From 81dd2c4afb98821b4c5a4a281bdea41370f5c4ea Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Mon, 2 Sep 2024 09:55:21 +0200 Subject: [PATCH 1/8] annotate service --- com/coralogix/openapi/v1/annotations.proto | 158 ++++++++++++++++++ .../alerts/v3/alert_defs_service.proto | 7 + 2 files changed, 165 insertions(+) create mode 100644 com/coralogix/openapi/v1/annotations.proto diff --git a/com/coralogix/openapi/v1/annotations.proto b/com/coralogix/openapi/v1/annotations.proto new file mode 100644 index 0000000..b415c37 --- /dev/null +++ b/com/coralogix/openapi/v1/annotations.proto @@ -0,0 +1,158 @@ +syntax = "proto3"; + +package com.coralogix.openapi.v1; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/wrappers.proto"; + +// ServiceOpenAPI is a message used to annotate gRPC services with additional +// OpenAPI-specific metadata. This includes service description, version, and +// and error model full qualified name. +message ServiceOpenAPI { + string description = 1; // Description of the service. (deprecated) + string version = 2; // Version of the service. + string error_model = 3; // Full qualified name of error model used by the service (defaults to com.coralogix.openapi.ApiError). + string resource_name = 4; // Name of the resource used in openapi spec. (deprecated) + string name = 5; // Name of the service used in openapi spec. +} + +// Extending google.protobuf.ServiceOptions to include ServiceOpenAPI annotations. +// This allows attaching the ServiceOpenAPI metadata to gRPC service definitions. +extend google.protobuf.ServiceOptions { + ServiceOpenAPI service = 99999; +} + +// MethodOpenAPI is a message used to annotate gRPC methods with additional +// OpenAPI-specific metadata. This includes whether the method operates on a REST resource, +// its description, request schema, error responses, and the index of the HTTP rule where endpoints is defined. +message MethodOpenAPI { + bool resource = 1; // Indicates if the method operates on a REST resource. + string description = 3; // Description of the method. + string request_schema = 4; // Schema of the request message. (Used when you want to use different schema than the one that will be generated from method request mesage type). + string response_schema = 5; // Schema of the response message. (Used when you want to use different schema than the one that will be generated from method response mesage type). + map error_responses = 6; // Map of error response codes to descriptions. + uint32 http_rule_index = 7; // Index of the associated HTTP rule. + string path_parameter_name = 8; // Name of the path parameter used in openapi spec. + map extensions = 9; // Map of extensions. Value is a free-form property to include a JSON of this field. This is copied to generated schema. Quotes must be escaped. + bool datasource = 10; // Indicates if the method is a datasource. + string request_body_example = 11; // A free-form property to include a JSON example of the request body. This is copied to generated schema. Quotes must be escaped. + string response_body_example = 12; // A free-form property to include a JSON example of the response body. This is copied to generated schema. Quotes must be escaped. + string name = 13; // Name of the method used in openapi spec. +} + +// Extending google.protobuf.MethodOptions to include MethodOpenAPI annotations. +// This allows attaching the MethodOpenAPI metadata to gRPC method definitions. +extend google.protobuf.MethodOptions { + MethodOpenAPI method = 99999; +} + +// MessageOpenAPI is a message used to annotate gRPC message types with additional +// OpenAPI-specific metadata, such as description and whether the message is a REST resource. +message MessageOpenAPI { + string name = 1; // Name of the message. + string description = 2; // Description of the message. + bool resource = 3; // Indicates if the message is a REST resource. + map extensions = 4; // Map of extensions. Value is a free-form property to include a JSON of this field. This is copied to generated schema. Quotes must be escaped. +} + +// Extending google.protobuf.MessageOptions to include MessageOpenAPI annotations. +// This allows attaching the MessageOpenAPI metadata to gRPC message definitions. +extend google.protobuf.MessageOptions { + MessageOpenAPI message = 99999; +} + +// EnumOpenAPI is a message used to annotate gRPC enum types with additional OpenAPI-specific metadata. +message EnumOpenAPI { + string name = 1; // Name of the enum. + string description = 2; // Description of the enum. + map extensions = 3; // Map of extensions. Value is a free-form property to include a JSON of this field. This is copied to generated schema. Quotes must be escaped. + +} + +// Extending google.protobuf.EnumOptions to include EnumOpenAPI annotations. +// This allows attaching the EnumOpenAPI metadata to gRPC enum definitions. +extend google.protobuf.EnumOptions { + EnumOpenAPI enum = 99999; +} + +// EnumValueOpenAPI is a message used to annotate enum values with additional OpenAPI-specific metadata. +message EnumValueOpenAPI { + repeated Cloud skip_in = 1; // List of clouds to skip this enum value in. +} + +// Extending google.protobuf.EnumValueOptions to include EnumValueOpenAPI annotations. +// This allows attaching the EnumValueOpenAPI metadata to enum value definitions. +extend google.protobuf.EnumValueOptions { + EnumValueOpenAPI enum_value = 99999; +} + +// FieldOpenAPI is a message used to annotate fields within gRPC message types +// with additional OpenAPI-specific metadata. This includes field descriptions, +// examples, validation patterns, length constraints, and other properties. +message FieldOpenAPI { + string name = 1; // Used for renaming field in OpenAPI schema. + string description = 2; // Description of the field. Defaults to the field name. + string example = 3; // A free-form property to include a JSON example of this field. This is copied to generated schema. Quotes must be escaped. + string pattern = 4; // Regex pattern the field value should match. + int32 min_length = 5; // Minimum length for string fields. Defaults to 1. + int32 max_length = 6; // Maximum length for string fields. Defaults to 4096. + int32 min_items = 7; // Minimum number of items for repeated fields. Defaults to 1. + int32 max_items = 8; // Maximum number of items for repeated fields. Defaults to 4096. + bool required = 9; // Indicates if the field is required. + bool identifier = 10; // Indicates if the field is an identifier. + string format = 11; // Format of the field. + repeated Cloud skip_in = 12; // List of clouds to skip this field in. +} + +// Extending google.protobuf.FieldOptions to include FieldOpenAPI annotations. +// This allows attaching the FieldOpenAPI metadata to field definitions within gRPC messages. +extend google.protobuf.FieldOptions { + FieldOpenAPI field = 99999; +} + +enum Cloud { + CLOUD_UNSPECIFIED = 0; + CLOUD_IBM = 1; + CLOUD_AWS = 2; + CLOUD_AZURE = 3; + CLOUD_GCP = 4; +} + +// ApiError is a message representing a standardized error response format. +// It contains a list of individual errors, a trace identifier, and a status code. +message ApiError { + // Nested message Error representing a single error occurrence. + message Error { + // Enum ErorCode defining possible error codes. + enum ErrorCode { + ERROR_CODE_BAD_REQUEST_OR_UNSPECIFIED = 0; + ERROR_CODE_UNAUTHORIZED = 1; + ERROR_CODE_FORBIDDEN = 2; + ERROR_CODE_NOT_FOUND = 3; + ERROR_CODE_METHOD_INTERNAL_ERROR = 4; + ERROR_CODE_CONFLICT = 5; + ERROR_CODE_UNAUTHENTICATED = 6; + ERROR_CODE_RESOURCE_EXHAUSTED = 7; + ERROR_CODE_DEADLINE_EXCEEDED = 8; + } + // Error code + ErrorCode code = 1 [(com.coralogix.openapi.v1.field) = { required: true } ]; + // Human-readable error message + google.protobuf.StringValue message = 2 [(com.coralogix.openapi.v1.field) = { example: "\"Not found\""} ]; + // Additional information about the error + google.protobuf.StringValue more_info = 3 [(com.coralogix.openapi.v1.field) = { example: "\"View not found\""} ]; + } + // List of errors + repeated Error errors = 1 [(com.coralogix.openapi.v1.field) = { required: true, min_length: 1 } ]; + // UUID uniquely identifying the request + google.protobuf.StringValue trace = 2 [(com.coralogix.openapi.v1.field) = { + required: true, + format : "uuid", + min_length : 36, + max_length : 36, + pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", + example: "\"3dc02998-0b50-4ea8-b68a-4779d716fa1f\"", + }]; + // HTTP status code associated with the error + google.protobuf.Int32Value status_code = 3 [(com.coralogix.openapi.v1.field) = { example: "404"}]; +} \ No newline at end of file diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index 44cf01a..81f01b0 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -8,6 +8,7 @@ import "google/protobuf/wrappers.proto"; import "google/protobuf/timestamp.proto"; import "com/coralogixapis/alerts/v3/alert_def.proto"; import "com/coralogixapis/alerts/v3/alert_def_type.proto"; +import "com/coralogix/openapi/v1/annotations.proto"; message AuditLogDescription { optional string description = 1; @@ -17,7 +18,13 @@ extend google.protobuf.MethodOptions { optional AuditLogDescription audit_log_description = 5000; } +// API to manage alert definitions service AlertDefsService { + option (com.coralogix.openapi.v1.service) = { + version: "v2" + name: "Alerts" + }; + // Get Alert Def by non changing ID AKA UniqueIdentifier rpc GetAlertDef(GetAlertDefRequest) returns (GetAlertDefResponse) { option (audit_log_description).description = "get alert definition"; From fa8ddbb1d87e6cd6ba4c74370a8f5f6fd8b3db0a Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Mon, 2 Sep 2024 10:16:19 +0200 Subject: [PATCH 2/8] annotate first method --- com/coralogix/openapi/v1/annotations.proto | 2 +- com/coralogixapis/alerts/v3/alert_defs_service.proto | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/com/coralogix/openapi/v1/annotations.proto b/com/coralogix/openapi/v1/annotations.proto index b415c37..1081310 100644 --- a/com/coralogix/openapi/v1/annotations.proto +++ b/com/coralogix/openapi/v1/annotations.proto @@ -27,7 +27,7 @@ extend google.protobuf.ServiceOptions { // its description, request schema, error responses, and the index of the HTTP rule where endpoints is defined. message MethodOpenAPI { bool resource = 1; // Indicates if the method operates on a REST resource. - string description = 3; // Description of the method. + string description = 3; // Description of the method. (Deprecated) string request_schema = 4; // Schema of the request message. (Used when you want to use different schema than the one that will be generated from method request mesage type). string response_schema = 5; // Schema of the response message. (Used when you want to use different schema than the one that will be generated from method response mesage type). map error_responses = 6; // Map of error response codes to descriptions. diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index 81f01b0..666751c 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -29,8 +29,13 @@ service AlertDefsService { rpc GetAlertDef(GetAlertDefRequest) returns (GetAlertDefResponse) { option (audit_log_description).description = "get alert definition"; option (google.api.http) = { - get: "/v3/alert-defs/{id}" + get: "/v2/alerts/{id}" + response_body: "alert_def" }; + option (com.coralogix.openapi.v1.method) = { + resource: true + }; + } rpc CreateAlertDef(CreateAlertDefRequest) returns (CreateAlertDefResponse){ @@ -123,6 +128,7 @@ message OrderBy { message GetAlertDefRequest { google.protobuf.StringValue id = 1; // The Alert's non changing ID + OrderByFields field_name = 1; } message GetAlertDefResponse { From 3882210a3c5a4b099f2727dd44a7321f67e0efa8 Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Mon, 2 Sep 2024 10:18:25 +0200 Subject: [PATCH 3/8] annotate first method --- com/coralogixapis/alerts/v3/alert_defs_service.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index 666751c..c07531d 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -128,7 +128,6 @@ message OrderBy { message GetAlertDefRequest { google.protobuf.StringValue id = 1; // The Alert's non changing ID - OrderByFields field_name = 1; } message GetAlertDefResponse { From a7da258f40da9d482d9220c1c95c45aa201776df Mon Sep 17 00:00:00 2001 From: Luigi Taglialatela Date: Mon, 2 Sep 2024 16:46:04 +0200 Subject: [PATCH 4/8] Add remaining alerts v3 endpoints --- .../alerts/v3/alert_defs_service.proto | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index c07531d..18c0c63 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -25,7 +25,7 @@ service AlertDefsService { name: "Alerts" }; - // Get Alert Def by non changing ID AKA UniqueIdentifier + // Get Alert Definition by non changing ID AKA UniqueIdentifier rpc GetAlertDef(GetAlertDefRequest) returns (GetAlertDefResponse) { option (audit_log_description).description = "get alert definition"; option (google.api.http) = { @@ -38,19 +38,29 @@ service AlertDefsService { } + // Create Alert Definition rpc CreateAlertDef(CreateAlertDefRequest) returns (CreateAlertDefResponse){ option (audit_log_description).description = "create alert definition"; option (google.api.http) = { - post: "/v3/alert-defs" - body: "alertDef" + post: "/v2/alerts" + body: "alert_def" + response_body: "alert_def" + }; + option (com.coralogix.openapi.v1.method) = { + resource: true }; } + // Replace Alert Definition by ID AKA UniqueIdentifier rpc ReplaceAlertDef(ReplaceAlertDefRequest) returns (ReplaceAlertDefResponse){ option (audit_log_description).description = "replace alert definition"; option (google.api.http) = { - put: "/v3/alert-defs" - body: "alertDef" + put: "/v2/alerts" + body: "alert_def" + response_body: "alert_def" + }; + option (com.coralogix.openapi.v1.method) = { + resource: true }; } @@ -60,19 +70,27 @@ service AlertDefsService { // get: "/v3/alertDefs:batchGet" // }; // } - + + // List all Alert Defitions rpc ListAlertDefs(ListAlertDefsRequest) returns (ListAlertDefsResponse){ option (audit_log_description).description = "get alert definitions list"; option (google.api.http) = { - get: "/v3/alert-defs" + get: "/v2/alerts" body: "*" }; + option (com.coralogix.openapi.v1.method) = { + resource: true + }; } + // Delete Alert Definition by ID AKA UniqueIdentifier rpc DeleteAlertDef(DeleteAlertDefRequest) returns (DeleteAlertDefResponse){ option (audit_log_description).description = "delete alert definitions"; option (google.api.http) = { - delete: "/v3/alert-defs/{id}" + delete: "/v2/alerts/{id}" + }; + option (com.coralogix.openapi.v1.method) = { + resource: true }; } @@ -100,10 +118,14 @@ service AlertDefsService { // }; // } + // Set Active status of an alert definition rpc SetActive(SetActiveRequest) returns (SetActiveResponse) { option (audit_log_description).description = "disable or enable the alert definitions"; option (google.api.http) = { - post: "/v3/alert-defs/{id}:SetActive" + post: "/v2/alerts/{id}:SetActive" + }; + option (com.coralogix.openapi.v1.method) = { + resource: true }; } } From f7f920809570b1129a1679fdefc1ae07758717ca Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Mon, 16 Sep 2024 11:41:53 +0200 Subject: [PATCH 5/8] adjust projections --- com/coralogixapis/alerts/v3/alert_defs_service.proto | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index 18c0c63..ae5ab2f 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -22,7 +22,7 @@ extend google.protobuf.MethodOptions { service AlertDefsService { option (com.coralogix.openapi.v1.service) = { version: "v2" - name: "Alerts" + name: "V2Alerts" }; // Get Alert Definition by non changing ID AKA UniqueIdentifier @@ -43,7 +43,7 @@ service AlertDefsService { option (audit_log_description).description = "create alert definition"; option (google.api.http) = { post: "/v2/alerts" - body: "alert_def" + body: "alert_def_properties" response_body: "alert_def" }; option (com.coralogix.openapi.v1.method) = { @@ -55,8 +55,8 @@ service AlertDefsService { rpc ReplaceAlertDef(ReplaceAlertDefRequest) returns (ReplaceAlertDefResponse){ option (audit_log_description).description = "replace alert definition"; option (google.api.http) = { - put: "/v2/alerts" - body: "alert_def" + put: "/v2/alerts/{id}" + body: "alert_def_properties" response_body: "alert_def" }; option (com.coralogix.openapi.v1.method) = { @@ -76,7 +76,6 @@ service AlertDefsService { option (audit_log_description).description = "get alert definitions list"; option (google.api.http) = { get: "/v2/alerts" - body: "*" }; option (com.coralogix.openapi.v1.method) = { resource: true From c3498df09858908f93e2fc5e34586d328d82aaa4 Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Tue, 17 Sep 2024 10:25:06 +0200 Subject: [PATCH 6/8] v2 renamings, few required fields --- com/coralogixapis/alerts/v3/alert_def.proto | 28 +++++++++++++++---- .../alerts/v3/alert_defs_service.proto | 8 +++--- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/com/coralogixapis/alerts/v3/alert_def.proto b/com/coralogixapis/alerts/v3/alert_def.proto index 7043dff..dc84f29 100644 --- a/com/coralogixapis/alerts/v3/alert_def.proto +++ b/com/coralogixapis/alerts/v3/alert_def.proto @@ -20,22 +20,40 @@ import "com/coralogixapis/alerts/v3/alert_def_type_definition/tracing/tracing_th import "com/coralogixapis/alerts/v3/alert_def_type_definition/logs/logs_unique_count_type_definition.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; +import "com/coralogix/openapi/v1/annotations.proto"; /** * Represents An Existing or Created Alert Definition */ message AlertDef { - AlertDefProperties alert_def_properties = 1; - google.protobuf.StringValue id = 2; // This is the Alert Definition's Persistent ID (does not change on replace) , AKA UniqueIdentifier - google.protobuf.StringValue alert_version_id = 20; // the old alertId - google.protobuf.Timestamp created_time = 3; - google.protobuf.Timestamp updated_time = 4; + option (com.coralogix.openapi.v1.message) = { + name: "V2Alert" + resource: true + }; + AlertDefProperties alert_def_properties = 1 [(com.coralogix.openapi.v1.field) = { + required: true + }]; + // This is the Alert Definition's Persistent ID (does not change on replace) , AKA UniqueIdentifier + google.protobuf.StringValue id = 2 [(com.coralogix.openapi.v1.field) = { + required: true + }]; + // the old alertId + google.protobuf.StringValue alert_version_id = 20; + google.protobuf.Timestamp created_time = 3 [(com.coralogix.openapi.v1.field) = { + required: true + }]; + google.protobuf.Timestamp updated_time = 4 [(com.coralogix.openapi.v1.field) = { + required: true + }]; } /** * Represents The non generated alert definition properties (the ones that are set by the user) */ message AlertDefProperties { + option (com.coralogix.openapi.v1.message) = { + name: "V2AlertPrototype" + }; google.protobuf.StringValue name = 1; google.protobuf.StringValue description = 2; google.protobuf.BoolValue enabled = 3; diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index ae5ab2f..c1b393c 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -123,9 +123,6 @@ service AlertDefsService { option (google.api.http) = { post: "/v2/alerts/{id}:SetActive" }; - option (com.coralogix.openapi.v1.method) = { - resource: true - }; } } @@ -156,7 +153,10 @@ message GetAlertDefResponse { } message ListAlertDefsResponse { - repeated AlertDef alert_defs = 1; + option (com.coralogix.openapi.v1.message) = { + name: "V2AlertCollection" + }; + repeated AlertDef alert_defs = 1 [ (com.coralogix.openapi.v1.field) = { name: "alerts" } ]; } message ListAlertDefsRequest { From 3821f97a5407cbef40a4972ab949e9753574489e Mon Sep 17 00:00:00 2001 From: Josip Grgurica Date: Mon, 23 Sep 2024 12:47:38 +0200 Subject: [PATCH 7/8] rename to alert defs --- com/coralogixapis/alerts/v3/alert_def.proto | 3 +-- .../alerts/v3/alert_defs_service.proto | 19 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/com/coralogixapis/alerts/v3/alert_def.proto b/com/coralogixapis/alerts/v3/alert_def.proto index dc84f29..bdc3945 100644 --- a/com/coralogixapis/alerts/v3/alert_def.proto +++ b/com/coralogixapis/alerts/v3/alert_def.proto @@ -27,7 +27,6 @@ import "com/coralogix/openapi/v1/annotations.proto"; */ message AlertDef { option (com.coralogix.openapi.v1.message) = { - name: "V2Alert" resource: true }; AlertDefProperties alert_def_properties = 1 [(com.coralogix.openapi.v1.field) = { @@ -52,7 +51,7 @@ message AlertDef { */ message AlertDefProperties { option (com.coralogix.openapi.v1.message) = { - name: "V2AlertPrototype" + name: "AlertDefPrototype" }; google.protobuf.StringValue name = 1; google.protobuf.StringValue description = 2; diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index c1b393c..a02ac6e 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -20,16 +20,11 @@ extend google.protobuf.MethodOptions { // API to manage alert definitions service AlertDefsService { - option (com.coralogix.openapi.v1.service) = { - version: "v2" - name: "V2Alerts" - }; - // Get Alert Definition by non changing ID AKA UniqueIdentifier rpc GetAlertDef(GetAlertDefRequest) returns (GetAlertDefResponse) { option (audit_log_description).description = "get alert definition"; option (google.api.http) = { - get: "/v2/alerts/{id}" + get: "/v1/alert_defs/{id}" response_body: "alert_def" }; option (com.coralogix.openapi.v1.method) = { @@ -42,7 +37,7 @@ service AlertDefsService { rpc CreateAlertDef(CreateAlertDefRequest) returns (CreateAlertDefResponse){ option (audit_log_description).description = "create alert definition"; option (google.api.http) = { - post: "/v2/alerts" + post: "/v1/alert_defs" body: "alert_def_properties" response_body: "alert_def" }; @@ -55,7 +50,7 @@ service AlertDefsService { rpc ReplaceAlertDef(ReplaceAlertDefRequest) returns (ReplaceAlertDefResponse){ option (audit_log_description).description = "replace alert definition"; option (google.api.http) = { - put: "/v2/alerts/{id}" + put: "/v1/alert_defs/{id}" body: "alert_def_properties" response_body: "alert_def" }; @@ -75,7 +70,7 @@ service AlertDefsService { rpc ListAlertDefs(ListAlertDefsRequest) returns (ListAlertDefsResponse){ option (audit_log_description).description = "get alert definitions list"; option (google.api.http) = { - get: "/v2/alerts" + get: "/v1/alert_defs" }; option (com.coralogix.openapi.v1.method) = { resource: true @@ -86,7 +81,7 @@ service AlertDefsService { rpc DeleteAlertDef(DeleteAlertDefRequest) returns (DeleteAlertDefResponse){ option (audit_log_description).description = "delete alert definitions"; option (google.api.http) = { - delete: "/v2/alerts/{id}" + delete: "/v1/alert_defs/{id}" }; option (com.coralogix.openapi.v1.method) = { resource: true @@ -154,9 +149,9 @@ message GetAlertDefResponse { message ListAlertDefsResponse { option (com.coralogix.openapi.v1.message) = { - name: "V2AlertCollection" + name: "AlertDefCollection" }; - repeated AlertDef alert_defs = 1 [ (com.coralogix.openapi.v1.field) = { name: "alerts" } ]; + repeated AlertDef alert_defs = 1 [ (com.coralogix.openapi.v1.field) = { required: true } ]; } message ListAlertDefsRequest { From 5cec74c4c40ec954f988269e59ff7ae7e643cb41 Mon Sep 17 00:00:00 2001 From: Luigi Taglialatela Date: Tue, 24 Sep 2024 15:53:25 +0200 Subject: [PATCH 8/8] Annotate alert_defs service with OpenApi descriptors --- com/coralogixapis/alerts/v3/alert_defs_service.proto | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com/coralogixapis/alerts/v3/alert_defs_service.proto b/com/coralogixapis/alerts/v3/alert_defs_service.proto index a02ac6e..70d5b54 100644 --- a/com/coralogixapis/alerts/v3/alert_defs_service.proto +++ b/com/coralogixapis/alerts/v3/alert_defs_service.proto @@ -20,6 +20,10 @@ extend google.protobuf.MethodOptions { // API to manage alert definitions service AlertDefsService { + option (com.coralogix.openapi.v1.service) = { + name: "Alert Definitions" + resource_name: "AlertDef" + }; // Get Alert Definition by non changing ID AKA UniqueIdentifier rpc GetAlertDef(GetAlertDefRequest) returns (GetAlertDefResponse) { option (audit_log_description).description = "get alert definition";