diff --git a/pkg/api/alertmanager.go b/pkg/api/alertmanager.go index 83bf1282935..9d3f17025b6 100644 --- a/pkg/api/alertmanager.go +++ b/pkg/api/alertmanager.go @@ -9,7 +9,7 @@ import ( "github.com/prometheus/alertmanager/config" ) -// swagger:route POST /alertmanager/api/v1/config alertmanager RoutePostAlertingConfig +// swagger:route POST /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager RoutePostAlertingConfig // // sets an Alerting config // @@ -17,7 +17,7 @@ import ( // 201: Ack // 400: ValidationError -// swagger:route GET /alertmanager/api/v1/config alertmanager RouteGetAlertingConfig +// swagger:route GET /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager RouteGetAlertingConfig // // gets an Alerting config // @@ -25,7 +25,7 @@ import ( // 200: AlertingConfigResponse // 400: ValidationError -// swagger:route DELETE /alertmanager/api/v1/config alertmanager RouteDeleteAlertingConfig +// swagger:route DELETE /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager RouteDeleteAlertingConfig // // deletes the Alerting config for a tenant // @@ -33,7 +33,7 @@ import ( // 200: Ack // 400: ValidationError -// swagger:route GET /alertmanager/api/v2/alerts alertmanager RouteGetAmAlerts +// swagger:route GET /alertmanager/{DatasourceId}/api/v2/alerts alertmanager RouteGetAmAlerts // // get alertmanager alerts // @@ -41,7 +41,7 @@ import ( // 200: GettableAlerts // 400: ValidationError -// swagger:route POST /alertmanager/api/v2/alerts alertmanager RoutePostAmAlerts +// swagger:route POST /alertmanager/{DatasourceId}/api/v2/alerts alertmanager RoutePostAmAlerts // // create alertmanager alerts // @@ -49,7 +49,7 @@ import ( // 200: Ack // 400: ValidationError -// swagger:route GET /alertmanager/api/v2/alerts/groups alertmanager RouteGetAmAlertGroups +// swagger:route GET /alertmanager/{DatasourceId}/api/v2/alerts/groups alertmanager RouteGetAmAlertGroups // // get alertmanager alerts // @@ -57,7 +57,7 @@ import ( // 200: AlertGroups // 400: ValidationError -// swagger:route GET /alertmanager/api/v2/silences alertmanager RouteGetSilences +// swagger:route GET /alertmanager/{DatasourceId}/api/v2/silences alertmanager RouteGetSilences // // get silences // @@ -65,7 +65,7 @@ import ( // 200: GettableSilences // 400: ValidationError -// swagger:route POST /alertmanager/api/v2/silences alertmanager RouteCreateSilence +// swagger:route POST /alertmanager/{DatasourceId}/api/v2/silences alertmanager RouteCreateSilence // // create silence // @@ -73,7 +73,7 @@ import ( // 201: GettableSilence // 400: ValidationError -// swagger:route GET /alertmanager/api/v2/silence/{SilenceId} alertmanager RouteGetSilence +// swagger:route GET /alertmanager/{DatasourceId}/api/v2/silence/{SilenceId} alertmanager RouteGetSilence // // get silence // @@ -81,7 +81,7 @@ import ( // 200: GettableSilence // 400: ValidationError -// swagger:route DELETE /alertmanager/api/v2/silence/{SilenceId} alertmanager RouteDeleteSilence +// swagger:route DELETE /alertmanager/{DatasourceId}/api/v2/silence/{SilenceId} alertmanager RouteDeleteSilence // // delete silence // @@ -103,7 +103,7 @@ type GetDeleteSilenceParams struct { // swagger:model type SilenceBody struct { - Idd string `json:"id"` + Id string `json:"id"` amv2.Silence } @@ -160,6 +160,12 @@ type BodyAlertingConfig struct { Body UserConfig } +// swagger:parameters RoutePostAlertingConfig RouteGetAlertingConfig RouteDeleteAlertingConfig RouteGetAmAlerts RoutePostAmAlerts RouteGetAmAlertGroups RouteGetSilences RouteCreateSilence RouteGetSilence RouteDeleteSilence RoutePostAlertingConfig +type DatasourceReference struct { + // in:path + DatasourceId string +} + // swagger:model type UserConfig struct { TemplateFiles map[string]string `yaml:"template_files" json:"template_files"` diff --git a/spec.json b/spec.json index 9942fe95f42..b631bbb6280 100644 --- a/spec.json +++ b/spec.json @@ -16,81 +16,7 @@ }, "basePath": "/api/v1", "paths": { - "/alertmanager/api/v1/config": { - "get": { - "description": "gets an Alerting config", - "tags": [ - "alertmanager" - ], - "operationId": "RouteGetAlertingConfig", - "responses": { - "200": { - "description": "AlertingConfigResponse", - "schema": { - "$ref": "#/definitions/AlertingConfigResponse" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - }, - "post": { - "description": "sets an Alerting config", - "tags": [ - "alertmanager" - ], - "operationId": "RoutePostAlertingConfig", - "parameters": [ - { - "name": "Body", - "in": "body", - "schema": { - "$ref": "#/definitions/UserConfig" - } - } - ], - "responses": { - "201": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - }, - "delete": { - "description": "deletes the Alerting config for a tenant", - "tags": [ - "alertmanager" - ], - "operationId": "RouteDeleteAlertingConfig", - "responses": { - "200": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - } - }, - "/alertmanager/api/v2/alerts": { + "/alertmanager/{DatasourceId}/api/v2/alerts": { "get": { "description": "get alertmanager alerts", "tags": [ @@ -138,6 +64,12 @@ "description": "A list of receivers to filter alerts by", "name": "receivers", "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -171,6 +103,12 @@ "$ref": "#/definitions/postableAlert" } } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -189,7 +127,7 @@ } } }, - "/alertmanager/api/v2/alerts/groups": { + "/alertmanager/{DatasourceId}/api/v2/alerts/groups": { "get": { "description": "get alertmanager alerts", "tags": [ @@ -237,6 +175,12 @@ "description": "A list of receivers to filter alerts by", "name": "receivers", "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -255,7 +199,7 @@ } } }, - "/alertmanager/api/v2/silence/{SilenceId}": { + "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}": { "get": { "description": "get silence", "tags": [ @@ -268,6 +212,12 @@ "name": "SilenceId", "in": "path", "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -297,6 +247,12 @@ "name": "SilenceId", "in": "path", "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -315,13 +271,21 @@ } } }, - "/alertmanager/api/v2/silences": { + "/alertmanager/{DatasourceId}/api/v2/silences": { "get": { "description": "get silences", "tags": [ "alertmanager" ], "operationId": "RouteGetSilences", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "GettableSilences", @@ -350,6 +314,12 @@ "schema": { "$ref": "#/definitions/SilenceBody" } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -368,6 +338,102 @@ } } }, + "/alertmanager/{DatasourceId}/config/api/v1/alerts": { + "get": { + "description": "gets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertingConfigResponse", + "schema": { + "$ref": "#/definitions/AlertingConfigResponse" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "sets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RoutePostAlertingConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/UserConfig" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "deletes the Alerting config for a tenant", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, "/api/v1/namespace/{Namespace}/permissions": { "get": { "description": "sets an Alerting config", @@ -2384,7 +2450,7 @@ }, "id": { "type": "string", - "x-go-name": "Idd" + "x-go-name": "Id" }, "matchers": { "$ref": "#/definitions/matchers" @@ -2637,9 +2703,8 @@ "x-go-package": "github.com/grafana/alerting-api/pkg/api" }, "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" @@ -2672,7 +2737,7 @@ "$ref": "#/definitions/Userinfo" } }, - "x-go-package": "net/url" + "x-go-package": "github.com/prometheus/common/config" }, "UpdateDashboardAclCommand": { "type": "object",