2022-04-14 12:19:18 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
2022-04-26 23:01:45 +00:00
|
|
|
instance_grpc "github.com/zitadel/zitadel/internal/api/grpc/instance"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
2022-05-16 14:35:49 +00:00
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/instance"
|
2022-04-14 12:19:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ListInstanceDomainsRequestToModel(req *admin_pb.ListInstanceDomainsRequest) (*query.InstanceDomainSearchQueries, error) {
|
|
|
|
offset, limit, asc := object.ListQueryToModel(req.Query)
|
|
|
|
queries, err := instance_grpc.DomainQueriesToModel(req.Queries)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &query.InstanceDomainSearchQueries{
|
|
|
|
SearchRequest: query.SearchRequest{
|
2022-05-16 14:35:49 +00:00
|
|
|
Offset: offset,
|
|
|
|
Limit: limit,
|
|
|
|
Asc: asc,
|
|
|
|
SortingColumn: fieldNameToInstanceDomainColumn(req.SortingColumn),
|
2022-04-14 12:19:18 +00:00
|
|
|
},
|
|
|
|
Queries: queries,
|
|
|
|
}, nil
|
|
|
|
}
|
2022-05-16 14:35:49 +00:00
|
|
|
|
|
|
|
func fieldNameToInstanceDomainColumn(fieldName instance.DomainFieldName) query.Column {
|
|
|
|
switch fieldName {
|
|
|
|
case instance.DomainFieldName_DOMAIN_FIELD_NAME_DOMAIN:
|
|
|
|
return query.InstanceDomainDomainCol
|
|
|
|
case instance.DomainFieldName_DOMAIN_FIELD_NAME_PRIMARY:
|
|
|
|
return query.InstanceDomainIsPrimaryCol
|
|
|
|
case instance.DomainFieldName_DOMAIN_FIELD_NAME_GENERATED:
|
|
|
|
return query.InstanceDomainIsGeneratedCol
|
|
|
|
case instance.DomainFieldName_DOMAIN_FIELD_NAME_CREATION_DATE:
|
|
|
|
return query.InstanceDomainCreationDateCol
|
|
|
|
default:
|
|
|
|
return query.Column{}
|
|
|
|
}
|
|
|
|
}
|