From d77731646c5cb93ab47b6ac3782957bcae9d6787 Mon Sep 17 00:00:00 2001 From: Alexander Weaver Date: Fri, 8 Jul 2022 10:33:43 -0500 Subject: [PATCH] Fix consistency errors and regenerate (#51935) --- pkg/services/ngalert/api/tooling/api.json | 166 +++++++---------- .../definitions/provisioning_alert_rules.go | 1 + pkg/services/ngalert/api/tooling/post.json | 165 +++++++---------- pkg/services/ngalert/api/tooling/spec.json | 169 ++++++++---------- 4 files changed, 205 insertions(+), 296 deletions(-) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 60645a449f3..ac160369476 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -167,71 +167,25 @@ }, "AlertRule": { "properties": { - "annotations": { + "Annotations": { "additionalProperties": { "type": "string" }, - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" - }, "type": "object" }, - "condition": { - "example": "A", + "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" }, - "execErrState": { + "ExecErrState": { "enum": [ "Alerting", "Error", @@ -239,27 +193,27 @@ ], "type": "string" }, - "folderUID": { - "example": "project_x", - "type": "string" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "format": "int64", "type": "integer" }, - "labels": { + "IntervalSeconds": { + "format": "int64", + "type": "integer" + }, + "Labels": { "additionalProperties": { "type": "string" }, - "example": { - "team": "sre-team-1" - }, "type": "object" }, - "noDataState": { + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "enum": [ "Alerting", "NoData", @@ -267,45 +221,58 @@ ], "type": "string" }, - "orgID": { + "OrgID": { "format": "int64", "type": "integer" }, - "provenance": { - "$ref": "#/definitions/Provenance" + "PanelID": { + "format": "int64", + "type": "integer" }, - "ruleGroup": { - "example": "eval_group_1", - "maxLength": 190, - "minLength": 1, + "RuleGroup": { "type": "string" }, + "RuleGroupIndex": { + "format": "int64", + "type": "integer" + }, + "Title": { + "type": "string" + }, + "UID": { + "type": "string" + }, + "Updated": { + "format": "date-time", + "type": "string" + }, + "Version": { + "format": "int64", + "type": "integer" + } + }, + "title": "AlertRule is the model for alert rules in unified alerting.", + "type": "object" + }, + "AlertRuleGroup": { + "properties": { + "folderUid": { + "type": "string" + }, + "interval": { + "format": "int64", + "type": "integer" + }, + "rules": { + "items": { + "$ref": "#/definitions/AlertRule" + }, + "type": "array" + }, "title": { - "example": "Always firing", - "maxLength": 190, - "minLength": 1, - "type": "string" - }, - "uid": { - "type": "string" - }, - "updated": { - "format": "date-time", - "readOnly": true, "type": "string" } }, - "required": [ - "orgID", - "folderUID", - "ruleGroup", - "title", - "condition", - "data", - "noDataState", - "execErrState", - "for" - ], "type": "object" }, "AlertRuleGroupMetadata": { @@ -2592,7 +2559,6 @@ "type": "object" }, "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" @@ -2625,7 +2591,7 @@ "$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" }, "Userinfo": { @@ -2795,6 +2761,7 @@ "type": "object" }, "alertGroup": { + "description": "AlertGroup alert group", "properties": { "alerts": { "description": "alerts", @@ -2925,7 +2892,6 @@ "$ref": "#/definitions/Duration" }, "gettableAlert": { - "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" @@ -2981,12 +2947,14 @@ "type": "object" }, "gettableAlerts": { + "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, "type": "array" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "properties": { "comment": { "description": "comment", @@ -3035,7 +3003,6 @@ "type": "object" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, @@ -3550,7 +3517,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 05c7dbeb931..fd193aeeecc 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -167,71 +167,25 @@ }, "AlertRule": { "properties": { - "annotations": { + "Annotations": { "additionalProperties": { "type": "string" }, - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" - }, "type": "object" }, - "condition": { - "example": "A", + "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" }, - "execErrState": { + "ExecErrState": { "enum": [ "Alerting", "Error", @@ -239,27 +193,27 @@ ], "type": "string" }, - "folderUID": { - "example": "project_x", - "type": "string" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "format": "int64", "type": "integer" }, - "labels": { + "IntervalSeconds": { + "format": "int64", + "type": "integer" + }, + "Labels": { "additionalProperties": { "type": "string" }, - "example": { - "team": "sre-team-1" - }, "type": "object" }, - "noDataState": { + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "enum": [ "Alerting", "NoData", @@ -267,45 +221,58 @@ ], "type": "string" }, - "orgID": { + "OrgID": { "format": "int64", "type": "integer" }, - "provenance": { - "$ref": "#/definitions/Provenance" + "PanelID": { + "format": "int64", + "type": "integer" }, - "ruleGroup": { - "example": "eval_group_1", - "maxLength": 190, - "minLength": 1, + "RuleGroup": { "type": "string" }, + "RuleGroupIndex": { + "format": "int64", + "type": "integer" + }, + "Title": { + "type": "string" + }, + "UID": { + "type": "string" + }, + "Updated": { + "format": "date-time", + "type": "string" + }, + "Version": { + "format": "int64", + "type": "integer" + } + }, + "title": "AlertRule is the model for alert rules in unified alerting.", + "type": "object" + }, + "AlertRuleGroup": { + "properties": { + "folderUid": { + "type": "string" + }, + "interval": { + "format": "int64", + "type": "integer" + }, + "rules": { + "items": { + "$ref": "#/definitions/AlertRule" + }, + "type": "array" + }, "title": { - "example": "Always firing", - "maxLength": 190, - "minLength": 1, - "type": "string" - }, - "uid": { - "type": "string" - }, - "updated": { - "format": "date-time", - "readOnly": true, "type": "string" } }, - "required": [ - "orgID", - "folderUID", - "ruleGroup", - "title", - "condition", - "data", - "noDataState", - "execErrState", - "for" - ], "type": "object" }, "AlertRuleGroupMetadata": { @@ -2592,7 +2559,6 @@ "type": "object" }, "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" @@ -2625,7 +2591,7 @@ "$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" }, "Userinfo": { @@ -2819,7 +2785,6 @@ "type": "object" }, "alertGroups": { - "description": "AlertGroups alert groups", "items": { "$ref": "#/definitions/alertGroup" }, @@ -2983,7 +2948,6 @@ "type": "object" }, "gettableAlerts": { - "description": "GettableAlerts gettable alerts", "items": { "$ref": "#/definitions/gettableAlert" }, @@ -3149,7 +3113,6 @@ "type": "array" }, "postableSilence": { - "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", @@ -3187,6 +3150,7 @@ "type": "object" }, "receiver": { + "description": "Receiver receiver", "properties": { "name": { "description": "name", @@ -5179,7 +5143,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 6878508f9b7..a9b374c9c8c 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -1916,7 +1916,10 @@ ], "responses": { "200": { - "$ref": "#/responses/AlertRuleGroup" + "description": "AlertRuleGroup", + "schema": { + "$ref": "#/definitions/AlertRuleGroup" + } }, "404": { "description": " Not found." @@ -2518,83 +2521,27 @@ }, "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" - }, - "example": { - "runbook_url": "https://supercoolrunbook.com/page/13" } }, - "condition": { - "type": "string", - "example": "A" + "Condition": { + "type": "string" }, - "data": { + "DashboardUID": { + "type": "string" + }, + "Data": { "type": "array", "items": { "$ref": "#/definitions/AlertQuery" - }, - "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": { + "ExecErrState": { "type": "string", "enum": [ "Alerting", @@ -2602,27 +2549,27 @@ "OK" ] }, - "folderUID": { - "type": "string", - "example": "project_x" - }, - "for": { + "For": { "$ref": "#/definitions/Duration" }, - "id": { + "ID": { "type": "integer", "format": "int64" }, - "labels": { + "IntervalSeconds": { + "type": "integer", + "format": "int64" + }, + "Labels": { "type": "object", "additionalProperties": { "type": "string" - }, - "example": { - "team": "sre-team-1" } }, - "noDataState": { + "NamespaceUID": { + "type": "string" + }, + "NoDataState": { "type": "string", "enum": [ "Alerting", @@ -2630,32 +2577,55 @@ "OK" ] }, - "orgID": { + "OrgID": { "type": "integer", "format": "int64" }, - "provenance": { - "$ref": "#/definitions/Provenance" + "PanelID": { + "type": "integer", + "format": "int64" }, - "ruleGroup": { - "type": "string", - "maxLength": 190, - "minLength": 1, - "example": "eval_group_1" - }, - "title": { - "type": "string", - "maxLength": 190, - "minLength": 1, - "example": "Always firing" - }, - "uid": { + "RuleGroup": { "type": "string" }, - "updated": { + "RuleGroupIndex": { + "type": "integer", + "format": "int64" + }, + "Title": { + "type": "string" + }, + "UID": { + "type": "string" + }, + "Updated": { "type": "string", - "format": "date-time", - "readOnly": true + "format": "date-time" + }, + "Version": { + "type": "integer", + "format": "int64" + } + } + }, + "AlertRuleGroup": { + "type": "object", + "properties": { + "folderUid": { + "type": "string" + }, + "interval": { + "type": "integer", + "format": "int64" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertRule" + } + }, + "title": { + "type": "string" } } }, @@ -4947,9 +4917,8 @@ } }, "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": "A URL represents a parsed URL (technically, a URI reference).", + "title": "URL is a custom URL type that allows validation at configuration load time.", "properties": { "ForceQuery": { "type": "boolean" @@ -5283,6 +5252,7 @@ "$ref": "#/definitions/Duration" }, "gettableAlert": { + "description": "GettableAlert gettable alert", "type": "object", "required": [ "labels", @@ -5346,6 +5316,7 @@ "$ref": "#/definitions/gettableAlerts" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "type": "object", "required": [ "comment",