From 884e0427e6429d7d4d8d5a9f2f17928326cf7810 Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Wed, 13 Dec 2023 10:55:59 -0500 Subject: [PATCH] ngalert openapi: Add `X-Disable-Provenance` to missing operations (#79278) Swagger(ngalert): Add `X-Disable-Provenance` to missing operations I added all functions that call the `determineProvenance` function Schema changes are from: `make` in `pkg/services/ngalert/api/tooling` `make swagger-clean && make openapi3-gen` in root --- pkg/services/ngalert/api/tooling/api.json | 42 +++++++++++- .../definitions/provisioning_alert_rules.go | 2 +- .../definitions/provisioning_contactpoints.go | 6 ++ .../definitions/provisioning_mute_timings.go | 6 ++ .../definitions/provisioning_policies.go | 6 ++ .../definitions/provisioning_templates.go | 6 ++ pkg/services/ngalert/api/tooling/post.json | 43 ++++++++++++- pkg/services/ngalert/api/tooling/spec.json | 43 ++++++++++++- public/api-merged.json | 42 +++++++++++- public/openapi3.json | 64 ++++++++++++++++++- 10 files changed, 251 insertions(+), 9 deletions(-) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index b6f6055fc1e..0af43588c6f 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -4252,7 +4252,6 @@ "type": "object" }, "alertGroups": { - "description": "AlertGroups alert groups", "items": { "$ref": "#/definitions/alertGroup" }, @@ -4413,7 +4412,6 @@ "type": "object" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, @@ -4898,6 +4896,11 @@ "name": "UID", "required": true, "type": "string" + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5067,6 +5070,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5185,6 +5193,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5246,6 +5259,11 @@ ], "operationId": "RoutePutAlertRuleGroup", "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" + }, { "in": "path", "name": "FolderUID", @@ -5367,6 +5385,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5496,6 +5519,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5611,6 +5639,11 @@ "schema": { "$ref": "#/definitions/Route" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -5744,6 +5777,11 @@ "schema": { "$ref": "#/definitions/NotificationTemplateContent" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go index 8304d178e5c..30233f8cff1 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go @@ -103,7 +103,7 @@ type AlertRulePayload struct { Body ProvisionedAlertRule } -// swagger:parameters RoutePostAlertRule RoutePutAlertRule +// swagger:parameters RoutePostAlertRule RoutePutAlertRule RouteDeleteAlertRule RoutePutAlertRuleGroup type AlertRuleHeaders struct { // in:header XDisableProvenance string `json:"X-Disable-Provenance"` diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go index 2cad1b0f00b..cea1209f0d0 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go @@ -75,6 +75,12 @@ type ContactPointPayload struct { // swagger:model type ContactPoints []EmbeddedContactPoint +// swagger:parameters RoutePostContactpoints RoutePutContactpoint +type ContactPointHeaders struct { + // in:header + XDisableProvenance string `json:"X-Disable-Provenance"` +} + // EmbeddedContactPoint is the contact point type that is used // by grafanas embedded alertmanager implementation. // swagger:model diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go index 77a7444cc9c..739c6e30a05 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go @@ -82,6 +82,12 @@ type MuteTimingPayload struct { Body MuteTimeInterval } +// swagger:parameters RoutePostMuteTiming RoutePutMuteTiming +type MuteTimingHeaders struct { + // in:header + XDisableProvenance string `json:"X-Disable-Provenance"` +} + // swagger:model type MuteTimeInterval struct { config.MuteTimeInterval `json:",inline" yaml:",inline"` diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go index 666e08a7329..9da558cda88 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go @@ -48,6 +48,12 @@ type Policytree struct { Body Route } +// swagger:parameters RoutePutPolicyTree +type PolicyTreeHeaders struct { + // in:header + XDisableProvenance string `json:"X-Disable-Provenance"` +} + // NotificationPolicyExport is the provisioned file export of alerting.NotificiationPolicyV1. type NotificationPolicyExport struct { OrgID int64 `json:"orgId" yaml:"orgId"` diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go index d91c47193b7..6184105bc93 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go @@ -61,6 +61,12 @@ type NotificationTemplatePayload struct { Body NotificationTemplateContent } +// swagger:parameters RoutePutTemplate +type NotificationTemplateHeaders struct { + // in:header + XDisableProvenance string `json:"X-Disable-Provenance"` +} + func (t *NotificationTemplate) ResourceType() string { return "template" } diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index e69fb825d72..f9ddbda7d0f 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -4419,6 +4419,7 @@ "type": "array" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "properties": { "comment": { "description": "comment", @@ -4473,7 +4474,6 @@ "type": "array" }, "integration": { - "description": "Integration integration", "properties": { "lastNotifyAttempt": { "description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time", @@ -4617,6 +4617,7 @@ "type": "array" }, "postableSilence": { + "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", @@ -6875,6 +6876,11 @@ "name": "UID", "required": true, "type": "string" + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7044,6 +7050,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7162,6 +7173,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7223,6 +7239,11 @@ ], "operationId": "RoutePutAlertRuleGroup", "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" + }, { "in": "path", "name": "FolderUID", @@ -7344,6 +7365,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7473,6 +7499,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7588,6 +7619,11 @@ "schema": { "$ref": "#/definitions/Route" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { @@ -7721,6 +7757,11 @@ "schema": { "$ref": "#/definitions/NotificationTemplateContent" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "type": "string" } ], "responses": { diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index 42dc2c56271..b4e2499a8e7 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -2200,6 +2200,11 @@ "name": "UID", "in": "path", "required": true + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2300,6 +2305,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2396,6 +2406,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2484,6 +2499,11 @@ "summary": "Update the interval of a rule group.", "operationId": "RoutePutAlertRuleGroup", "parameters": [ + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" + }, { "type": "string", "name": "FolderUID", @@ -2608,6 +2628,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2719,6 +2744,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2841,6 +2871,11 @@ "schema": { "$ref": "#/definitions/Route" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2976,6 +3011,11 @@ "schema": { "$ref": "#/definitions/NotificationTemplateContent" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -7576,6 +7616,7 @@ "$ref": "#/definitions/gettableAlerts" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "type": "object", "required": [ "comment", @@ -7632,7 +7673,6 @@ "$ref": "#/definitions/gettableSilences" }, "integration": { - "description": "Integration integration", "type": "object", "required": [ "name", @@ -7777,6 +7817,7 @@ } }, "postableSilence": { + "description": "PostableSilence postable silence", "type": "object", "required": [ "comment", diff --git a/public/api-merged.json b/public/api-merged.json index f10021f65a6..3a954af77e3 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -2664,6 +2664,11 @@ "name": "UID", "in": "path", "required": true + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2761,6 +2766,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2855,6 +2865,11 @@ "schema": { "$ref": "#/definitions/EmbeddedContactPoint" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -2940,6 +2955,11 @@ "summary": "Update the interval of a rule group.", "operationId": "RoutePutAlertRuleGroup", "parameters": [ + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" + }, { "type": "string", "name": "FolderUID", @@ -3061,6 +3081,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -3169,6 +3194,11 @@ "schema": { "$ref": "#/definitions/MuteTimeInterval" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -3287,6 +3317,11 @@ "schema": { "$ref": "#/definitions/Route" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -3417,6 +3452,11 @@ "schema": { "$ref": "#/definitions/NotificationTemplateContent" } + }, + { + "type": "string", + "name": "X-Disable-Provenance", + "in": "header" } ], "responses": { @@ -20671,7 +20711,6 @@ } }, "alertGroups": { - "description": "AlertGroups alert groups", "type": "array", "items": { "$ref": "#/definitions/alertGroup" @@ -20860,7 +20899,6 @@ } }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "type": "array", "items": { "$ref": "#/definitions/gettableAlert" diff --git a/public/openapi3.json b/public/openapi3.json index e334c8a4e87..d03c1b4f50e 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -11602,7 +11602,6 @@ "type": "object" }, "alertGroups": { - "description": "AlertGroups alert groups", "items": { "$ref": "#/components/schemas/alertGroup" }, @@ -11791,7 +11790,6 @@ "type": "object" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/components/schemas/gettableAlert" }, @@ -14976,6 +14974,13 @@ "schema": { "type": "string" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } } ], "responses": { @@ -15174,6 +15179,15 @@ }, "post": { "operationId": "RoutePostContactpoints", + "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } + } + ], "requestBody": { "content": { "application/json": { @@ -15315,6 +15329,13 @@ "schema": { "type": "string" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } } ], "requestBody": { @@ -15399,6 +15420,13 @@ "put": { "operationId": "RoutePutAlertRuleGroup", "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } + }, { "in": "path", "name": "FolderUID", @@ -15546,6 +15574,15 @@ }, "post": { "operationId": "RoutePostMuteTiming", + "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } + } + ], "requestBody": { "content": { "application/json": { @@ -15703,6 +15740,13 @@ "schema": { "type": "string" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } } ], "requestBody": { @@ -15844,6 +15888,15 @@ }, "put": { "operationId": "RoutePutPolicyTree", + "parameters": [ + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } + } + ], "requestBody": { "content": { "application/json": { @@ -16006,6 +16059,13 @@ "schema": { "type": "string" } + }, + { + "in": "header", + "name": "X-Disable-Provenance", + "schema": { + "type": "string" + } } ], "requestBody": {