diff --git a/raystack/frontier/v1beta1/admin.proto b/raystack/frontier/v1beta1/admin.proto index b23c83a0..0501b91f 100644 --- a/raystack/frontier/v1beta1/admin.proto +++ b/raystack/frontier/v1beta1/admin.proto @@ -353,6 +353,49 @@ service AdminService { description: "Revert billing usage for a billing account."; }; } + + // Webhooks + rpc CreateWebhook(CreateWebhookRequest) returns (CreateWebhookResponse) { + option (google.api.http) = { + post: "/v1beta1/admin/webhooks", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Webhook"; + summary: "Create webhook"; + description: "Create a new webhook."; + }; + } + + rpc UpdateWebhook(UpdateWebhookRequest) returns (UpdateWebhookResponse) { + option (google.api.http) = { + put: "/v1beta1/admin/webhooks/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Webhook"; + summary: "Update webhook"; + description: "Update a webhook."; + }; + } + + rpc DeleteWebhook(DeleteWebhookRequest) returns (DeleteWebhookResponse) { + option (google.api.http) = {delete: "/v1beta1/admin/webhooks/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Webhook"; + summary: "Delete webhook"; + description: "Delete a webhook."; + }; + } + + rpc ListWebhooks(ListWebhooksRequest) returns (ListWebhooksResponse) { + option (google.api.http) = {get: "/v1beta1/admin/webhooks"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Webhook"; + summary: "List webhooks"; + description: "List all webhooks."; + }; + } } message ListAllUsersRequest { @@ -612,3 +655,59 @@ message RevertBillingUsageRequest { } message RevertBillingUsageResponse {} + +message WebhookRequestBody { + // URL to send the webhook to (valid absolute URI via RFC 3986) + string url = 1 [(validate.rules).string = {uri: true}]; + string description = 2; + // events to subscribe to, if empty all events are subscribed + repeated string subscribed_events = 3; + // headers to be sent with the webhook + map headers = 4; + string state = 5 [(validate.rules).string = { + ignore_empty: true, + in: [ + "enabled", + "disabled" + ] + }]; + + google.protobuf.Struct metadata = 20; +} + +message CreateWebhookRequest { + WebhookRequestBody body = 1; +} + +message CreateWebhookResponse { + Webhook webhook = 1; +} + +message UpdateWebhookRequest { + string id = 1 [ + (google.api.field_behavior) = REQUIRED, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The webhook id to update."}, + (validate.rules).string.uuid = true + ]; + WebhookRequestBody body = 2; +} + +message UpdateWebhookResponse { + Webhook webhook = 1; +} + +message DeleteWebhookRequest { + string id = 1 [ + (google.api.field_behavior) = REQUIRED, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The webhook id to delete."}, + (validate.rules).string.uuid = true + ]; +} + +message DeleteWebhookResponse {} + +message ListWebhooksRequest {} + +message ListWebhooksResponse { + repeated Webhook webhooks = 1; +} diff --git a/raystack/frontier/v1beta1/models.proto b/raystack/frontier/v1beta1/models.proto index 8a96bc3d..d14092d2 100644 --- a/raystack/frontier/v1beta1/models.proto +++ b/raystack/frontier/v1beta1/models.proto @@ -858,6 +858,41 @@ message PaymentMethod { google.protobuf.Timestamp created_at = 21; } +message Webhook { + message Secret { + string id = 1; + string value = 2; + } + + string id = 1; + string description = 2; + string url = 3; + repeated string subscribed_events = 4; + // headers to be sent with the webhook + map headers = 5; + + // secret to sign the payload, there could be multiple enabled secrets for a webhook + // but only one will be used to sign the payload, this is useful for rotating secrets + repeated Secret secrets = 6; + string state = 7; + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21; + google.protobuf.Timestamp updated_at = 22; +} + +message WebhookEvent { + string id = 1; + string action = 2; + google.protobuf.Struct data = 3; + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + description: "The time the log was created.", + example: "\"2023-06-07T05:39:56.961Z\"" + }]; +} + // Model crud body message RoleRequestBody {