2020-03-24 09:14:39 +00:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-06-16 09:40:18 +00:00
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
2020-03-24 09:14:39 +00:00
|
|
|
)
|
|
|
|
|
2020-05-13 12:22:29 +00:00
|
|
|
func (s *Server) GetOrgByID(ctx context.Context, orgID *OrgID) (*Org, error) {
|
|
|
|
org, err := s.org.OrgByID(ctx, orgID.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgFromModel(org), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) GetOrgByDomainGlobal(ctx context.Context, in *OrgDomain) (*Org, error) {
|
2020-05-13 12:22:29 +00:00
|
|
|
org, err := s.org.OrgByDomainGlobal(ctx, in.Domain)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-06-16 09:40:18 +00:00
|
|
|
return orgFromModel(org), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DeactivateOrg(ctx context.Context, in *OrgID) (*Org, error) {
|
2020-05-13 12:22:29 +00:00
|
|
|
org, err := s.org.DeactivateOrg(ctx, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgFromModel(org), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ReactivateOrg(ctx context.Context, in *OrgID) (*Org, error) {
|
2020-05-13 12:22:29 +00:00
|
|
|
org, err := s.org.ReactivateOrg(ctx, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgFromModel(org), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 09:40:18 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
func (s *Server) OrgChanges(ctx context.Context, changesRequest *ChangeRequest) (*Changes, error) {
|
2020-06-15 14:50:09 +00:00
|
|
|
response, err := s.org.OrgChanges(ctx, changesRequest.Id, 0, 0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgChangesToResponse(response, changesRequest.GetSequenceOffset(), changesRequest.GetLimit()), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|