Alerting: Receivers API (read only endpoints) (#81751)

* Add single receiver method

* Add receiver permissions

* Add single/multi GET endpoints for receivers

* Remove stable tag from time intervals

See end of PR description here: https://github.com/grafana/grafana/pull/81672
This commit is contained in:
William Wernert
2024-02-05 20:12:15 +02:00
committed by GitHub
parent 49b49e28af
commit 2ab7d3c725
23 changed files with 971 additions and 340 deletions
+17 -59
View File
@@ -4511,7 +4511,6 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -4535,7 +4534,6 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
@@ -4695,13 +4693,13 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -4750,6 +4748,7 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
@@ -4900,7 +4899,6 @@
"type": "array"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -5057,61 +5055,6 @@
"version": "1.1.0"
},
"paths": {
"/v1/notifications/time-intervals": {
"get": {
"description": "Get all the time intervals",
"operationId": "RouteNotificationsGetTimeIntervals",
"responses": {
"200": {
"$ref": "#/responses/GetAllIntervalsResponse"
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
},
"tags": [
"notifications"
]
}
},
"/v1/notifications/time-intervals/{name}": {
"get": {
"operationId": "RouteNotificationsGetTimeInterval",
"parameters": [
{
"description": "Time interval name",
"in": "path",
"name": "name",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"$ref": "#/responses/GetIntervalsByNameResponse"
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"summary": "Get a time interval by name.",
"tags": [
"notifications"
]
}
},
"/v1/provisioning/alert-rules": {
"get": {
"operationId": "RouteGetAlertRules",
@@ -6168,6 +6111,21 @@
"$ref": "#/definitions/GettableTimeIntervals"
}
},
"GetReceiverResponse": {
"description": "",
"schema": {
"$ref": "#/definitions/GettableApiReceiver"
}
},
"GetReceiversResponse": {
"description": "",
"schema": {
"items": {
"$ref": "#/definitions/GettableApiReceiver"
},
"type": "array"
}
},
"GettableHistoricUserConfigs": {
"description": "",
"schema": {
@@ -0,0 +1,56 @@
package definitions
// swagger:route GET /v1/notifications/receivers/{Name} notifications RouteGetReceiver
//
// Get a receiver by name.
//
// Responses:
// 200: GetReceiverResponse
// 403: PermissionDenied
// 404: NotFound
// swagger:route GET /v1/notifications/receivers notifications RouteGetReceivers
//
// Get all receivers.
//
// Responses:
// 200: GetReceiversResponse
// 403: PermissionDenied
// swagger:parameters RouteGetReceiver
type GetReceiverParams struct {
// in:path
// required: true
Name string `json:"name"`
// in:query
// required: false
Decrypt bool `json:"decrypt"`
}
// swagger:parameters RouteGetReceivers
type GetReceiversParams struct {
// in:query
// required: false
Names []string `json:"names"`
// in:query
// required: false
Limit int `json:"limit"`
// in:query
// required: false
Offset int `json:"offset"`
// in:query
// required: false
Decrypt bool `json:"decrypt"`
}
// swagger:response GetReceiverResponse
type GetReceiverResponse struct {
// in:body
Body GettableApiReceiver
}
// swagger:response GetReceiversResponse
type GetReceiversResponse struct {
// in:body
Body []GettableApiReceiver
}
@@ -1,6 +1,6 @@
package definitions
// swagger:route GET /v1/notifications/time-intervals notifications stable RouteNotificationsGetTimeIntervals
// swagger:route GET /v1/notifications/time-intervals notifications RouteNotificationsGetTimeIntervals
//
// Get all the time intervals
//
@@ -8,7 +8,7 @@ package definitions
// 200: GetAllIntervalsResponse
// 403: ForbiddenError
// swagger:route GET /v1/notifications/time-intervals/{name} notifications stable RouteNotificationsGetTimeInterval
// swagger:route GET /v1/notifications/time-intervals/{name} notifications RouteNotificationsGetTimeInterval
//
// Get a time interval by name.
//
@@ -17,7 +17,7 @@ package definitions
// 404: NotFound
// 403: ForbiddenError
// swagger:parameters stable RouteNotificationsGetTimeInterval
// swagger:parameters RouteNotificationsGetTimeInterval
type RouteTimeIntervalNameParam struct {
// Time interval name
// in:path
+98 -3
View File
@@ -4512,7 +4512,6 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -4536,6 +4535,7 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
@@ -4640,6 +4640,7 @@
"type": "object"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -4701,7 +4702,6 @@
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -4756,6 +4756,7 @@
"type": "array"
},
"integration": {
"description": "Integration integration",
"properties": {
"lastNotifyAttempt": {
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
@@ -4936,7 +4937,6 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",
@@ -7046,6 +7046,86 @@
]
}
},
"/v1/notifications/receivers": {
"get": {
"operationId": "RouteGetReceivers",
"parameters": [
{
"in": "query",
"items": {
"type": "string"
},
"name": "names",
"type": "array"
},
{
"format": "int64",
"in": "query",
"name": "limit",
"type": "integer"
},
{
"format": "int64",
"in": "query",
"name": "offset",
"type": "integer"
},
{
"in": "query",
"name": "decrypt",
"type": "boolean"
}
],
"responses": {
"200": {
"$ref": "#/responses/GetReceiversResponse"
},
"403": {
"description": "PermissionDenied",
"schema": {
"$ref": "#/definitions/PermissionDenied"
}
}
},
"summary": "Get all receivers.",
"tags": [
"notifications"
]
}
},
"/v1/notifications/receivers/{Name}": {
"get": {
"operationId": "RouteGetReceiver",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"type": "string"
},
{
"in": "query",
"name": "decrypt",
"type": "boolean"
}
],
"responses": {
"200": {
"$ref": "#/responses/GetReceiverResponse"
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"summary": "Get a receiver by name.",
"tags": [
"notifications"
]
}
},
"/v1/notifications/time-intervals": {
"get": {
"description": "Get all the time intervals",
@@ -8507,6 +8587,21 @@
"$ref": "#/definitions/GettableTimeIntervals"
}
},
"GetReceiverResponse": {
"description": "",
"schema": {
"$ref": "#/definitions/GettableApiReceiver"
}
},
"GetReceiversResponse": {
"description": "",
"schema": {
"items": {
"$ref": "#/definitions/GettableApiReceiver"
},
"type": "array"
}
},
"GettableHistoricUserConfigs": {
"description": "",
"schema": {
+100 -7
View File
@@ -2007,12 +2007,91 @@
}
}
},
"/v1/notifications/receivers": {
"get": {
"tags": [
"notifications"
],
"summary": "Get all receivers.",
"operationId": "RouteGetReceivers",
"parameters": [
{
"type": "array",
"items": {
"type": "string"
},
"name": "names",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "offset",
"in": "query"
},
{
"type": "boolean",
"name": "decrypt",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/GetReceiversResponse"
},
"403": {
"description": "PermissionDenied",
"schema": {
"$ref": "#/definitions/PermissionDenied"
}
}
}
}
},
"/v1/notifications/receivers/{Name}": {
"get": {
"tags": [
"notifications"
],
"summary": "Get a receiver by name.",
"operationId": "RouteGetReceiver",
"parameters": [
{
"type": "string",
"name": "name",
"in": "path",
"required": true
},
{
"type": "boolean",
"name": "decrypt",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/GetReceiverResponse"
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
}
}
},
"/v1/notifications/time-intervals": {
"get": {
"description": "Get all the time intervals",
"tags": [
"notifications",
"stable"
"notifications"
],
"operationId": "RouteNotificationsGetTimeIntervals",
"responses": {
@@ -2031,8 +2110,7 @@
"/v1/notifications/time-intervals/{name}": {
"get": {
"tags": [
"notifications",
"stable"
"notifications"
],
"summary": "Get a time interval by name.",
"operationId": "RouteNotificationsGetTimeInterval",
@@ -7994,7 +8072,6 @@
}
},
"alertGroup": {
"description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@@ -8019,6 +8096,7 @@
"$ref": "#/definitions/alertGroup"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"type": "array",
"items": {
"$ref": "#/definitions/alertGroup"
@@ -8124,6 +8202,7 @@
}
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"type": "object",
"required": [
"labels",
@@ -8187,7 +8266,6 @@
"$ref": "#/definitions/gettableAlerts"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"type": "object",
"required": [
"comment",
@@ -8244,6 +8322,7 @@
"$ref": "#/definitions/gettableSilences"
},
"integration": {
"description": "Integration integration",
"type": "object",
"required": [
"name",
@@ -8426,7 +8505,6 @@
"$ref": "#/definitions/postableSilence"
},
"receiver": {
"description": "Receiver receiver",
"type": "object",
"required": [
"active",
@@ -8557,6 +8635,21 @@
"$ref": "#/definitions/GettableTimeIntervals"
}
},
"GetReceiverResponse": {
"description": "",
"schema": {
"$ref": "#/definitions/GettableApiReceiver"
}
},
"GetReceiversResponse": {
"description": "",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/GettableApiReceiver"
}
}
},
"GettableHistoricUserConfigs": {
"description": "",
"schema": {