zitadel/pkg/management/api/grpc/org.go
Fabi 1de574df42
fix: query side (#257)
* fix: project by id return projectview

* fix: return always view model on query side

* fix: return always view model on query side
2020-06-23 07:06:07 +02:00

76 lines
2.1 KiB
Go

package grpc
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
)
func (s *Server) GetOrgByID(ctx context.Context, orgID *OrgID) (*OrgView, error) {
org, err := s.org.OrgByID(ctx, orgID.Id)
if err != nil {
return nil, err
}
return orgViewFromModel(org), nil
}
func (s *Server) GetOrgByDomainGlobal(ctx context.Context, in *OrgDomain) (*OrgView, error) {
org, err := s.org.OrgByDomainGlobal(ctx, in.Domain)
if err != nil {
return nil, err
}
return orgViewFromModel(org), nil
}
func (s *Server) DeactivateOrg(ctx context.Context, in *OrgID) (*Org, error) {
org, err := s.org.DeactivateOrg(ctx, in.Id)
if err != nil {
return nil, err
}
return orgFromModel(org), nil
}
func (s *Server) ReactivateOrg(ctx context.Context, in *OrgID) (*Org, error) {
org, err := s.org.ReactivateOrg(ctx, in.Id)
if err != nil {
return nil, err
}
return orgFromModel(org), nil
}
func (s *Server) SearchMyOrgDomains(ctx context.Context, in *OrgDomainSearchRequest) (*OrgDomainSearchResponse, error) {
domains, err := s.org.SearchMyOrgDomains(ctx, orgDomainSearchRequestToModel(in))
if err != nil {
return nil, err
}
return orgDomainSearchResponseFromModel(domains), nil
}
func (s *Server) AddMyOrgDomain(ctx context.Context, in *AddOrgDomainRequest) (*OrgDomain, error) {
domain, err := s.org.AddMyOrgDomain(ctx, addOrgDomainToModel(in))
if err != nil {
return nil, err
}
return orgDomainFromModel(domain), nil
}
func (s *Server) RemoveMyOrgDomain(ctx context.Context, in *RemoveOrgDomainRequest) (*empty.Empty, error) {
err := s.org.RemoveMyOrgDomain(ctx, in.Domain)
return &empty.Empty{}, err
}
func (s *Server) OrgChanges(ctx context.Context, changesRequest *ChangeRequest) (*Changes, error) {
response, err := s.org.OrgChanges(ctx, changesRequest.Id, 0, 0)
if err != nil {
return nil, err
}
return orgChangesToResponse(response, changesRequest.GetSequenceOffset(), changesRequest.GetLimit()), nil
}
func (s *Server) GetMyOrgIamPolicy(ctx context.Context, _ *empty.Empty) (_ *OrgIamPolicy, err error) {
policy, err := s.org.GetMyOrgIamPolicy(ctx)
if err != nil {
return nil, err
}
return orgIamPolicyFromModel(policy), err
}