Skip to content

Commit

Permalink
feat(frontier): webhooks
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <[email protected]>
  • Loading branch information
kushsharma committed May 1, 2024
1 parent 3819daa commit 608c3cc
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
99 changes: 99 additions & 0 deletions raystack/frontier/v1beta1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<string, string> 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;
}
35 changes: 35 additions & 0 deletions raystack/frontier/v1beta1/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> 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 {
Expand Down

0 comments on commit 608c3cc

Please sign in to comment.