From cb0bcb6fe4c9d0cef7bbef9a328d2b70a4221665 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Tue, 21 May 2024 10:06:44 -0400 Subject: [PATCH] Alerting: Fix/update alerting API spec (#88130) --- pkg/services/ngalert/api/tooling/api.json | 13 ++++++------- .../definitions/provisioning_alert_rules.go | 18 ++++++++---------- pkg/services/ngalert/api/tooling/post.json | 19 ++++++++----------- pkg/services/ngalert/api/tooling/spec.json | 19 ++++++++----------- public/api-merged.json | 11 +++++------ public/openapi3.json | 11 +++++------ 6 files changed, 40 insertions(+), 51 deletions(-) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 7154995fea5..ea45ed05448 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -174,7 +174,7 @@ "condition": { "type": "string" }, - "dasboardUid": { + "dashboardUid": { "type": "string" }, "data": { @@ -2435,7 +2435,6 @@ "type": "object" }, "PagerdutyImage": { - "description": "PagerdutyImage is an image", "properties": { "alt": { "type": "string" @@ -2447,10 +2446,10 @@ "type": "string" } }, + "title": "PagerdutyImage is an image.", "type": "object" }, "PagerdutyLink": { - "description": "PagerdutyLink is a link", "properties": { "href": { "type": "string" @@ -2459,6 +2458,7 @@ "type": "string" } }, + "title": "PagerdutyLink is a link.", "type": "object" }, "PermissionDenied": { @@ -4241,7 +4241,7 @@ "type": "object" }, "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.", + "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.", "type": "object" }, "ValidationError": { @@ -4417,7 +4417,6 @@ "type": "object" }, "alertGroup": { - "description": "AlertGroup alert group", "properties": { "alerts": { "description": "alerts", @@ -4546,6 +4545,7 @@ "type": "object" }, "gettableAlert": { + "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" @@ -4607,7 +4607,6 @@ "type": "array" }, "gettableSilence": { - "description": "GettableSilence gettable silence", "properties": { "comment": { "description": "comment", @@ -4656,7 +4655,6 @@ "type": "object" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, @@ -4807,6 +4805,7 @@ "type": "array" }, "postableSilence": { + "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", 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 d7c0938938b..c3d8d9bcf2c 100644 --- a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go +++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go @@ -291,15 +291,13 @@ type RelativeTimeRangeExport struct { } // AlertRuleNotificationSettingsExport is the provisioned export of models.NotificationSettings. -// Field name mismatches with Terraform provider schema are noted where applicable. type AlertRuleNotificationSettingsExport struct { - // TF -> `contact_point` - Receiver string `yaml:"receiver,omitempty" json:"receiver,omitempty" hcl:"contact_point"` - - GroupBy []string `yaml:"group_by,omitempty" json:"group_by,omitempty" hcl:"group_by"` - GroupWait *string `yaml:"group_wait,omitempty" json:"group_wait,omitempty" hcl:"group_wait,optional"` - GroupInterval *string `yaml:"group_interval,omitempty" json:"group_interval,omitempty" hcl:"group_interval,optional"` - RepeatInterval *string `yaml:"repeat_interval,omitempty" json:"repeat_interval,omitempty" hcl:"repeat_interval,optional"` - // TF -> `mute_timings` - MuteTimeIntervals []string `yaml:"mute_time_intervals,omitempty" json:"mute_time_intervals,omitempty" hcl:"mute_timings"` + // Field name mismatches with Terraform provider schema are noted where applicable. + + Receiver string `yaml:"receiver,omitempty" json:"receiver,omitempty" hcl:"contact_point"` // TF -> `contact_point` + GroupBy []string `yaml:"group_by,omitempty" json:"group_by,omitempty" hcl:"group_by"` + GroupWait *string `yaml:"group_wait,omitempty" json:"group_wait,omitempty" hcl:"group_wait,optional"` + GroupInterval *string `yaml:"group_interval,omitempty" json:"group_interval,omitempty" hcl:"group_interval,optional"` + RepeatInterval *string `yaml:"repeat_interval,omitempty" json:"repeat_interval,omitempty" hcl:"repeat_interval,optional"` + MuteTimeIntervals []string `yaml:"mute_time_intervals,omitempty" json:"mute_time_intervals,omitempty" hcl:"mute_timings"` // TF -> `mute_timings` } diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index e17b66af824..7d9b58d2b0f 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -174,7 +174,7 @@ "condition": { "type": "string" }, - "dasboardUid": { + "dashboardUid": { "type": "string" }, "data": { @@ -2435,7 +2435,6 @@ "type": "object" }, "PagerdutyImage": { - "description": "PagerdutyImage is an image", "properties": { "alt": { "type": "string" @@ -2447,10 +2446,10 @@ "type": "string" } }, + "title": "PagerdutyImage is an image.", "type": "object" }, "PagerdutyLink": { - "description": "PagerdutyLink is a link", "properties": { "href": { "type": "string" @@ -2459,6 +2458,7 @@ "type": "string" } }, + "title": "PagerdutyLink is a link.", "type": "object" }, "PermissionDenied": { @@ -4176,7 +4176,7 @@ "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 the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", + "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\nThe Host field contains the host and port subcomponents of the URL.\nWhen the port is present, it is separated from the host with a colon.\nWhen the host is an IPv6 address, it must be enclosed in square brackets:\n\"[fe80::1]:80\". The [net.JoinHostPort] function combines a host and port\ninto a string suitable for the Host field, adding square brackets to\nthe host when necessary.\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 the [URL.EscapedPath] method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "properties": { "ForceQuery": { "type": "boolean" @@ -4242,7 +4242,7 @@ "type": "object" }, "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.", + "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.", "type": "object" }, "ValidationError": { @@ -4418,7 +4418,6 @@ "type": "object" }, "alertGroup": { - "description": "AlertGroup alert group", "properties": { "alerts": { "description": "alerts", @@ -4442,6 +4441,7 @@ "type": "object" }, "alertGroups": { + "description": "AlertGroups alert groups", "items": { "$ref": "#/definitions/alertGroup" }, @@ -4656,7 +4656,6 @@ "type": "object" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, @@ -4806,7 +4805,6 @@ "type": "array" }, "postableSilence": { - "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment", @@ -4844,7 +4842,6 @@ "type": "object" }, "receiver": { - "description": "Receiver receiver", "properties": { "active": { "description": "active", @@ -6236,9 +6233,9 @@ ], "responses": { "202": { - "description": "GettableGrafanaRule", + "description": "GettableExtendedRuleNode", "schema": { - "$ref": "#/definitions/GettableGrafanaRule" + "$ref": "#/definitions/GettableExtendedRuleNode" } }, "403": { diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index b7c49010b46..c5f511d7a75 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -1292,9 +1292,9 @@ ], "responses": { "202": { - "description": "GettableGrafanaRule", + "description": "GettableExtendedRuleNode", "schema": { - "$ref": "#/definitions/GettableGrafanaRule" + "$ref": "#/definitions/GettableExtendedRuleNode" } }, "403": { @@ -3687,7 +3687,7 @@ "condition": { "type": "string" }, - "dasboardUid": { + "dashboardUid": { "type": "string" }, "data": { @@ -5950,8 +5950,8 @@ } }, "PagerdutyImage": { - "description": "PagerdutyImage is an image", "type": "object", + "title": "PagerdutyImage is an image.", "properties": { "alt": { "type": "string" @@ -5965,8 +5965,8 @@ } }, "PagerdutyLink": { - "description": "PagerdutyLink is a link", "type": "object", + "title": "PagerdutyLink is a link.", "properties": { "href": { "type": "string" @@ -7691,7 +7691,7 @@ } }, "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 the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", + "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\nThe Host field contains the host and port subcomponents of the URL.\nWhen the port is present, it is separated from the host with a colon.\nWhen the host is an IPv6 address, it must be enclosed in square brackets:\n\"[fe80::1]:80\". The [net.JoinHostPort] function combines a host and port\ninto a string suitable for the Host field, adding square brackets to\nthe host when necessary.\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 the [URL.EscapedPath] method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.", "type": "object", "title": "A URL represents a parsed URL (technically, a URI reference).", "properties": { @@ -7757,7 +7757,7 @@ } }, "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.", + "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.", "type": "object" }, "ValidationError": { @@ -7933,7 +7933,6 @@ } }, "alertGroup": { - "description": "AlertGroup alert group", "type": "object", "required": [ "alerts", @@ -7958,6 +7957,7 @@ "$ref": "#/definitions/alertGroup" }, "alertGroups": { + "description": "AlertGroups alert groups", "type": "array", "items": { "$ref": "#/definitions/alertGroup" @@ -8176,7 +8176,6 @@ "$ref": "#/definitions/gettableSilence" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "type": "array", "items": { "$ref": "#/definitions/gettableSilence" @@ -8328,7 +8327,6 @@ } }, "postableSilence": { - "description": "PostableSilence postable silence", "type": "object", "required": [ "comment", @@ -8367,7 +8365,6 @@ "$ref": "#/definitions/postableSilence" }, "receiver": { - "description": "Receiver receiver", "type": "object", "required": [ "active", diff --git a/public/api-merged.json b/public/api-merged.json index 6ece5036ee6..c91b7532803 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -12009,7 +12009,7 @@ "condition": { "type": "string" }, - "dasboardUid": { + "dashboardUid": { "type": "string" }, "data": { @@ -16906,8 +16906,8 @@ } }, "PagerdutyImage": { - "description": "PagerdutyImage is an image", "type": "object", + "title": "PagerdutyImage is an image.", "properties": { "alt": { "type": "string" @@ -16921,8 +16921,8 @@ } }, "PagerdutyLink": { - "description": "PagerdutyLink is a link", "type": "object", + "title": "PagerdutyLink is a link.", "properties": { "href": { "type": "string" @@ -21288,7 +21288,6 @@ } }, "alertGroup": { - "description": "AlertGroup alert group", "type": "object", "required": [ "alerts", @@ -21445,6 +21444,7 @@ } }, "gettableAlert": { + "description": "GettableAlert gettable alert", "type": "object", "required": [ "labels", @@ -21506,7 +21506,6 @@ } }, "gettableSilence": { - "description": "GettableSilence gettable silence", "type": "object", "required": [ "comment", @@ -21555,7 +21554,6 @@ } }, "gettableSilences": { - "description": "GettableSilences gettable silences", "type": "array", "items": { "$ref": "#/definitions/gettableSilence" @@ -21706,6 +21704,7 @@ } }, "postableSilence": { + "description": "PostableSilence postable silence", "type": "object", "required": [ "comment", diff --git a/public/openapi3.json b/public/openapi3.json index edc037de130..a1e76d0e2f4 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -2528,7 +2528,7 @@ "condition": { "type": "string" }, - "dasboardUid": { + "dashboardUid": { "type": "string" }, "data": { @@ -7427,7 +7427,6 @@ "type": "object" }, "PagerdutyImage": { - "description": "PagerdutyImage is an image", "properties": { "alt": { "type": "string" @@ -7439,10 +7438,10 @@ "type": "string" } }, + "title": "PagerdutyImage is an image.", "type": "object" }, "PagerdutyLink": { - "description": "PagerdutyLink is a link", "properties": { "href": { "type": "string" @@ -7451,6 +7450,7 @@ "type": "string" } }, + "title": "PagerdutyLink is a link.", "type": "object" }, "Password": { @@ -11808,7 +11808,6 @@ "type": "object" }, "alertGroup": { - "description": "AlertGroup alert group", "properties": { "alerts": { "description": "alerts", @@ -11965,6 +11964,7 @@ "type": "object" }, "gettableAlert": { + "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/components/schemas/labelSet" @@ -12026,7 +12026,6 @@ "type": "array" }, "gettableSilence": { - "description": "GettableSilence gettable silence", "properties": { "comment": { "description": "comment", @@ -12075,7 +12074,6 @@ "type": "object" }, "gettableSilences": { - "description": "GettableSilences gettable silences", "items": { "$ref": "#/components/schemas/gettableSilence" }, @@ -12226,6 +12224,7 @@ "type": "array" }, "postableSilence": { + "description": "PostableSilence postable silence", "properties": { "comment": { "description": "comment",