mirror of
https://github.com/zitadel/zitadel.git
synced 2026-07-25 18:28:00 +00:00
# Which Problems Are Solved This PR implements the endpoints listed in https://github.com/zitadel/zitadel/issues/10444 . # How the Problems Are Solved The implementation follows the same pattern as the Instance one. The `Add` and `Remove` are implementing the `Commander` interface, while `List` Domains endpoints are implementing the `Querier` interace. The PR adds also some forgotten calls to the relational logic for the Instance API. The commits are identifiable by the label `instance:` prepended to them. This is the complete list: bafce01b0 , 6fe7257ab , e27bc9c34 , 8133ede73 , fde667953 , a3e1135ed , ee1a6f9c1 # Additional Context - Closes #10444 --------- Co-authored-by: Elio Bischof <elio@zitadel.com> Co-authored-by: Lebogang Phoshoko <phoshokolebogang@outlook.com> Co-authored-by: Wim Van Laer <van.laer.wim@gmail.com> Co-authored-by: Max Peintner <max@caos.ch> Co-authored-by: Gayathri Vijayan <66356931+grvijayan@users.noreply.github.com>
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package instance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"connectrpc.com/connect"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
instancev2 "github.com/zitadel/zitadel/backend/v3/api/instance/v2"
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/pkg/grpc/instance/v2"
|
|
)
|
|
|
|
func (s *Server) DeleteInstance(ctx context.Context, request *connect.Request[instance.DeleteInstanceRequest]) (*connect.Response[instance.DeleteInstanceResponse], error) {
|
|
// Deleting an instance is currently only allowed with system permissions,
|
|
// so we directly check for them in the auth interceptor and do not check here again.
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.DeleteInstance(ctx, request)
|
|
}
|
|
|
|
obj, err := s.command.RemoveInstance(ctx, request.Msg.GetInstanceId(), false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// obj is nil when the instance is not found, so we return an empty message.
|
|
if obj == nil {
|
|
return &connect.Response[instance.DeleteInstanceResponse]{}, nil
|
|
}
|
|
return connect.NewResponse(&instance.DeleteInstanceResponse{
|
|
DeletionDate: timestamppb.New(obj.EventDate),
|
|
}), nil
|
|
|
|
}
|
|
|
|
func (s *Server) UpdateInstance(ctx context.Context, request *connect.Request[instance.UpdateInstanceRequest]) (*connect.Response[instance.UpdateInstanceResponse], error) {
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.UpdateInstance(ctx, request)
|
|
}
|
|
|
|
if err := s.checkPermission(ctx, domain.PermissionSystemInstanceWrite, domain.PermissionInstanceWrite); err != nil {
|
|
return nil, err
|
|
}
|
|
obj, err := s.command.UpdateInstance(ctx, request.Msg.GetInstanceName())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return connect.NewResponse(&instance.UpdateInstanceResponse{
|
|
ChangeDate: timestamppb.New(obj.EventDate),
|
|
}), nil
|
|
}
|