zitadel/internal/api/grpc/admin/org_converter.go
2021-03-11 09:40:40 +01:00

35 lines
893 B
Go

package admin
import (
"github.com/caos/zitadel/internal/api/grpc/object"
org_grpc "github.com/caos/zitadel/internal/api/grpc/org"
"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/org/model"
"github.com/caos/zitadel/pkg/grpc/admin"
)
func listOrgRequestToModel(req *admin.ListOrgsRequest) (*model.OrgSearchRequest, error) {
offset, limit, asc := object.ListQueryToModel(req.Query)
queries, err := org_grpc.OrgQueriesToModel(req.Queries)
if err != nil {
return nil, err
}
return &model.OrgSearchRequest{
Offset: offset,
Limit: limit,
Asc: asc,
Queries: queries,
}, nil
}
func setUpOrgOrgToDomain(req *admin.SetUpOrgRequest_Org) *domain.Org {
org := &domain.Org{
Name: req.Name,
Domains: []*domain.OrgDomain{},
}
if req.Domain != "" {
org.Domains = append(org.Domains, &domain.OrgDomain{Domain: req.Domain})
}
return org
}