Alerting: Add method to provisioning API for obtaining a group and its rules (#51398) (#51761)

* Generate shell for new route

* Propagate path parameters

* Implement route logic

* Add a couple simple tests

* Use NotFound error for not found, avoid returning pointer

* Regenerate

(cherry picked from commit b9c7eb1380)
This commit is contained in:
Alexander Weaver
2022-07-05 12:47:41 -05:00
committed by GitHub
parent 7955efc62f
commit 96c7f6e9ed
10 changed files with 251 additions and 70 deletions
+48 -24
View File
@@ -355,7 +355,7 @@
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertRuleGroup": {
"AlertRuleGroupMetadata": {
"properties": {
"interval": {
"format": "int64",
@@ -3373,6 +3373,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -3394,17 +3395,14 @@
"labels",
"receiver"
],
"type": "object",
"x-go-name": "AlertGroup",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
"type": "array",
"x-go-name": "AlertGroups",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "array"
},
"alertStatus": {
"description": "AlertStatus alert status",
@@ -3524,6 +3522,7 @@
"$ref": "#/definitions/Duration"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -3582,20 +3581,16 @@
"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",
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3647,7 +3642,9 @@
"status",
"updatedAt"
],
"type": "object"
"type": "object",
"x-go-name": "GettableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
@@ -3783,6 +3780,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3822,11 +3820,10 @@
"matchers",
"startsAt"
],
"type": "object",
"x-go-name": "PostableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"name": {
"description": "name",
@@ -3837,9 +3834,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",
@@ -4195,6 +4190,35 @@
}
},
"/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}": {
"get": {
"operationId": "RouteGetAlertRuleGroup",
"parameters": [
{
"in": "path",
"name": "FolderUID",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "Group",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"$ref": "#/responses/AlertRuleGroup"
},
"404": {
"description": " Not found."
}
},
"summary": "Get a rule group.",
"tags": [
"provisioning"
]
},
"put": {
"consumes": [
"application/json"
@@ -4217,15 +4241,15 @@
"in": "body",
"name": "Body",
"schema": {
"$ref": "#/definitions/AlertRuleGroup"
"$ref": "#/definitions/AlertRuleGroupMetadata"
}
}
],
"responses": {
"200": {
"description": "AlertRuleGroup",
"description": "AlertRuleGroupMetadata",
"schema": {
"$ref": "#/definitions/AlertRuleGroup"
"$ref": "#/definitions/AlertRuleGroupMetadata"
}
},
"400": {