feat: query side for executions and targets for actions v2 (#7524)

* feat: add projections and query side to executions and targets

* feat: add list and get endpoints for targets

* feat: add integration tests for query endpoints target and execution

* fix: linting

* fix: linting

* fix: review changes, renames and corrections

* fix: review changes, renames and corrections

* fix: review changes, renames and corrections

* fix: review changes, renames and corrections

* fix: review changes, renames and corrections

* fix: review changes, renames and corrections

* fix: remove position from list details
This commit is contained in:
Stefan Benz
2024-03-14 10:56:23 +01:00
committed by GitHub
parent 5d2cfc06d5
commit fb3c6f791b
30 changed files with 3266 additions and 326 deletions

View File

@@ -13,23 +13,37 @@ import "zitadel/protoc_gen_zitadel/v2/options.proto";
option go_package = "github.com/zitadel/zitadel/pkg/grpc/execution/v3alpha;execution";
message SetConditions{
message Execution {
string execution_id = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"request.zitadel.session.v2beta.SessionService\"";
}
];
// Details provide some base information (such as the last change date) of the target.
zitadel.object.v2beta.Details details = 2;
// Targets which are called in the defined conditions.
repeated string targets = 3;
// Included executions with the same condition-types.
repeated string includes = 4;
}
message Condition {
// Condition-types under which conditions the execution should happen, only one possible.
oneof condition_type {
option (validate.required) = true;
// Condition-type to execute if a request on the defined API point happens.
SetRequestExecution request = 1;
RequestExecution request = 1;
// Condition-type to execute on response if a request on the defined API point happens.
SetResponseExecution response = 2;
ResponseExecution response = 2;
// Condition-type to execute if function is used, replaces actions v1.
string function = 3;
// Condition-type to execute if an event is created in the system.
SetEventExecution event = 4;
EventExecution event = 4;
}
}
message SetRequestExecution{
message RequestExecution {
// Condition for the request execution, only one possible.
oneof condition{
// GRPC-method as condition.
@@ -55,7 +69,7 @@ message SetRequestExecution{
}
}
message SetResponseExecution{
message ResponseExecution {
// Condition for the response execution, only one possible.
oneof condition{
// GRPC-method as condition.
@@ -81,7 +95,7 @@ message SetResponseExecution{
}
}
message SetEventExecution{
message EventExecution{
// Condition for the event execution, only one possible.
oneof condition{
// Event name as condition.

View File

@@ -10,6 +10,7 @@ import "protoc-gen-openapiv2/options/annotations.proto";
import "validate/validate.proto";
import "zitadel/execution/v3alpha/target.proto";
import "zitadel/execution/v3alpha/execution.proto";
import "zitadel/execution/v3alpha/query.proto";
import "zitadel/object/v2beta/object.proto";
import "zitadel/protoc_gen_zitadel/v2/options.proto";
@@ -187,12 +188,73 @@ service ExecutionService {
};
}
// List targets
//
// List all matching targets. By default, we will return all targets of your instance.
// Make sure to include a limit and sorting for pagination.
rpc ListTargets (ListTargetsRequest) returns (ListTargetsResponse) {
option (google.api.http) = {
post: "/v3alpha/targets/search"
body: "*"
};
option (zitadel.protoc_gen_zitadel.v2.options) = {
auth_option: {
permission: "execution.target.read"
}
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
responses: {
key: "200";
value: {
description: "A list of all targets matching the query";
};
};
responses: {
key: "400";
value: {
description: "invalid list query";
schema: {
json_schema: {
ref: "#/definitions/rpcStatus";
};
};
};
};
};
}
// Target by ID
//
// Returns the target identified by the requested ID.
rpc GetTargetByID (GetTargetByIDRequest) returns (GetTargetByIDResponse) {
option (google.api.http) = {
get: "/v3alpha/targets/{target_id}"
};
option (zitadel.protoc_gen_zitadel.v2.options) = {
auth_option: {
permission: "execution.target.read"
}
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
responses: {
key: "200"
value: {
description: "Target successfully retrieved";
}
};
};
}
// Set an execution
//
// Set an execution to call a previously defined target or include the targets of a previously defined execution.
rpc SetExecution (SetExecutionRequest) returns (SetExecutionResponse) {
option (google.api.http) = {
post: "/v3alpha/executions"
put: "/v3alpha/executions"
body: "*"
};
@@ -236,6 +298,44 @@ service ExecutionService {
};
};
}
// List executions
//
// List all matching executions. By default, we will return all executions of your instance.
// Make sure to include a limit and sorting for pagination.
rpc ListExecutions (ListExecutionsRequest) returns (ListExecutionsResponse) {
option (google.api.http) = {
post: "/v3alpha/executions/search"
body: "*"
};
option (zitadel.protoc_gen_zitadel.v2.options) = {
auth_option: {
permission: "execution.read"
}
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
responses: {
key: "200";
value: {
description: "A list of all executions matching the query";
};
};
responses: {
key: "400";
value: {
description: "invalid list query";
schema: {
json_schema: {
ref: "#/definitions/rpcStatus";
};
};
};
};
};
}
// List all available functions
//
// List all available functions which can be used as condition for executions.
@@ -412,9 +512,48 @@ message DeleteTargetResponse {
zitadel.object.v2beta.Details details = 1;
}
message ListTargetsRequest {
// list limitations and ordering.
zitadel.object.v2beta.ListQuery query = 1;
// the field the result is sorted.
zitadel.execution.v3alpha.TargetFieldName sorting_column = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"FIELD_NAME_SCHEMA_TYPE\""
}
];
// Define the criteria to query for.
repeated zitadel.execution.v3alpha.TargetSearchQuery queries = 3;
}
message ListTargetsResponse {
// Details provides information about the returned result including total amount found.
zitadel.object.v2beta.ListDetails details = 1;
// States by which field the results are sorted.
zitadel.execution.v3alpha.TargetFieldName sorting_column = 2;
// The result contains the user schemas, which matched the queries.
repeated zitadel.execution.v3alpha.Target result = 3;
}
message GetTargetByIDRequest {
// unique identifier of the target.
string target_id = 1 [
(validate.rules).string = {min_len: 1, max_len: 200},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
min_length: 1,
max_length: 200,
example: "\"69629026806489455\"";
}
];
}
message GetTargetByIDResponse {
zitadel.execution.v3alpha.Target target = 1;
}
message SetExecutionRequest {
// Defines the condition type and content of the condition for execution.
SetConditions condition = 1;
Condition condition = 1;
// Defines the execution targets which are defined as a different resource, which are called in the defined conditions.
repeated string targets = 2;
// Defines other executions as included with the same condition-types.
@@ -428,7 +567,7 @@ message SetExecutionResponse {
message DeleteExecutionRequest {
// Unique identifier of the execution.
SetConditions condition = 1;
Condition condition = 1;
}
message DeleteExecutionResponse {
@@ -436,6 +575,20 @@ message DeleteExecutionResponse {
zitadel.object.v2beta.Details details = 1;
}
message ListExecutionsRequest {
// list limitations and ordering.
zitadel.object.v2beta.ListQuery query = 1;
// Define the criteria to query for.
repeated zitadel.execution.v3alpha.SearchQuery queries = 2;
}
message ListExecutionsResponse {
// Details provides information about the returned result including total amount found.
zitadel.object.v2beta.ListDetails details = 1;
// The result contains the executions, which matched the queries.
repeated zitadel.execution.v3alpha.Execution result = 2;
}
message ListExecutionFunctionsRequest{}
message ListExecutionFunctionsResponse{
// All available methods

View File

@@ -0,0 +1,110 @@
syntax = "proto3";
package zitadel.execution.v3alpha;
option go_package = "github.com/zitadel/zitadel/pkg/grpc/execution/v3alpha;execution";
import "google/api/field_behavior.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "validate/validate.proto";
import "zitadel/object/v2beta/object.proto";
import "zitadel/execution/v3alpha/execution.proto";
message SearchQuery {
oneof query {
option (validate.required) = true;
InConditionsQuery in_conditions_query = 1;
ExecutionTypeQuery execution_type_query = 2;
TargetQuery target_query = 3;
IncludeQuery include_query = 4;
}
}
message InConditionsQuery {
// Defines the conditions to query for.
repeated Condition conditions = 1;
}
message ExecutionTypeQuery {
// Defines the type to query for.
ExecutionType execution_type = 1;
}
message TargetQuery {
// Defines the id to query for.
string target_id = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "the id of the targets to include"
example: "\"69629023906488334\"";
}
];
}
message IncludeQuery {
// Defines the include to query for.
string include = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "the id of the include"
example: "\"request.zitadel.session.v2beta.SessionService\"";
}
];
}
message TargetSearchQuery {
oneof query {
option (validate.required) = true;
TargetNameQuery target_name_query = 1;
InTargetIDsQuery in_target_ids_query = 2;
}
}
message TargetNameQuery {
// Defines the name of the target to query for.
string target_name = 1 [
(validate.rules).string = {max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
max_length: 200;
example: "\"ip_allow_list\"";
}
];
// Defines which text comparison method used for the name query.
zitadel.object.v2beta.TextQueryMethod method = 2 [
(validate.rules).enum.defined_only = true,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "defines which text equality method is used";
}
];
}
message InTargetIDsQuery {
// Defines the ids to query for.
repeated string target_ids = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "the ids of the targets to include"
example: "[\"69629023906488334\",\"69622366012355662\"]";
}
];
}
enum ExecutionType {
EXECUTION_TYPE_UNSPECIFIED = 0;
EXECUTION_TYPE_REQUEST = 1;
EXECUTION_TYPE_RESPONSE = 2;
EXECUTION_TYPE_EVENT = 3;
EXECUTION_TYPE_FUNCTION = 4;
}
enum TargetFieldName {
FIELD_NAME_UNSPECIFIED = 0;
FIELD_NAME_ID = 1;
FIELD_NAME_CREATION_DATE = 2;
FIELD_NAME_CHANGE_DATE = 3;
FIELD_NAME_NAME = 4;
FIELD_NAME_TARGET_TYPE = 5;
FIELD_NAME_URL = 6;
FIELD_NAME_TIMEOUT = 7;
FIELD_NAME_ASYNC = 8;
FIELD_NAME_INTERRUPT_ON_ERROR = 9;
}

View File

@@ -35,4 +35,39 @@ message SetRESTRequestResponse {
example: "\"https://example.com/hooks/ip_check\"";
}
];
}
message Target {
// ID is the read-only unique identifier of the target.
string target_id = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"69629012906488334\"";
}
];
// Details provide some base information (such as the last change date) of the target.
zitadel.object.v2beta.Details details = 2;
// Unique name of the target.
string name = 3 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"ip_allow_list\"";
}
];
// Defines the target type and how the response of the target is treated.
oneof target_type {
SetRESTWebhook rest_webhook = 4;
SetRESTRequestResponse rest_request_response = 5;
}
// Timeout defines the duration until ZITADEL cancels the execution.
google.protobuf.Duration timeout = 6 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"10s\"";
}
];
oneof execution_type {
// Set the execution to run asynchronously.
bool is_async = 7;
// Define if any error stops the whole execution. By default the process continues as normal.
bool interrupt_on_error = 8;
}
}