From 174e36732b911d476ad2a6136a1a94b41484e509 Mon Sep 17 00:00:00 2001 From: rfockema-arista Date: Wed, 19 Jun 2024 13:16:16 +0100 Subject: [PATCH] alert.v1: Add azure oauth for webhook Change-Id: Ibd1b9057ebe3f6d4c484dc264c2ab2db3b062aef --- arista/alert.v1/alert-changelog.yaml | 5 ++ arista/alert.v1/alert.proto | 18 +++++- arista/alert.v1/services.gen.proto | 75 ----------------------- arista/alert.v1/services.gen.swagger.json | 28 ++++++++- 4 files changed, 46 insertions(+), 80 deletions(-) diff --git a/arista/alert.v1/alert-changelog.yaml b/arista/alert.v1/alert-changelog.yaml index 3ce49dff..0aacf943 100644 --- a/arista/alert.v1/alert-changelog.yaml +++ b/arista/alert.v1/alert-changelog.yaml @@ -7,6 +7,11 @@ # New entries go on top. Changes: + - date: 2024-06-17 + description: Add Azure OAuth settings for webhook + version: 1.10.0 + onprem: true + cvaas: true - date: 2024-06-12 description: Update Rule struct with debouncing field version: 1.9.1 diff --git a/arista/alert.v1/alert.proto b/arista/alert.v1/alert.proto index df735798..7d33663f 100644 --- a/arista/alert.v1/alert.proto +++ b/arista/alert.v1/alert.proto @@ -183,6 +183,8 @@ message Settings { google.protobuf.BoolValue hide_tags = 18; // zoom is the global default settings for zoom ZoomSettings zoom = 19; + // webhook is the auth settings for webhook + WebhookSettings webhook = 20; } @@ -203,7 +205,7 @@ message EmailSettings { // notification, the email will only have a single notification, the format will also be different google.protobuf.BoolValue single_alert_per_email = 6; // azure_o_auth used for auth when using an Azure smtp server - // uses auth_username + // uses auth_username, scopes is not required as we use https://outlook.office365.com/.default AzureOAuth azure_o_auth = 7; } @@ -216,7 +218,11 @@ message AzureOAuth { // client_secret is a user generated secret key used for auth google.protobuf.StringValue client_secret = 3; // auth_uri is the URI used for OAuth + // this should always be https://login.microsoftonline.com/ unless using a very custom + // set up, where the Azure enviroment is not running on microsoft servers google.protobuf.StringValue auth_uri = 4; + // scopes are the scopes that auth is granted for + fmp.RepeatedString scopes = 5; } // HttpSettings are the settings to be used when sending various message over a http connection @@ -290,6 +296,13 @@ message MsTeamsSettings { google.protobuf.StringValue url = 1; } +// WebhookSettings contain the settings for sending alerts to a Webhook +message WebhookSettings { + // azure_o_auth used for auth when using an Azure smtp server + // uses auth_username + AzureOAuth azure_o_auth = 1; +} + // SyslogSettings contain the settings for sending alerts with syslog message SyslogSettings { @@ -795,7 +808,8 @@ message WebhookEndpoint { // single_alert is a boolean flag that will cause an individual webhook message to be sent per // alert when true. google.protobuf.BoolValue single_alert = 5; - // Webhook does not have a settings override + // settings_override is the override for the webhook global endpoint settings + WebhookSettings settings_override = 6; } diff --git a/arista/alert.v1/services.gen.proto b/arista/alert.v1/services.gen.proto index b1096f5e..df789419 100644 --- a/arista/alert.v1/services.gen.proto +++ b/arista/alert.v1/services.gen.proto @@ -87,48 +87,11 @@ message AlertStreamResponse { arista.subscriptions.Operation type = 3; }; -message AlertBatchedStreamRequest { - - // TimeRange allows limiting response data to within a specified time window. - // If this field is populated, at least one of the two time fields are required. - // - // For GetAll, the fields start and end can be used as follows: - // - // * end: Returns the state of each Alert at end. - // * Each Alert response is fully-specified (all fields set). - // * start: Returns the state of each Alert at start, followed by updates until now. - // * Each Alert response at start is fully-specified, but updates may be partial. - // * start and end: Returns the state of each Alert at start, followed by updates - // until end. - // * Each Alert response at start is fully-specified, but updates until end may - // be partial. - // - // This field is not allowed in the Subscribe RPC. - arista.time.TimeBounds time = 3; - - // MaxMessages limits the maximum number of messages that can be contained in one batch. - // MaxMessages is required to be at least 1. - // The maximum number of messages in a batch is min(max_messages, INTERNAL_BATCH_LIMIT) - // INTERNAL_BATCH_LIMIT is set based on the maximum message size. - google.protobuf.UInt32Value max_messages = 4; -}; - -message AlertBatchedStreamResponse { - // Values are the values deemed relevant to the initiating request. - // The length of this structure is guaranteed to be between (inclusive) 1 and - // min(req.max_messages, INTERNAL_BATCH_LIMIT). - repeated AlertStreamResponse responses = 1; -}; - service AlertService { rpc GetOne (AlertRequest) returns (AlertResponse); - rpc GetAll (AlertStreamRequest) returns (stream AlertStreamResponse); rpc Subscribe (AlertStreamRequest) returns (stream AlertStreamResponse); - rpc SubscribeMeta (AlertStreamRequest) returns (stream MetaResponse); - rpc GetAllBatched (AlertBatchedStreamRequest) returns (stream AlertBatchedStreamResponse); - rpc SubscribeBatched (AlertBatchedStreamRequest) returns (stream AlertBatchedStreamResponse); } message AlertConfigRequest { @@ -186,39 +149,6 @@ message AlertConfigStreamResponse { arista.subscriptions.Operation type = 3; }; -message AlertConfigBatchedStreamRequest { - - // TimeRange allows limiting response data to within a specified time window. - // If this field is populated, at least one of the two time fields are required. - // - // For GetAll, the fields start and end can be used as follows: - // - // * end: Returns the state of each AlertConfig at end. - // * Each AlertConfig response is fully-specified (all fields set). - // * start: Returns the state of each AlertConfig at start, followed by updates until now. - // * Each AlertConfig response at start is fully-specified, but updates may be partial. - // * start and end: Returns the state of each AlertConfig at start, followed by updates - // until end. - // * Each AlertConfig response at start is fully-specified, but updates until end may - // be partial. - // - // This field is not allowed in the Subscribe RPC. - arista.time.TimeBounds time = 3; - - // MaxMessages limits the maximum number of messages that can be contained in one batch. - // MaxMessages is required to be at least 1. - // The maximum number of messages in a batch is min(max_messages, INTERNAL_BATCH_LIMIT) - // INTERNAL_BATCH_LIMIT is set based on the maximum message size. - google.protobuf.UInt32Value max_messages = 4; -}; - -message AlertConfigBatchedStreamResponse { - // Values are the values deemed relevant to the initiating request. - // The length of this structure is guaranteed to be between (inclusive) 1 and - // min(req.max_messages, INTERNAL_BATCH_LIMIT). - repeated AlertConfigStreamResponse responses = 1; -}; - message AlertConfigSetRequest { // AlertConfig carries the value to set into the datastore. // See the documentation on the AlertConfig struct for which fields are required. @@ -241,16 +171,11 @@ message AlertConfigSetResponse { service AlertConfigService { rpc GetOne (AlertConfigRequest) returns (AlertConfigResponse); - rpc GetAll (AlertConfigStreamRequest) returns (stream AlertConfigStreamResponse); rpc Subscribe (AlertConfigStreamRequest) returns (stream AlertConfigStreamResponse); - rpc SubscribeMeta (AlertConfigStreamRequest) returns (stream MetaResponse); rpc Set (AlertConfigSetRequest) returns (AlertConfigSetResponse); - - rpc GetAllBatched (AlertConfigBatchedStreamRequest) returns (stream AlertConfigBatchedStreamResponse); - rpc SubscribeBatched (AlertConfigBatchedStreamRequest) returns (stream AlertConfigBatchedStreamResponse); } message DefaultTemplateRequest { diff --git a/arista/alert.v1/services.gen.swagger.json b/arista/alert.v1/services.gen.swagger.json index 4b791fe0..ec201450 100644 --- a/arista/alert.v1/services.gen.swagger.json +++ b/arista/alert.v1/services.gen.swagger.json @@ -1505,7 +1505,11 @@ }, "authUri": { "type": "string", - "title": "auth_uri is the URI used for OAuth" + "title": "auth_uri is the URI used for OAuth\nthis should always be https://login.microsoftonline.com/ unless using a very custom\nset up, where the Azure enviroment is not running on microsoft servers" + }, + "scopes": { + "$ref": "#/definitions/fmp.RepeatedString", + "title": "scopes are the scopes that auth is granted for" } }, "title": "AzureOAuth contains the settings for the sending of emails on Azure smtp server" @@ -2065,7 +2069,7 @@ }, "azureOAuth": { "$ref": "#/definitions/arista.alert.v1.AzureOAuth", - "title": "azure_o_auth used for auth when using an Azure smtp server\nuses auth_username" + "title": "azure_o_auth used for auth when using an Azure smtp server\nuses auth_username, scopes is not required as we use https://outlook.office365.com/.default" } }, "title": "EmailSettings contain the settings for the sending of emails" @@ -2790,6 +2794,10 @@ "zoom": { "$ref": "#/definitions/arista.alert.v1.ZoomSettings", "title": "zoom is the global default settings for zoom" + }, + "webhook": { + "$ref": "#/definitions/arista.alert.v1.WebhookSettings", + "title": "webhook is the auth settings for webhook" } }, "title": "Settings portion of config, a list of default global settings used by broadcast groups" @@ -3225,7 +3233,11 @@ }, "singleAlert": { "type": "boolean", - "description": "single_alert is a boolean flag that will cause an individual webhook message to be sent per\nalert when true.\n\nWebhook does not have a settings override" + "description": "single_alert is a boolean flag that will cause an individual webhook message to be sent per\nalert when true." + }, + "settingsOverride": { + "$ref": "#/definitions/arista.alert.v1.WebhookSettings", + "title": "settings_override is the override for the webhook global endpoint settings" } }, "title": "WebhookEndpoint contains the required information for an alert to be sent to a webhook endpoint" @@ -3244,6 +3256,16 @@ }, "title": "WebhookEndpoints is a set of webhook endpoints" }, + "arista.alert.v1.WebhookSettings": { + "type": "object", + "properties": { + "azureOAuth": { + "$ref": "#/definitions/arista.alert.v1.AzureOAuth", + "title": "azure_o_auth used for auth when using an Azure smtp server\nuses auth_username" + } + }, + "title": "WebhookSettings contain the settings for sending alerts to a Webhook" + }, "arista.alert.v1.ZoomEndpoint": { "type": "object", "properties": {