mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 21:37:17 +00:00
feat: Add DeleteInstance endpoint (#9452)
This commit is contained in:
27
internal/api/grpc/instance/v2/instance.go
Normal file
27
internal/api/grpc/instance/v2/instance.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/object/v2"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
"github.com/zitadel/zitadel/pkg/grpc/instance/v2"
|
||||
)
|
||||
|
||||
func (s *Server) DeleteInstance(ctx context.Context, request *instance.DeleteInstanceRequest) (*instance.DeleteInstanceResponse, error) {
|
||||
instanceID := strings.TrimSpace(request.GetInstanceId())
|
||||
if instanceID == "" {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "instance_id", "instance id must not be empty")
|
||||
}
|
||||
|
||||
obj, err := s.command.RemoveInstance(ctx, instanceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &instance.DeleteInstanceResponse{
|
||||
Details: object.DomainToDetailsPb(obj),
|
||||
}, nil
|
||||
|
||||
}
|
||||
55
internal/api/grpc/instance/v2/server.go
Normal file
55
internal/api/grpc/instance/v2/server.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/server"
|
||||
"github.com/zitadel/zitadel/internal/command"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
"github.com/zitadel/zitadel/pkg/grpc/instance/v2"
|
||||
)
|
||||
|
||||
var _ instance.InstanceServiceServer = (*Server)(nil)
|
||||
|
||||
type Server struct {
|
||||
instance.UnimplementedInstanceServiceServer
|
||||
command *command.Commands
|
||||
query *query.Queries
|
||||
checkPermission domain.PermissionCheck
|
||||
}
|
||||
|
||||
type Config struct{}
|
||||
|
||||
func CreateServer(
|
||||
command *command.Commands,
|
||||
query *query.Queries,
|
||||
checkPermission domain.PermissionCheck,
|
||||
) *Server {
|
||||
return &Server{
|
||||
command: command,
|
||||
query: query,
|
||||
checkPermission: checkPermission,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
|
||||
instance.RegisterInstanceServiceServer(grpcServer, s)
|
||||
}
|
||||
|
||||
func (s *Server) AppName() string {
|
||||
return instance.InstanceService_ServiceDesc.ServiceName
|
||||
}
|
||||
|
||||
func (s *Server) MethodPrefix() string {
|
||||
return instance.InstanceService_ServiceDesc.ServiceName
|
||||
}
|
||||
|
||||
func (s *Server) AuthMethods() authz.MethodMapping {
|
||||
return instance.InstanceService_AuthMethods
|
||||
}
|
||||
|
||||
func (s *Server) RegisterGateway() server.RegisterGatewayFunc {
|
||||
return instance.RegisterInstanceServiceHandler
|
||||
}
|
||||
Reference in New Issue
Block a user