From 2b23445b4224f903767e80451b8a2b72b678f517 Mon Sep 17 00:00:00 2001 From: Alexander Weaver Date: Fri, 8 Jul 2022 11:00:33 -0500 Subject: [PATCH] Fix consistency errors and regenerate (#51935) (#51985) (cherry picked from commit d77731646c5cb93ab47b6ac3782957bcae9d6787) --- pkg/services/ngalert/api/tooling/api.json | 208 +++++++----------- .../definitions/provisioning_alert_rules.go | 1 + pkg/services/ngalert/api/tooling/post.json | 203 +++++++---------- pkg/services/ngalert/api/tooling/spec.json | 199 +++++++---------- 4 files changed, 243 insertions(+), 368 deletions(-) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 85932bbc80c..862062003c5 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -196,162 +196,115 @@ }, "AlertRule": { "properties": { - "annotations": { + "Annotations": { "additionalProperties": { "type": "string" }, - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" - }, - "type": "object", - "x-go-name": "Annotations" + "type": "object" }, - "condition": { - "example": "A", - "type": "string", - "x-go-name": "Condition" + "Condition": { + "type": "string" }, - "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 - } - } - ], + "DashboardUID": { + "type": "string" + }, + "Data": { "items": { "$ref": "#/definitions/AlertQuery" }, - "type": "array", - "x-go-name": "Data" + "type": "array" }, - "execErrState": { - "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState", + "ExecErrState": { "enum": [ "Alerting", "Error", "OK" ], "type": "string", - "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState", - "x-go-name": "ExecErrState" + "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState" }, - "folderUID": { - "example": "project_x", - "type": "string", - "x-go-name": "FolderUID" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "format": "int64", - "type": "integer", - "x-go-name": "ID" + "type": "integer" }, - "labels": { + "IntervalSeconds": { + "format": "int64", + "type": "integer" + }, + "Labels": { "additionalProperties": { "type": "string" }, - "example": { - "team": "sre-team-1" - }, - "type": "object", - "x-go-name": "Labels" + "type": "object" }, - "noDataState": { - "description": "\nAlerting Alerting\nNoData NoData\nOK OK", + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "enum": [ "Alerting", "NoData", "OK" ], "type": "string", - "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK", - "x-go-name": "NoDataState" + "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK" }, - "orgID": { + "OrgID": { "format": "int64", - "type": "integer", - "x-go-name": "OrgID" + "type": "integer" }, - "provenance": { - "$ref": "#/definitions/Provenance" + "PanelID": { + "format": "int64", + "type": "integer" }, - "ruleGroup": { - "example": "eval_group_1", - "maxLength": 190, - "minLength": 1, - "type": "string", - "x-go-name": "RuleGroup" + "RuleGroup": { + "type": "string" }, - "title": { - "example": "Always firing", - "maxLength": 190, - "minLength": 1, - "type": "string", - "x-go-name": "Title" + "Title": { + "type": "string" }, - "uid": { - "type": "string", - "x-go-name": "UID" + "UID": { + "type": "string" }, - "updated": { + "Updated": { "format": "date-time", - "readOnly": true, + "type": "string" + }, + "Version": { + "format": "int64", + "type": "integer" + } + }, + "title": "AlertRule is the model for alert rules in unified alerting.", + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models" + }, + "AlertRuleGroup": { + "properties": { + "folderUid": { "type": "string", - "x-go-name": "Updated" + "x-go-name": "FolderUID" + }, + "interval": { + "format": "int64", + "type": "integer", + "x-go-name": "Interval" + }, + "rules": { + "items": { + "$ref": "#/definitions/AlertRule" + }, + "type": "array", + "x-go-name": "Rules" + }, + "title": { + "type": "string", + "x-go-name": "Title" } }, - "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" }, @@ -3141,6 +3094,7 @@ "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" @@ -3173,9 +3127,9 @@ "$ref": "#/definitions/Userinfo" } }, - "title": "URL is a custom URL type that allows validation at configuration load time.", + "title": "A URL represents a parsed URL (technically, a URI reference).", "type": "object", - "x-go-package": "github.com/prometheus/common/config" + "x-go-package": "net/url" }, "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.", @@ -3373,7 +3327,6 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "alertGroup": { - "description": "AlertGroup alert group", "properties": { "alerts": { "description": "alerts", @@ -3395,7 +3348,9 @@ "labels", "receiver" ], - "type": "object" + "type": "object", + "x-go-name": "AlertGroup", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "alertGroups": { "description": "AlertGroups alert groups", @@ -3584,11 +3539,12 @@ "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": { @@ -3647,11 +3603,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": { @@ -4208,7 +4165,10 @@ ], "responses": { "200": { - "$ref": "#/responses/AlertRuleGroup" + "description": "AlertRuleGroup", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } }, "404": { "description": " Not found." 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 d54f27090bd..8ffd32b2ad4 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go @@ -176,6 +176,7 @@ type AlertRuleGroupMetadata struct { Interval int64 `json:"interval"` } +// swagger:model type AlertRuleGroup struct { Title string `json:"title"` FolderUID string `json:"folderUid"` diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index 03b771229ac..97e674ec4a5 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -196,162 +196,115 @@ }, "AlertRule": { "properties": { - "annotations": { + "Annotations": { "additionalProperties": { "type": "string" }, - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" - }, - "type": "object", - "x-go-name": "Annotations" + "type": "object" }, - "condition": { - "example": "A", - "type": "string", - "x-go-name": "Condition" + "Condition": { + "type": "string" }, - "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 - } - } - ], + "DashboardUID": { + "type": "string" + }, + "Data": { "items": { "$ref": "#/definitions/AlertQuery" }, - "type": "array", - "x-go-name": "Data" + "type": "array" }, - "execErrState": { - "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState", + "ExecErrState": { "enum": [ "Alerting", "Error", "OK" ], "type": "string", - "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState", - "x-go-name": "ExecErrState" + "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState" }, - "folderUID": { - "example": "project_x", - "type": "string", - "x-go-name": "FolderUID" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "format": "int64", - "type": "integer", - "x-go-name": "ID" + "type": "integer" }, - "labels": { + "IntervalSeconds": { + "format": "int64", + "type": "integer" + }, + "Labels": { "additionalProperties": { "type": "string" }, - "example": { - "team": "sre-team-1" - }, - "type": "object", - "x-go-name": "Labels" + "type": "object" }, - "noDataState": { - "description": "\nAlerting Alerting\nNoData NoData\nOK OK", + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "enum": [ "Alerting", "NoData", "OK" ], "type": "string", - "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK", - "x-go-name": "NoDataState" + "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK" }, - "orgID": { + "OrgID": { "format": "int64", - "type": "integer", - "x-go-name": "OrgID" + "type": "integer" }, - "provenance": { - "$ref": "#/definitions/Provenance" + "PanelID": { + "format": "int64", + "type": "integer" }, - "ruleGroup": { - "example": "eval_group_1", - "maxLength": 190, - "minLength": 1, - "type": "string", - "x-go-name": "RuleGroup" + "RuleGroup": { + "type": "string" }, - "title": { - "example": "Always firing", - "maxLength": 190, - "minLength": 1, - "type": "string", - "x-go-name": "Title" + "Title": { + "type": "string" }, - "uid": { - "type": "string", - "x-go-name": "UID" + "UID": { + "type": "string" }, - "updated": { + "Updated": { "format": "date-time", - "readOnly": true, + "type": "string" + }, + "Version": { + "format": "int64", + "type": "integer" + } + }, + "title": "AlertRule is the model for alert rules in unified alerting.", + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models" + }, + "AlertRuleGroup": { + "properties": { + "folderUid": { "type": "string", - "x-go-name": "Updated" + "x-go-name": "FolderUID" + }, + "interval": { + "format": "int64", + "type": "integer", + "x-go-name": "Interval" + }, + "rules": { + "items": { + "$ref": "#/definitions/AlertRule" + }, + "type": "array", + "x-go-name": "Rules" + }, + "title": { + "type": "string", + "x-go-name": "Title" } }, - "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" }, @@ -3141,6 +3094,7 @@ "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" @@ -3173,9 +3127,9 @@ "$ref": "#/definitions/Userinfo" } }, - "title": "URL is a custom URL type that allows validation at configuration load time.", + "title": "A URL represents a parsed URL (technically, a URI reference).", "type": "object", - "x-go-package": "github.com/prometheus/common/config" + "x-go-package": "net/url" }, "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.", @@ -3649,12 +3603,11 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "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": { @@ -3783,7 +3736,6 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "postableSilence": { - "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", @@ -3823,7 +3775,9 @@ "matchers", "startsAt" ], - "type": "object" + "type": "object", + "x-go-name": "PostableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "receiver": { "description": "Receiver receiver", @@ -5861,7 +5815,10 @@ ], "responses": { "200": { - "$ref": "#/responses/AlertRuleGroup" + "description": "AlertRuleGroup", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } }, "404": { "description": " Not found." diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index fd53085e240..b0df1f8c530 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -1940,7 +1940,10 @@ ], "responses": { "200": { - "$ref": "#/responses/AlertRuleGroup" + "description": "AlertRuleGroup", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } }, "404": { "description": " Not found." @@ -2577,161 +2580,114 @@ }, "AlertRule": { "type": "object", - "required": [ - "orgID", - "folderUID", - "ruleGroup", - "title", - "condition", - "data", - "noDataState", - "execErrState", - "for" - ], + "title": "AlertRule is the model for alert rules in unified alerting.", "properties": { - "annotations": { + "Annotations": { "type": "object", "additionalProperties": { "type": "string" - }, - "x-go-name": "Annotations", - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" } }, - "condition": { - "type": "string", - "x-go-name": "Condition", - "example": "A" + "Condition": { + "type": "string" }, - "data": { + "DashboardUID": { + "type": "string" + }, + "Data": { "type": "array", "items": { "$ref": "#/definitions/AlertQuery" - }, - "x-go-name": "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 - } - } - ] + } }, - "execErrState": { - "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState", + "ExecErrState": { "type": "string", "enum": [ "Alerting", "Error", "OK" ], - "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState", - "x-go-name": "ExecErrState" + "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState" }, - "folderUID": { - "type": "string", - "x-go-name": "FolderUID", - "example": "project_x" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "type": "integer", - "format": "int64", - "x-go-name": "ID" + "format": "int64" }, - "labels": { + "IntervalSeconds": { + "type": "integer", + "format": "int64" + }, + "Labels": { "type": "object", "additionalProperties": { "type": "string" - }, - "x-go-name": "Labels", - "example": { - "team": "sre-team-1" } }, - "noDataState": { - "description": "\nAlerting Alerting\nNoData NoData\nOK OK", + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "type": "string", "enum": [ "Alerting", "NoData", "OK" ], - "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK", - "x-go-name": "NoDataState" + "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK" }, - "orgID": { + "OrgID": { + "type": "integer", + "format": "int64" + }, + "PanelID": { + "type": "integer", + "format": "int64" + }, + "RuleGroup": { + "type": "string" + }, + "Title": { + "type": "string" + }, + "UID": { + "type": "string" + }, + "Updated": { + "type": "string", + "format": "date-time" + }, + "Version": { + "type": "integer", + "format": "int64" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models" + }, + "AlertRuleGroup": { + "type": "object", + "properties": { + "folderUid": { + "type": "string", + "x-go-name": "FolderUID" + }, + "interval": { "type": "integer", "format": "int64", - "x-go-name": "OrgID" + "x-go-name": "Interval" }, - "provenance": { - "$ref": "#/definitions/Provenance" - }, - "ruleGroup": { - "type": "string", - "maxLength": 190, - "minLength": 1, - "x-go-name": "RuleGroup", - "example": "eval_group_1" + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertRule" + }, + "x-go-name": "Rules" }, "title": { "type": "string", - "maxLength": 190, - "minLength": 1, - "x-go-name": "Title", - "example": "Always firing" - }, - "uid": { - "type": "string", - "x-go-name": "UID" - }, - "updated": { - "type": "string", - "format": "date-time", - "x-go-name": "Updated", - "readOnly": true + "x-go-name": "Title" } }, "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" @@ -5526,8 +5482,9 @@ "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.", "type": "object", - "title": "URL is a custom URL type that allows validation at configuration load time.", + "title": "A URL represents a parsed URL (technically, a URI reference).", "properties": { "ForceQuery": { "type": "boolean" @@ -5560,7 +5517,7 @@ "$ref": "#/definitions/Userinfo" } }, - "x-go-package": "github.com/prometheus/common/config" + "x-go-package": "net/url" }, "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.", @@ -6039,12 +5996,11 @@ "$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": { @@ -6174,7 +6130,6 @@ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" }, "postableSilence": { - "description": "PostableSilence postable silence", "type": "object", "required": [ "comment", @@ -6215,6 +6170,8 @@ "x-go-name": "StartsAt" } }, + "x-go-name": "PostableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models", "$ref": "#/definitions/postableSilence" }, "receiver": {