mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 23:57:31 +00:00
fix: refactor system api (#3500)
* fix: refactor system api * fix: search domains on get instance * fix: search domains on get instance * fix: return instance detail * fix: implement user sorting column (#3469) * fix: implement user sorting column * fix: implement user sorting column * fix: string column * isOrderByLower Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: user converter import * Update instance.go Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
instance_grpc "github.com/zitadel/zitadel/internal/api/grpc/instance"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
object_pb "github.com/zitadel/zitadel/pkg/grpc/object"
|
||||
system_pb "github.com/zitadel/zitadel/pkg/grpc/system"
|
||||
)
|
||||
@@ -29,13 +30,13 @@ func (s *Server) ListInstances(ctx context.Context, req *system_pb.ListInstances
|
||||
}
|
||||
|
||||
func (s *Server) GetInstance(ctx context.Context, req *system_pb.GetInstanceRequest) (*system_pb.GetInstanceResponse, error) {
|
||||
ctx = authz.WithInstanceID(ctx, req.Id)
|
||||
ctx = authz.WithInstanceID(ctx, req.InstanceId)
|
||||
instance, err := s.query.Instance(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.GetInstanceResponse{
|
||||
Instance: instance_grpc.InstanceToPb(instance),
|
||||
Instance: instance_grpc.InstanceDetailToPb(instance),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ func (s *Server) AddInstance(ctx context.Context, req *system_pb.AddInstanceRequ
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.AddInstanceResponse{
|
||||
Id: id,
|
||||
InstanceId: id,
|
||||
Details: object.AddToDetailsPb(
|
||||
details.Sequence,
|
||||
details.EventDate,
|
||||
@@ -55,8 +56,30 @@ func (s *Server) AddInstance(ctx context.Context, req *system_pb.AddInstanceRequ
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) ExistsDomain(ctx context.Context, req *system_pb.ExistsDomainRequest) (*system_pb.ExistsDomainResponse, error) {
|
||||
domainQuery, err := query.NewInstanceDomainDomainSearchQuery(query.TextEqualsIgnoreCase, req.Domain)
|
||||
|
||||
query := &query.InstanceDomainSearchQueries{
|
||||
SearchRequest: query.SearchRequest{
|
||||
Offset: 0,
|
||||
Limit: 1,
|
||||
Asc: true,
|
||||
},
|
||||
Queries: []query.SearchQuery{
|
||||
domainQuery,
|
||||
},
|
||||
}
|
||||
domains, err := s.query.SearchInstanceDomains(ctx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.ExistsDomainResponse{
|
||||
Exists: domains.Count > 0,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) ListDomains(ctx context.Context, req *system_pb.ListDomainsRequest) (*system_pb.ListDomainsResponse, error) {
|
||||
ctx = authz.WithInstanceID(ctx, req.Id)
|
||||
ctx = authz.WithInstanceID(ctx, req.InstanceId)
|
||||
queries, err := ListInstanceDomainsRequestToModel(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -77,7 +100,7 @@ func (s *Server) ListDomains(ctx context.Context, req *system_pb.ListDomainsRequ
|
||||
}
|
||||
|
||||
func (s *Server) AddDomain(ctx context.Context, req *system_pb.AddDomainRequest) (*system_pb.AddDomainResponse, error) {
|
||||
ctx = authz.WithInstanceID(ctx, req.Id)
|
||||
ctx = authz.WithInstanceID(ctx, req.InstanceId)
|
||||
instance, err := s.query.Instance(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -97,7 +120,7 @@ func (s *Server) AddDomain(ctx context.Context, req *system_pb.AddDomainRequest)
|
||||
}
|
||||
|
||||
func (s *Server) RemoveDomain(ctx context.Context, req *system_pb.RemoveDomainRequest) (*system_pb.RemoveDomainResponse, error) {
|
||||
ctx = authz.WithInstanceID(ctx, req.Id)
|
||||
ctx = authz.WithInstanceID(ctx, req.InstanceId)
|
||||
details, err := s.command.RemoveInstanceDomain(ctx, req.Domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -112,7 +135,7 @@ func (s *Server) RemoveDomain(ctx context.Context, req *system_pb.RemoveDomainRe
|
||||
}
|
||||
|
||||
func (s *Server) SetPrimaryDomain(ctx context.Context, req *system_pb.SetPrimaryDomainRequest) (*system_pb.SetPrimaryDomainResponse, error) {
|
||||
ctx = authz.WithInstanceID(ctx, req.Id)
|
||||
ctx = authz.WithInstanceID(ctx, req.InstanceId)
|
||||
details, err := s.command.SetPrimaryInstanceDomain(ctx, req.Domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user