mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
8d13f170e8
* feat: add v2alpha policies service * feat: add v2alpha policies service * fix: rename of attributes and messages in v2alpha api * fix: rename of attributes and messages in v2alpha api * fix: linter corrections * fix: review corrections * fix: review corrections * fix: review corrections * fix: review corrections * fix grpc * refactor: rename to settings and more * Apply suggestions from code review Co-authored-by: Fabi <fabienne.gerschwiler@gmail.com> * add service to docs and rename legal settings * unit tests for converters * go mod tidy * ensure idp name and return list details * fix: use correct resource owner for active idps * change query to join --------- Co-authored-by: Livio Spring <livio.a@gmail.com> Co-authored-by: Fabi <fabienne.gerschwiler@gmail.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package object
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
object "github.com/zitadel/zitadel/pkg/grpc/object/v2alpha"
|
|
)
|
|
|
|
func DomainToDetailsPb(objectDetail *domain.ObjectDetails) *object.Details {
|
|
details := &object.Details{
|
|
Sequence: objectDetail.Sequence,
|
|
ResourceOwner: objectDetail.ResourceOwner,
|
|
}
|
|
if !objectDetail.EventDate.IsZero() {
|
|
details.ChangeDate = timestamppb.New(objectDetail.EventDate)
|
|
}
|
|
return details
|
|
}
|
|
|
|
func ToListDetails(response query.SearchResponse) *object.ListDetails {
|
|
details := &object.ListDetails{
|
|
TotalResult: response.Count,
|
|
ProcessedSequence: response.Sequence,
|
|
}
|
|
if !response.Timestamp.IsZero() {
|
|
details.Timestamp = timestamppb.New(response.Timestamp)
|
|
}
|
|
|
|
return details
|
|
}
|
|
func ListQueryToQuery(query *object.ListQuery) (offset, limit uint64, asc bool) {
|
|
if query == nil {
|
|
return 0, 0, false
|
|
}
|
|
return query.Offset, uint64(query.Limit), query.Asc
|
|
}
|
|
|
|
func ResourceOwnerFromReq(ctx context.Context, req *object.RequestContext) string {
|
|
if req.GetInstance() {
|
|
return authz.GetInstance(ctx).InstanceID()
|
|
}
|
|
if req.GetOrgId() != "" {
|
|
return req.GetOrgId()
|
|
}
|
|
return authz.GetCtxData(ctx).OrgID
|
|
}
|