mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-27 05:30:51 +00:00

* feat(actions): begin api * feat(actions): begin api * api and projections * fix: handle multiple statements for a single event in projections * export func type * fix test * update to new reduce interface * flows in login * feat: jwt idp * feat: command side * feat: add tests * actions and flows * fill idp views with jwt idps and return apis * add jwtEndpoint to jwt idp * begin jwt request handling * add feature * merge * merge * handle jwt idp * cleanup * bug fixes * autoregister * get token from specific header name * fix: proto * fixes * i18n * begin tests * fix and log http proxy * remove docker cache * fixes * usergrants in actions api * tests adn cleanup * cleanup * fix add user grant * set login context * i18n Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package management
|
|
|
|
import (
|
|
action_grpc "github.com/caos/zitadel/internal/api/grpc/action"
|
|
"github.com/caos/zitadel/internal/api/grpc/object"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
"github.com/caos/zitadel/internal/query"
|
|
mgmt_pb "github.com/caos/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(id 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(id)
|
|
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
|
|
}
|