mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package management
|
|
|
|
import (
|
|
action_grpc "github.com/zitadel/zitadel/internal/api/grpc/action"
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
|
)
|
|
|
|
func createActionRequestToDomain(req *mgmt_pb.CreateActionRequest) *domain.Action {
|
|
return &domain.Action{
|
|
Name: req.Name,
|
|
Script: req.Script,
|
|
Timeout: req.Timeout.AsDuration(),
|
|
AllowedToFail: req.AllowedToFail,
|
|
}
|
|
}
|
|
|
|
func updateActionRequestToDomain(req *mgmt_pb.UpdateActionRequest) *domain.Action {
|
|
return &domain.Action{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: req.Id,
|
|
},
|
|
Name: req.Name,
|
|
Script: req.Script,
|
|
Timeout: req.Timeout.AsDuration(),
|
|
AllowedToFail: req.AllowedToFail,
|
|
}
|
|
}
|
|
|
|
func listActionsToQuery(orgID string, req *mgmt_pb.ListActionsRequest) (_ *query.ActionSearchQueries, err error) {
|
|
offset, limit, asc := object.ListQueryToModel(req.Query)
|
|
queries := make([]query.SearchQuery, len(req.Queries)+1)
|
|
queries[0], err = query.NewActionResourceOwnerQuery(orgID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for i, actionQuery := range req.Queries {
|
|
queries[i+1], err = ActionQueryToQuery(actionQuery.Query)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return &query.ActionSearchQueries{
|
|
SearchRequest: query.SearchRequest{
|
|
Offset: offset,
|
|
Limit: limit,
|
|
Asc: asc,
|
|
},
|
|
Queries: queries,
|
|
}, nil
|
|
}
|
|
|
|
func ActionQueryToQuery(query interface{}) (query.SearchQuery, error) {
|
|
switch q := query.(type) {
|
|
case *mgmt_pb.ActionQuery_ActionNameQuery:
|
|
return action_grpc.ActionNameQuery(q.ActionNameQuery)
|
|
case *mgmt_pb.ActionQuery_ActionStateQuery:
|
|
return action_grpc.ActionStateQuery(q.ActionStateQuery)
|
|
}
|
|
return nil, nil
|
|
}
|