feat(admin-api): list events (#4989)

* docs: update cockroachdb version to 22.2
* feat(adminAPI): ListEventTypes returns the list of event types ZITADEL implements
* feat(adminAPI): ListAggregateTypes returns the list of aggregate types ZITADEL implements
* feat(adminAPI): ListEvents allows `IAM_OWNERS` to search for events
This commit is contained in:
Silvan
2023-01-16 12:30:03 +01:00
committed by GitHub
parent 74c1c39207
commit 1bf1f335dc
30 changed files with 888 additions and 360 deletions

View File

@@ -10,6 +10,7 @@ import "zitadel/policy.proto";
import "zitadel/settings.proto";
import "zitadel/text.proto";
import "zitadel/member.proto";
import "zitadel/event.proto";
import "zitadel/management.proto";
import "zitadel/v1.proto";
@@ -2544,6 +2545,39 @@ service AdminService {
permission: "iam.read";
};
}
rpc ListEventTypes(ListEventTypesRequest) returns (ListEventTypesResponse) {
option (google.api.http) = {
post: "/events/types/_search";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "events.read";
};
}
rpc ListEvents(ListEventsRequest) returns (ListEventsResponse) {
option (google.api.http) = {
post: "/events/_search";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "events.read";
};
}
rpc ListAggregateTypes(ListAggregateTypesRequest) returns (ListAggregateTypesResponse) {
option (google.api.http) = {
post: "/aggregates/types/_search";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "events.read";
};
}
}
@@ -4797,3 +4831,76 @@ message ExportDataRequest {
message ExportDataResponse {
repeated DataOrg orgs = 1;
}
message ListEventsRequest {
// sequence represents the order of events. It's always upcounting
// if asc is false sequence is used as less than filter
// if asc is true sequence is used as greater than filter
// if sequence is 0 the field is ignored
uint64 sequence = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"2\"";
}
];
uint32 limit = 2 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "20";
description: "Maximum amount of events returned.";
}
];
bool asc = 3 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "default is descending sorting order"
}
];
string editor_user_id = 4 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"69629023906488334\"";
}
];
// the types are or filtered and must match the type exatly
repeated string event_types = 5 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "[\"user.human.added\", \"user.machine\"]";
}
];
string aggregate_id = 6 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"69629023906488334\"";
}
];
string aggregate_type = 7 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"user\"";
}
];
string resource_owner = 8 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"69629023906488334\"";
}
];
// if asc is false creation_date is used as less than filter
// if asc is true creation_date is used as greater than filter
// if creation_date is not set the field is ignored
google.protobuf.Timestamp creation_date = 9 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"2019-04-01T08:45:00.000000Z\"";
}
];
}
message ListEventsResponse {
repeated zitadel.event.v1.Event events = 1;
}
message ListEventTypesRequest {}
message ListEventTypesResponse {
repeated string event_types = 1;
}
message ListAggregateTypesRequest {}
message ListAggregateTypesResponse {
repeated string aggregate_types = 1;
}

36
proto/zitadel/event.proto Normal file
View File

@@ -0,0 +1,36 @@
syntax = "proto3";
import "google/protobuf/timestamp.proto";
import "google/protobuf/struct.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
package zitadel.event.v1;
option go_package ="github.com/zitadel/zitadel/pkg/grpc/event";
message Event {
Editor editor = 1;
Aggregate aggregate = 2;
uint64 sequence = 3;
// The timestamp the event occurred
google.protobuf.Timestamp creation_date = 4 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"2019-04-01T08:45:00.000000Z\"";
}
];
google.protobuf.Struct payload = 5;
string type = 6;
}
message Editor {
string user_id = 1;
string display_name = 2;
string service = 3;
}
message Aggregate {
string id = 1;
string type = 2;
string resource_owner = 3;
}