From e80cef242ecc132e83a7127b21de9c2608913317 Mon Sep 17 00:00:00 2001 From: Praveen Yadav Date: Tue, 16 Nov 2021 08:59:49 +0530 Subject: [PATCH] refactor: move APIs from v1 to sirenv1beta1 --- odpf/siren/{v1 => v1beta1}/siren.proto | 228 +++++++++---------------- 1 file changed, 79 insertions(+), 149 deletions(-) rename odpf/siren/{v1 => v1beta1}/siren.proto (83%) diff --git a/odpf/siren/v1/siren.proto b/odpf/siren/v1beta1/siren.proto similarity index 83% rename from odpf/siren/v1/siren.proto rename to odpf/siren/v1beta1/siren.proto index 494cebf6..d1e37b8e 100644 --- a/odpf/siren/v1/siren.proto +++ b/odpf/siren/v1beta1/siren.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package odpf.siren.v1; +package odpf.siren.v1beta1; import "google/api/annotations.proto"; import "google/api/field_behavior.proto"; @@ -10,7 +10,7 @@ import "google/protobuf/empty.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; import "validate/validate.proto"; -option go_package = "github.com/odpf/proton/siren/v1;sirenv1"; +option go_package = "github.com/odpf/proton/siren/v1beta1;sirenv1beta1"; option java_multiple_files = true; option java_package = "io.odpf.proton.siren"; option java_outer_classname = "ServiceManager"; @@ -37,6 +37,7 @@ service SirenService { }; } + rpc ListProviders(ListProvidersRequest) returns (ListProvidersResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "list providers"; @@ -44,7 +45,7 @@ service SirenService { }; option (google.api.http) = { - get: "/providers" + get: "/v1beta1/providers" }; } @@ -55,7 +56,7 @@ service SirenService { }; option (google.api.http) = { - post: "/providers" + post: "/v1beta1/providers" body: "*" }; } @@ -67,7 +68,7 @@ service SirenService { }; option (google.api.http) = { - get: "/providers/{id}" + get: "/v1beta1/providers/{id}" }; } @@ -78,7 +79,7 @@ service SirenService { }; option (google.api.http) = { - put: "/providers/{id}", + put: "/v1beta1/providers/{id}", body: "*" }; } @@ -90,7 +91,19 @@ service SirenService { }; option (google.api.http) = { - delete: "/providers/{id}" + delete: "/v1beta1/providers/{id}" + }; + } + + rpc SendReceiverNotification(SendReceiverNotificationRequest) returns (SendReceiverNotificationResponse) { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "send notification to receiver"; + tags: "Receiver"; + }; + + option (google.api.http) = { + post: "/v1beta1/receivers/{id}/send" + body: "*" }; } @@ -102,7 +115,7 @@ service SirenService { }; option (google.api.http) = { - get: "/namespaces" + get: "/v1beta1/namespaces" }; } @@ -113,7 +126,7 @@ service SirenService { }; option (google.api.http) = { - post: "/namespaces" + post: "/v1beta1/namespaces" body: "*" }; } @@ -125,7 +138,7 @@ service SirenService { }; option (google.api.http) = { - get: "/namespaces/{id}" + get: "/v1beta1/namespaces/{id}" }; } @@ -136,7 +149,7 @@ service SirenService { }; option (google.api.http) = { - put: "/namespaces/{id}", + put: "/v1beta1/namespaces/{id}", body: "*" }; } @@ -148,10 +161,11 @@ service SirenService { }; option (google.api.http) = { - delete: "/namespaces/{id}" + delete: "/v1beta1/namespaces/{id}" }; } + rpc ListReceivers(google.protobuf.Empty) returns (ListReceiversResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "list receivers"; @@ -159,7 +173,7 @@ service SirenService { }; option (google.api.http) = { - get: "/receivers" + get: "/v1beta1/receivers" }; } @@ -170,7 +184,7 @@ service SirenService { }; option (google.api.http) = { - post: "/receivers" + post: "/v1beta1/receivers" body: "*" }; } @@ -182,7 +196,7 @@ service SirenService { }; option (google.api.http) = { - get: "/receivers/{id}" + get: "/v1beta1/receivers/{id}" }; } @@ -193,7 +207,7 @@ service SirenService { }; option (google.api.http) = { - put: "/receivers/{id}", + put: "/v1beta1/receivers/{id}", body: "*" }; } @@ -205,10 +219,11 @@ service SirenService { }; option (google.api.http) = { - delete: "/receivers/{id}" + delete: "/v1beta1/receivers/{id}" }; } + rpc ListAlerts(ListAlertsRequest) returns (Alerts) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "list alerts"; @@ -216,19 +231,7 @@ service SirenService { }; option (google.api.http) = { - get: "/alerts/{provider_name}/{provider_id}" - }; - } - - rpc SendReceiverNotification(SendReceiverNotificationRequest) returns (SendReceiverNotificationResponse) { - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - summary: "send notification to receiver"; - tags: "Receiver"; - }; - - option (google.api.http) = { - post: "/receivers/{id}/send" - body: "*" + get: "/v1beta1/alerts/{provider_name}/{provider_id}" }; } @@ -239,35 +242,12 @@ service SirenService { }; option (google.api.http) = { - post: "/alerts/cortex/{provider_id}" - body: "*" - }; - } - - rpc ListWorkspaceChannels(ListWorkspaceChannelsRequest) returns (ListWorkspaceChannelsResponse) { - option (google.api.http) = { - get: "/slackworkspaces/{workspace_name}/channels" - }; - } - rpc ExchangeCode(ExchangeCodeRequest) returns (ExchangeCodeResponse) { - option (google.api.http) = { - post: "/oauth/slack/token", - body: "*" - }; - } - rpc GetAlertCredentials(GetAlertCredentialsRequest) returns (GetAlertCredentialsResponse) { - option (google.api.http) = { - get: "/teams/{team_name}/credentials" - }; - } - - rpc UpdateAlertCredentials(UpdateAlertCredentialsRequest) returns (UpdateAlertCredentialsResponse) { - option (google.api.http) = { - put: "/teams/{team_name}/credentials" + post: "/v1beta1/alerts/cortex/{provider_id}" body: "*" }; } + rpc ListRules(ListRulesRequest) returns (ListRulesResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "list rules"; @@ -275,9 +255,10 @@ service SirenService { }; option (google.api.http) = { - get: "/rules" + get: "/v1beta1/rules" }; } + rpc UpdateRule(UpdateRuleRequest) returns (UpdateRuleResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "add/update a rule"; @@ -285,11 +266,12 @@ service SirenService { }; option (google.api.http) = { - put: "/rules" + put: "/v1beta1/rules" body: "*" }; } - + + rpc ListTemplates(ListTemplatesRequest) returns (ListTemplatesResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "list templates"; @@ -297,7 +279,7 @@ service SirenService { }; option (google.api.http) = { - get: "/templates" + get: "/v1beta1/templates" }; } @@ -308,7 +290,7 @@ service SirenService { }; option (google.api.http) = { - get: "/templates/{name}" + get: "/v1beta1/templates/{name}" }; } @@ -319,10 +301,11 @@ service SirenService { }; option (google.api.http) = { - put: "/templates", + put: "/v1beta1/templates", body: "*" }; } + rpc DeleteTemplate(DeleteTemplateRequest) returns (DeleteTemplateResponse) { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "delete a template"; @@ -330,7 +313,7 @@ service SirenService { }; option (google.api.http) = { - delete: "/templates/{name}", + delete: "/v1beta1/templates/{name}", }; } @@ -341,7 +324,7 @@ service SirenService { }; option (google.api.http) = { - post: "/templates/{name}/render", + post: "/v1beta1/templates/{name}/render", body: "*" }; } @@ -484,6 +467,24 @@ message DeleteReceiverRequest { uint64 id = 1; } +message SendReceiverNotificationRequest{ + uint64 id = 1; + message SlackPayload { + string message = 1; + string receiver_name = 2 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; + string receiver_type = 3 [(validate.rules).string = {in: ["channel", "user"]}]; + repeated google.protobuf.Struct blocks = 4; + } + + oneof data { + SlackPayload slack = 2; + } +} + +message SendReceiverNotificationResponse { + bool ok = 1; +} + message ListAlertsRequest { string provider_name = 1 [(validate.rules).string = {in: ["cortex"]}]; uint64 provider_id = 2; @@ -530,77 +531,26 @@ message Labels { string severity = 1; } -message SlackWorkspace { - string id = 1; +message Rule { + uint64 id = 1; string name = 2; + bool enabled = 3; + string group_name = 4; + string namespace = 5; + string template = 6; + repeated Variables variables = 7; + google.protobuf.Timestamp created_at = 8; + google.protobuf.Timestamp updated_at = 9; + uint64 provider_namespace = 10 [(validate.rules).uint64.gte = 0];; } -message ListWorkspaceChannelsRequest { - string workspace_name = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; -} - -message ListWorkspaceChannelsResponse { - repeated SlackWorkspace data = 1; -} - -message ExchangeCodeRequest { - string code = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9._-]+$"]; - string workspace = 2 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; -} - -message ExchangeCodeResponse { - bool ok = 1; -} - -message GetAlertCredentialsRequest{ - string team_name = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; -} - -message Critical { - string channel = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; -} - -message Warning { - string channel = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; -} - -message SlackConfig { - Critical critical = 1 [(validate.rules).message.required = true]; - Warning warning = 2 [(validate.rules).message.required = true]; -} - -message GetAlertCredentialsResponse { - string entity = 1; - string team_name = 2; - string pagerduty_credentials = 3; - SlackConfig slack_config = 4; -} - -message UpdateAlertCredentialsRequest { - string entity = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; - string team_name = 2; - string pagerduty_credentials = 3 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; - SlackConfig slack_config = 4 [(validate.rules).message.required = true]; -} -message UpdateAlertCredentialsResponse{} - -message SendReceiverNotificationRequest{ - uint64 id = 1; - message SlackPayload { - string message = 1; - string receiver_name = 2 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; - string receiver_type = 3 [(validate.rules).string = {in: ["channel", "user"]}]; - repeated google.protobuf.Struct blocks = 4; - } - - oneof data { - SlackPayload slack = 2; - } +message Variables { + string name = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; + string value = 2 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; + string type = 3; + string description = 4; } -message SendReceiverNotificationResponse { - bool ok = 1; -} message ListRulesRequest { string name = 1; @@ -610,26 +560,6 @@ message ListRulesRequest { uint64 provider_namespace = 5; } -message Variables { - string name = 1 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; - string value = 2 [(validate.rules).string.pattern = "^[A-Za-z0-9_-]+$"]; - string type = 3; - string description = 4; -} - -message Rule { - uint64 id = 1; - string name = 2; - bool enabled = 3; - string group_name = 4; - string namespace = 5; - string template = 6; - repeated Variables variables = 7; - google.protobuf.Timestamp created_at = 8; - google.protobuf.Timestamp updated_at = 9; - uint64 provider_namespace = 10 [(validate.rules).uint64.gte = 0];; -} - message ListRulesResponse { repeated Rule rules = 1; }