From 17e76b06ff73b0f8a21257fa3793e0a31e252fbf Mon Sep 17 00:00:00 2001 From: Alexander Weaver Date: Mon, 13 Jun 2022 12:51:07 -0500 Subject: [PATCH] Alerting: Fix rendering issues in OpenAPI docs (#50630) * Clean up status codes * Missing consumes tag * Regenerate * Fix incorrect documented responses and missing UI elements * Fix response docs * Fix wrong response copy paste * Regenerate * Temporarily revert --- pkg/services/ngalert/api/tooling/api.json | 868 +++++++++++++++++- .../ngalert/api/tooling/definitions/api.go | 5 - .../definitions/provisioning_alert_rules.go | 7 +- .../definitions/provisioning_contactpoints.go | 14 +- .../definitions/provisioning_mute_timings.go | 7 +- .../definitions/provisioning_policies.go | 3 +- .../definitions/provisioning_templates.go | 16 +- .../ngalert/api/tooling/definitions/shared.go | 6 + pkg/services/ngalert/api/tooling/post.json | 147 ++- pkg/services/ngalert/api/tooling/spec.json | 141 ++- 10 files changed, 985 insertions(+), 229 deletions(-) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index fd722d9ef11..a5ebb64a483 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -194,6 +194,178 @@ "type": "object", "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" }, + "AlertRule": { + "properties": { + "annotations": { + "additionalProperties": { + "type": "string" + }, + "example": { + "runbook_url": "https://supercoolrunbook.com/page/13" + }, + "type": "object", + "x-go-name": "Annotations" + }, + "condition": { + "example": "A", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "example": [ + { + "datasourceUid": "-100", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 0, + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "1 == 1", + "hide": false, + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "A", + "type": "math" + }, + "queryType": "", + "refId": "A", + "relativeTimeRange": { + "from": 0, + "to": 0 + } + } + ], + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "type": "array", + "x-go-name": "Data" + }, + "execErrState": { + "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState", + "enum": [ + "Alerting", + "Error", + "OK" + ], + "type": "string", + "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState", + "x-go-name": "ExecErrState" + }, + "folderUID": { + "example": "project_x", + "type": "string", + "x-go-name": "FolderUID" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "id": { + "format": "int64", + "type": "integer", + "x-go-name": "ID" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "example": { + "team": "sre-team-1" + }, + "type": "object", + "x-go-name": "Labels" + }, + "noDataState": { + "description": "\nAlerting Alerting\nNoData NoData\nOK OK", + "enum": [ + "Alerting", + "NoData", + "OK" + ], + "type": "string", + "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK", + "x-go-name": "NoDataState" + }, + "orgID": { + "format": "int64", + "type": "integer", + "x-go-name": "OrgID" + }, + "provenance": { + "$ref": "#/definitions/Provenance" + }, + "ruleGroup": { + "example": "eval_group_1", + "maxLength": 190, + "minLength": 1, + "type": "string", + "x-go-name": "RuleGroup" + }, + "title": { + "example": "Always firing", + "maxLength": 190, + "minLength": 1, + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "type": "string", + "x-go-name": "UID" + }, + "updated": { + "format": "date-time", + "readOnly": true, + "type": "string", + "x-go-name": "Updated" + } + }, + "required": [ + "orgID", + "folderUID", + "ruleGroup", + "title", + "condition", + "data", + "noDataState", + "execErrState", + "for" + ], + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" + }, + "AlertRuleGroup": { + "properties": { + "interval": { + "format": "int64", + "type": "integer", + "x-go-name": "Interval" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" + }, "AlertingRule": { "description": "adapted from cortex", "properties": { @@ -367,6 +539,13 @@ "type": "object", "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" }, + "ContactPoints": { + "items": { + "$ref": "#/definitions/EmbeddedContactPoint" + }, + "type": "array", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" + }, "CreateDashboardSnapshotCommand": { "properties": { "Result": { @@ -588,15 +767,18 @@ "description": "EmbeddedContactPoint is the contact point type that is used\nby grafanas embedded alertmanager implementation.", "properties": { "disableResolveMessage": { + "example": false, "type": "boolean", "x-go-name": "DisableResolveMessage" }, "name": { "description": "Name is used as grouping key in the UI. Contact points with the\nsame name will be grouped in the UI.", + "example": "webhook_1", "type": "string", "x-go-name": "Name" }, "provenance": { + "readOnly": true, "type": "string", "x-go-name": "Provenance" }, @@ -604,15 +786,41 @@ "$ref": "#/definitions/Json" }, "type": { + "enum": [ + "alertmanager", + " dingding", + " discord", + " email", + " googlechat", + " kafka", + " line", + " opsgenie", + " pagerduty", + " pushover", + " sensugo", + " slack", + " teams", + " telegram", + " threema", + " victorops", + " webhook", + " wecom" + ], + "example": "webhook", "type": "string", "x-go-name": "Type" }, "uid": { - "description": "UID is the unique identifier of the contact point. This will be\nautomatically set be the Grafana.", + "description": "UID is the unique identifier of the contact point. The UID can be\nset by the user.", + "example": "my_external_reference", "type": "string", "x-go-name": "UID" } }, + "required": [ + "type", + "settings" + ], "type": "object", "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" }, @@ -724,6 +932,13 @@ "type": "array", "x-go-name": "InhibitRules" }, + "muteTimeProvenances": { + "additionalProperties": { + "$ref": "#/definitions/Provenance" + }, + "type": "object", + "x-go-name": "MuteTimeProvenances" + }, "mute_time_intervals": { "items": { "$ref": "#/definitions/MuteTimeInterval" @@ -1373,14 +1588,16 @@ }, "MessageTemplate": { "properties": { - "Name": { - "type": "string" - }, - "Template": { - "type": "string" + "name": { + "type": "string", + "x-go-name": "Name" }, "provenance": { "$ref": "#/definitions/Provenance" + }, + "template": { + "type": "string", + "x-go-name": "Template" } }, "type": "object", @@ -1388,8 +1605,9 @@ }, "MessageTemplateContent": { "properties": { - "Template": { - "type": "string" + "template": { + "type": "string", + "x-go-name": "Template" } }, "type": "object", @@ -2923,7 +3141,6 @@ "x-go-package": "github.com/prometheus/alertmanager/timeinterval" }, "URL": { - "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.", "properties": { "ForceQuery": { "type": "boolean" @@ -2956,9 +3173,9 @@ "$ref": "#/definitions/Userinfo" } }, - "title": "A URL represents a parsed URL (technically, a URI reference).", + "title": "URL is a custom URL type that allows validation at configuration load time.", "type": "object", - "x-go-package": "net/url" + "x-go-package": "github.com/prometheus/common/config" }, "Userinfo": { "description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.", @@ -2968,6 +3185,7 @@ "ValidationError": { "properties": { "msg": { + "example": "error message", "type": "string", "x-go-name": "Msg" } @@ -3306,7 +3524,6 @@ "$ref": "#/definitions/Duration" }, "gettableAlert": { - "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" @@ -3365,16 +3582,20 @@ "status", "updatedAt" ], - "type": "object" + "type": "object", + "x-go-name": "GettableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, - "type": "array" + "type": "array", + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "properties": { "comment": { "description": "comment", @@ -3426,17 +3647,14 @@ "status", "updatedAt" ], - "type": "object", - "x-go-name": "GettableSilence", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + "type": "object" }, "gettableSilences": { + "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, - "type": "array", - "x-go-name": "GettableSilences", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + "type": "array" }, "labelSet": { "additionalProperties": { @@ -3565,7 +3783,6 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "postableSilence": { - "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", @@ -3605,10 +3822,11 @@ "matchers", "startsAt" ], - "type": "object" + "type": "object", + "x-go-name": "PostableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "receiver": { - "description": "Receiver receiver", "properties": { "name": { "description": "name", @@ -3619,7 +3837,9 @@ "required": [ "name" ], - "type": "object" + "type": "object", + "x-go-name": "Receiver", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "silence": { "description": "Silence silence", @@ -3732,7 +3952,603 @@ "title": "Grafana Alerting API.", "version": "1.1.0" }, - "paths": {}, + "paths": { + "/api/v1/provisioning/alert-rules": { + "post": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePostAlertRule", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/AlertRule" + } + } + ], + "responses": { + "201": { + "description": "AlertRule", + "schema": { + "$ref": "#/definitions/AlertRule" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Create a new alert rule.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/alert-rules/{UID}": { + "delete": { + "operationId": "RouteDeleteAlertRule", + "parameters": [ + { + "description": "Alert rule UID", + "in": "path", + "name": "UID", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": " The alert rule was deleted successfully." + } + }, + "summary": "Delete a specific alert rule by UID.", + "tags": [ + "provisioning" + ] + }, + "get": { + "operationId": "RouteGetAlertRule", + "parameters": [ + { + "description": "Alert rule UID", + "in": "path", + "name": "UID", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "AlertRule", + "schema": { + "$ref": "#/definitions/AlertRule" + } + }, + "404": { + "description": " Not found." + } + }, + "summary": "Get a specific alert rule by UID.", + "tags": [ + "provisioning" + ] + }, + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutAlertRule", + "parameters": [ + { + "description": "Alert rule UID", + "in": "path", + "name": "UID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/AlertRule" + } + } + ], + "responses": { + "200": { + "description": "AlertRule", + "schema": { + "$ref": "#/definitions/AlertRule" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Update an existing alert rule.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/contact-points": { + "get": { + "operationId": "RouteGetContactpoints", + "responses": { + "200": { + "description": "ContactPoints", + "schema": { + "$ref": "#/definitions/ContactPoints" + } + } + }, + "summary": "Get all the contact points.", + "tags": [ + "provisioning" + ] + }, + "post": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePostContactpoints", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/EmbeddedContactPoint" + } + } + ], + "responses": { + "202": { + "description": "EmbeddedContactPoint", + "schema": { + "$ref": "#/definitions/EmbeddedContactPoint" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Create a contact point.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/contact-points/{UID}": { + "delete": { + "consumes": [ + "application/json" + ], + "operationId": "RouteDeleteContactpoints", + "parameters": [ + { + "description": "UID is the contact point unique identifier", + "in": "path", + "name": "UID", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": " The contact point was deleted successfully." + } + }, + "summary": "Delete a contact point.", + "tags": [ + "provisioning" + ] + }, + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutContactpoint", + "parameters": [ + { + "description": "UID is the contact point unique identifier", + "in": "path", + "name": "UID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/EmbeddedContactPoint" + } + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Update an existing contact point.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}": { + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutAlertRuleGroup", + "parameters": [ + { + "in": "path", + "name": "FolderUID", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "Group", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } + } + ], + "responses": { + "200": { + "description": "AlertRuleGroup", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Update the interval of a rule group.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/mute-timings": { + "get": { + "operationId": "RouteGetMuteTimings", + "responses": { + "200": { + "description": "MuteTimings", + "schema": { + "$ref": "#/definitions/MuteTimings" + } + } + }, + "summary": "Get all the mute timings.", + "tags": [ + "provisioning" + ] + }, + "post": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePostMuteTiming", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/MuteTimeInterval" + } + } + ], + "responses": { + "201": { + "description": "MuteTimeInterval", + "schema": { + "$ref": "#/definitions/MuteTimeInterval" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Create a new mute timing.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/mute-timings/{name}": { + "delete": { + "operationId": "RouteDeleteMuteTiming", + "parameters": [ + { + "description": "Mute timing name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + } + ], + "responses": { + "204": { + "description": " The mute timing was deleted successfully." + } + }, + "summary": "Delete a mute timing.", + "tags": [ + "provisioning" + ] + }, + "get": { + "operationId": "RouteGetMuteTiming", + "parameters": [ + { + "description": "Mute timing name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + } + ], + "responses": { + "200": { + "description": "MuteTimeInterval", + "schema": { + "$ref": "#/definitions/MuteTimeInterval" + } + }, + "404": { + "description": " Not found." + } + }, + "summary": "Get a mute timing.", + "tags": [ + "provisioning" + ] + }, + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutMuteTiming", + "parameters": [ + { + "description": "Mute timing name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/MuteTimeInterval" + } + } + ], + "responses": { + "200": { + "description": "MuteTimeInterval", + "schema": { + "$ref": "#/definitions/MuteTimeInterval" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Replace an existing mute timing.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/policies": { + "get": { + "operationId": "RouteGetPolicyTree", + "responses": { + "200": { + "description": "Route", + "schema": { + "$ref": "#/definitions/Route" + } + } + }, + "summary": "Get the notification policy tree.", + "tags": [ + "provisioning" + ] + }, + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutPolicyTree", + "parameters": [ + { + "description": "The new notification routing tree to use", + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/Route" + } + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Sets the notification policy tree.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/templates": { + "get": { + "operationId": "RouteGetTemplates", + "responses": { + "200": { + "description": "MessageTemplates", + "schema": { + "$ref": "#/definitions/MessageTemplates" + } + }, + "404": { + "description": " Not found." + } + }, + "summary": "Get all message templates.", + "tags": [ + "provisioning" + ] + } + }, + "/api/v1/provisioning/templates/{name}": { + "delete": { + "operationId": "RouteDeleteTemplate", + "parameters": [ + { + "description": "Template Name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + } + ], + "responses": { + "204": { + "description": " The template was deleted successfully." + } + }, + "summary": "Delete a template.", + "tags": [ + "provisioning" + ] + }, + "get": { + "operationId": "RouteGetTemplate", + "parameters": [ + { + "description": "Template Name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + } + ], + "responses": { + "200": { + "description": "MessageTemplate", + "schema": { + "$ref": "#/definitions/MessageTemplate" + } + }, + "404": { + "description": " Not found." + } + }, + "summary": "Get a message template.", + "tags": [ + "provisioning" + ] + }, + "put": { + "consumes": [ + "application/json" + ], + "operationId": "RoutePutTemplate", + "parameters": [ + { + "description": "Template Name", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "x-go-name": "Name" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/MessageTemplateContent" + } + } + ], + "responses": { + "202": { + "description": "MessageTemplate", + "schema": { + "$ref": "#/definitions/MessageTemplate" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "summary": "Updates an existing template.", + "tags": [ + "provisioning" + ] + } + } + }, "produces": [ "application/json" ], diff --git a/pkg/services/ngalert/api/tooling/definitions/api.go b/pkg/services/ngalert/api/tooling/definitions/api.go index c865234b92d..29050cf9d2d 100644 --- a/pkg/services/ngalert/api/tooling/definitions/api.go +++ b/pkg/services/ngalert/api/tooling/definitions/api.go @@ -24,11 +24,6 @@ // swagger:meta package definitions -// swagger:model -type ValidationError struct { - Msg string `json:"msg"` -} - type Backend int const ( 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 39a09f22321..44a7df7491e 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go @@ -12,12 +12,15 @@ import ( // // Responses: // 200: AlertRule -// 400: ValidationError +// 404: description: Not found. // swagger:route POST /api/v1/provisioning/alert-rules provisioning stable RoutePostAlertRule // // Create a new alert rule. // +// Consumes: +// - application/json +// // Responses: // 201: AlertRule // 400: ValidationError @@ -39,10 +42,10 @@ import ( // // Responses: // 204: description: The alert rule was deleted successfully. -// 400: ValidationError // swagger:parameters RouteGetAlertRule RoutePutAlertRule RouteDeleteAlertRule type AlertRuleUIDReference struct { + // Alert rule UID // in:path UID string } diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go index 9d35fca6094..08245794a3f 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go @@ -12,8 +12,7 @@ import ( // Get all the contact points. // // Responses: -// 200: Route -// 400: ValidationError +// 200: ContactPoints // swagger:route POST /api/v1/provisioning/contact-points provisioning stable RoutePostContactpoints // @@ -23,7 +22,7 @@ import ( // - application/json // // Responses: -// 202: Ack +// 202: EmbeddedContactPoint // 400: ValidationError // swagger:route PUT /api/v1/provisioning/contact-points/{UID} provisioning stable RoutePutContactpoint @@ -45,12 +44,11 @@ import ( // - application/json // // Responses: -// 202: Ack -// 400: ValidationError +// 204: description: The contact point was deleted successfully. // swagger:parameters RoutePutContactpoint RouteDeleteContactpoints type ContactPointUIDReference struct { - // UID should be the contact point unique identifier + // UID is the contact point unique identifier // in:path UID string } @@ -61,8 +59,12 @@ type ContactPointPayload struct { Body EmbeddedContactPoint } +// swagger:model +type ContactPoints []EmbeddedContactPoint + // EmbeddedContactPoint is the contact point type that is used // by grafanas embedded alertmanager implementation. +// swagger:model type EmbeddedContactPoint struct { // UID is the unique identifier of the contact point. The UID can be // set by the user. 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 72ad6efca88..b1466d8991e 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go @@ -11,7 +11,6 @@ import ( // // Responses: // 200: MuteTimings -// 400: ValidationError // swagger:route GET /api/v1/provisioning/mute-timings/{name} provisioning stable RouteGetMuteTiming // @@ -19,7 +18,7 @@ import ( // // Responses: // 200: MuteTimeInterval -// 400: ValidationError +// 404: description: Not found. // swagger:route POST /api/v1/provisioning/mute-timings provisioning stable RoutePostMuteTiming // @@ -48,7 +47,7 @@ import ( // Delete a mute timing. // // Responses: -// 204: Ack +// 204: description: The mute timing was deleted successfully. // swagger:route @@ -57,7 +56,7 @@ type MuteTimings []MuteTimeInterval // swagger:parameters RouteGetTemplate RouteGetMuteTiming RoutePutMuteTiming stable RouteDeleteMuteTiming type RouteGetMuteTimingParam struct { - // Template Name + // Mute timing name // in:path Name string `json:"name"` } diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go index c6d21784b09..e1f0f48859a 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go @@ -6,7 +6,7 @@ package definitions // // Responses: // 200: Route -// 400: ValidationError +// description: The currently active notification routing tree // swagger:route PUT /api/v1/provisioning/policies provisioning stable RoutePutPolicyTree // @@ -21,6 +21,7 @@ package definitions // swagger:parameters RoutePutPolicyTree type Policytree struct { + // The new notification routing tree to use // in:body Body Route } diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go index fcbc2d80203..21b60fde480 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go @@ -9,8 +9,8 @@ import ( // Get all message templates. // // Responses: -// 200: MessageTemplate -// 400: ValidationError +// 200: MessageTemplates +// 404: description: Not found. // swagger:route GET /api/v1/provisioning/templates/{name} provisioning stable RouteGetTemplate // @@ -18,7 +18,7 @@ import ( // // Responses: // 200: MessageTemplate -// 404: NotFound +// 404: description: Not found. // swagger:route PUT /api/v1/provisioning/templates/{name} provisioning stable RoutePutTemplate // @@ -28,7 +28,7 @@ import ( // - application/json // // Responses: -// 202: Ack +// 202: MessageTemplate // 400: ValidationError // swagger:route DELETE /api/v1/provisioning/templates/{name} provisioning stable RouteDeleteTemplate @@ -36,7 +36,7 @@ import ( // Delete a template. // // Responses: -// 204: Ack +// 204: description: The template was deleted successfully. // swagger:parameters RouteGetTemplate RoutePutTemplate RouteDeleteTemplate type RouteGetTemplateParam struct { @@ -47,8 +47,8 @@ type RouteGetTemplateParam struct { // swagger:model type MessageTemplate struct { - Name string - Template string + Name string `json:"name"` + Template string `json:"template"` Provenance models.Provenance `json:"provenance,omitempty"` } @@ -56,7 +56,7 @@ type MessageTemplate struct { type MessageTemplates []MessageTemplate type MessageTemplateContent struct { - Template string + Template string `json:"template"` } // swagger:parameters RoutePutTemplate diff --git a/pkg/services/ngalert/api/tooling/definitions/shared.go b/pkg/services/ngalert/api/tooling/definitions/shared.go index 1b2677311d3..9c15a2b8efb 100644 --- a/pkg/services/ngalert/api/tooling/definitions/shared.go +++ b/pkg/services/ngalert/api/tooling/definitions/shared.go @@ -5,3 +5,9 @@ type NotFound struct{} // swagger:model type Ack struct{} + +// swagger:model +type ValidationError struct { + // example: error message + Msg string `json:"msg"` +} diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index 779cf127d35..d539a8486db 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -539,6 +539,13 @@ "type": "object", "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" }, + "ContactPoints": { + "items": { + "$ref": "#/definitions/EmbeddedContactPoint" + }, + "type": "array", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" + }, "CreateDashboardSnapshotCommand": { "properties": { "Result": { @@ -1581,14 +1588,16 @@ }, "MessageTemplate": { "properties": { - "Name": { - "type": "string" - }, - "Template": { - "type": "string" + "name": { + "type": "string", + "x-go-name": "Name" }, "provenance": { "$ref": "#/definitions/Provenance" + }, + "template": { + "type": "string", + "x-go-name": "Template" } }, "type": "object", @@ -1596,8 +1605,9 @@ }, "MessageTemplateContent": { "properties": { - "Template": { - "type": "string" + "template": { + "type": "string", + "x-go-name": "Template" } }, "type": "object", @@ -3176,6 +3186,7 @@ "ValidationError": { "properties": { "msg": { + "example": "error message", "type": "string", "x-go-name": "Msg" } @@ -3513,6 +3524,7 @@ "$ref": "#/definitions/Duration" }, "gettableAlert": { + "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" @@ -3571,16 +3583,15 @@ "status", "updatedAt" ], - "type": "object", - "x-go-name": "GettableAlert", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + "type": "object" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, - "type": "array" + "type": "array", + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "gettableSilence": { "properties": { @@ -3639,11 +3650,12 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, - "type": "array" + "type": "array", + "x-go-name": "GettableSilences", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "labelSet": { "additionalProperties": { @@ -3815,6 +3827,7 @@ "type": "object" }, "receiver": { + "description": "Receiver receiver", "properties": { "name": { "description": "name", @@ -3825,9 +3838,7 @@ "required": [ "name" ], - "type": "object", - "x-go-name": "Receiver", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + "type": "object" }, "silence": { "description": "Silence silence", @@ -5593,6 +5604,9 @@ }, "/api/v1/provisioning/alert-rules": { "post": { + "consumes": [ + "application/json" + ], "operationId": "RoutePostAlertRule", "parameters": [ { @@ -5628,6 +5642,7 @@ "operationId": "RouteDeleteAlertRule", "parameters": [ { + "description": "Alert rule UID", "in": "path", "name": "UID", "required": true, @@ -5637,12 +5652,6 @@ "responses": { "204": { "description": " The alert rule was deleted successfully." - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } }, "summary": "Delete a specific alert rule by UID.", @@ -5654,6 +5663,7 @@ "operationId": "RouteGetAlertRule", "parameters": [ { + "description": "Alert rule UID", "in": "path", "name": "UID", "required": true, @@ -5667,11 +5677,8 @@ "$ref": "#/definitions/AlertRule" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } }, "summary": "Get a specific alert rule by UID.", @@ -5686,6 +5693,7 @@ "operationId": "RoutePutAlertRule", "parameters": [ { + "description": "Alert rule UID", "in": "path", "name": "UID", "required": true, @@ -5724,15 +5732,9 @@ "operationId": "RouteGetContactpoints", "responses": { "200": { - "description": "Route", + "description": "ContactPoints", "schema": { - "$ref": "#/definitions/Route" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" + "$ref": "#/definitions/ContactPoints" } } }, @@ -5757,9 +5759,9 @@ ], "responses": { "202": { - "description": "Ack", + "description": "EmbeddedContactPoint", "schema": { - "$ref": "#/definitions/Ack" + "$ref": "#/definitions/EmbeddedContactPoint" } }, "400": { @@ -5791,17 +5793,8 @@ } ], "responses": { - "202": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "204": { + "description": " The contact point was deleted successfully." } }, "summary": "Delete a contact point.", @@ -5906,12 +5899,6 @@ "schema": { "$ref": "#/definitions/MuteTimings" } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } }, "summary": "Get all the mute timings.", @@ -5958,7 +5945,7 @@ "operationId": "RouteDeleteMuteTiming", "parameters": [ { - "description": "Template Name", + "description": "Mute timing name", "in": "path", "name": "name", "required": true, @@ -5968,10 +5955,7 @@ ], "responses": { "204": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } + "description": " The mute timing was deleted successfully." } }, "summary": "Delete a mute timing.", @@ -5983,7 +5967,7 @@ "operationId": "RouteGetMuteTiming", "parameters": [ { - "description": "Template Name", + "description": "Mute timing name", "in": "path", "name": "name", "required": true, @@ -5998,11 +5982,8 @@ "$ref": "#/definitions/MuteTimeInterval" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } }, "summary": "Get a mute timing.", @@ -6017,7 +5998,7 @@ "operationId": "RoutePutMuteTiming", "parameters": [ { - "description": "Template Name", + "description": "Mute timing name", "in": "path", "name": "name", "required": true, @@ -6061,12 +6042,6 @@ "schema": { "$ref": "#/definitions/Route" } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } }, "summary": "Get the notification policy tree.", @@ -6081,6 +6056,7 @@ "operationId": "RoutePutPolicyTree", "parameters": [ { + "description": "The new notification routing tree to use", "in": "body", "name": "Body", "schema": { @@ -6113,16 +6089,13 @@ "operationId": "RouteGetTemplates", "responses": { "200": { - "description": "MessageTemplate", + "description": "MessageTemplates", "schema": { - "$ref": "#/definitions/MessageTemplate" + "$ref": "#/definitions/MessageTemplates" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } }, "summary": "Get all message templates.", @@ -6146,10 +6119,7 @@ ], "responses": { "204": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } + "description": " The template was deleted successfully." } }, "summary": "Delete a template.", @@ -6177,10 +6147,7 @@ } }, "404": { - "description": "NotFound", - "schema": { - "$ref": "#/definitions/NotFound" - } + "description": " Not found." } }, "summary": "Get a message template.", @@ -6212,9 +6179,9 @@ ], "responses": { "202": { - "description": "Ack", + "description": "MessageTemplate", "schema": { - "$ref": "#/definitions/Ack" + "$ref": "#/definitions/MessageTemplate" } }, "400": { diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index cdbeaa4b219..ddeefda9cb3 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -1669,6 +1669,9 @@ }, "/api/v1/provisioning/alert-rules": { "post": { + "consumes": [ + "application/json" + ], "tags": [ "provisioning", "stable" @@ -1711,6 +1714,7 @@ "parameters": [ { "type": "string", + "description": "Alert rule UID", "name": "UID", "in": "path", "required": true @@ -1723,11 +1727,8 @@ "$ref": "#/definitions/AlertRule" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } } }, @@ -1744,6 +1745,7 @@ "parameters": [ { "type": "string", + "description": "Alert rule UID", "name": "UID", "in": "path", "required": true @@ -1781,6 +1783,7 @@ "parameters": [ { "type": "string", + "description": "Alert rule UID", "name": "UID", "in": "path", "required": true @@ -1789,12 +1792,6 @@ "responses": { "204": { "description": " The alert rule was deleted successfully." - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } } } @@ -1809,15 +1806,9 @@ "operationId": "RouteGetContactpoints", "responses": { "200": { - "description": "Route", + "description": "ContactPoints", "schema": { - "$ref": "#/definitions/Route" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" + "$ref": "#/definitions/ContactPoints" } } } @@ -1843,9 +1834,9 @@ ], "responses": { "202": { - "description": "Ack", + "description": "EmbeddedContactPoint", "schema": { - "$ref": "#/definitions/Ack" + "$ref": "#/definitions/EmbeddedContactPoint" } }, "400": { @@ -1919,17 +1910,8 @@ } ], "responses": { - "202": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "204": { + "description": " The contact point was deleted successfully." } } } @@ -1996,12 +1978,6 @@ "schema": { "$ref": "#/definitions/MuteTimings" } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } } }, @@ -2052,7 +2028,7 @@ { "type": "string", "x-go-name": "Name", - "description": "Template Name", + "description": "Mute timing name", "name": "name", "in": "path", "required": true @@ -2065,11 +2041,8 @@ "$ref": "#/definitions/MuteTimeInterval" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } } }, @@ -2087,7 +2060,7 @@ { "type": "string", "x-go-name": "Name", - "description": "Template Name", + "description": "Mute timing name", "name": "name", "in": "path", "required": true @@ -2126,7 +2099,7 @@ { "type": "string", "x-go-name": "Name", - "description": "Template Name", + "description": "Mute timing name", "name": "name", "in": "path", "required": true @@ -2134,10 +2107,7 @@ ], "responses": { "204": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } + "description": " The mute timing was deleted successfully." } } } @@ -2156,12 +2126,6 @@ "schema": { "$ref": "#/definitions/Route" } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } } } }, @@ -2177,6 +2141,7 @@ "operationId": "RoutePutPolicyTree", "parameters": [ { + "description": "The new notification routing tree to use", "name": "Body", "in": "body", "schema": { @@ -2210,16 +2175,13 @@ "operationId": "RouteGetTemplates", "responses": { "200": { - "description": "MessageTemplate", + "description": "MessageTemplates", "schema": { - "$ref": "#/definitions/MessageTemplate" + "$ref": "#/definitions/MessageTemplates" } }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } + "404": { + "description": " Not found." } } } @@ -2250,10 +2212,7 @@ } }, "404": { - "description": "NotFound", - "schema": { - "$ref": "#/definitions/NotFound" - } + "description": " Not found." } } }, @@ -2286,9 +2245,9 @@ ], "responses": { "202": { - "description": "Ack", + "description": "MessageTemplate", "schema": { - "$ref": "#/definitions/Ack" + "$ref": "#/definitions/MessageTemplate" } }, "400": { @@ -2318,10 +2277,7 @@ ], "responses": { "204": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } + "description": " The template was deleted successfully." } } } @@ -2934,6 +2890,13 @@ }, "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" }, + "ContactPoints": { + "type": "array", + "items": { + "$ref": "#/definitions/EmbeddedContactPoint" + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" + }, "CreateDashboardSnapshotCommand": { "type": "object", "required": [ @@ -3981,14 +3944,16 @@ "MessageTemplate": { "type": "object", "properties": { - "Name": { - "type": "string" - }, - "Template": { - "type": "string" + "name": { + "type": "string", + "x-go-name": "Name" }, "provenance": { "$ref": "#/definitions/Provenance" + }, + "template": { + "type": "string", + "x-go-name": "Template" } }, "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" @@ -3996,8 +3961,9 @@ "MessageTemplateContent": { "type": "object", "properties": { - "Template": { - "type": "string" + "template": { + "type": "string", + "x-go-name": "Template" } }, "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" @@ -5577,7 +5543,8 @@ "properties": { "msg": { "type": "string", - "x-go-name": "Msg" + "x-go-name": "Msg", + "example": "error message" } }, "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" @@ -5914,6 +5881,7 @@ "$ref": "#/definitions/Duration" }, "gettableAlert": { + "description": "GettableAlert gettable alert", "type": "object", "required": [ "labels", @@ -5973,16 +5941,15 @@ "x-go-name": "UpdatedAt" } }, - "x-go-name": "GettableAlert", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models", "$ref": "#/definitions/gettableAlert" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "type": "array", "items": { "$ref": "#/definitions/gettableAlert" }, + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models", "$ref": "#/definitions/gettableAlerts" }, "gettableSilence": { @@ -6043,11 +6010,12 @@ "$ref": "#/definitions/gettableSilence" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "type": "array", "items": { "$ref": "#/definitions/gettableSilence" }, + "x-go-name": "GettableSilences", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models", "$ref": "#/definitions/gettableSilences" }, "labelSet": { @@ -6221,6 +6189,7 @@ "$ref": "#/definitions/postableSilence" }, "receiver": { + "description": "Receiver receiver", "type": "object", "required": [ "name" @@ -6232,8 +6201,6 @@ "x-go-name": "Name" } }, - "x-go-name": "Receiver", - "x-go-package": "github.com/prometheus/alertmanager/api/v2/models", "$ref": "#/definitions/receiver" }, "silence": {