diff --git a/pkg/api/alertmanager.go b/pkg/api/alertmanager.go index 3803f85812b..78c726b8dc8 100644 --- a/pkg/api/alertmanager.go +++ b/pkg/api/alertmanager.go @@ -9,7 +9,7 @@ import ( "github.com/prometheus/alertmanager/config" ) -// swagger:route POST /api/v1/config alertmanager RoutePostAlertingConfig +// swagger:route POST /api/am/{DatasourceId}/v1/config alertmanager RoutePostAlertingConfig // // sets an Alerting config // @@ -17,7 +17,7 @@ import ( // 201: Ack // 400: ValidationError -// swagger:route GET /api/v1/config alertmanager RouteGetAlertingConfig +// swagger:route GET /api/am/{DatasourceId}/v1/config alertmanager RouteGetAlertingConfig // // gets an Alerting config // @@ -25,7 +25,7 @@ import ( // 200: AlertingConfigResponse // 400: ValidationError -// swagger:route DELETE /api/v1/config alertmanager RouteDeleteAlertingConfig +// swagger:route DELETE /api/am/{DatasourceId}/v1/config alertmanager RouteDeleteAlertingConfig // // deletes the Alerting config for a tenant // @@ -33,7 +33,7 @@ import ( // 200: Ack // 400: ValidationError -// swagger:route GET /api/v1/alerts alertmanager RouteGetAmAlerts +// swagger:route GET /api/am/{DatasourceId}/v1/alerts alertmanager RouteGetAmAlerts // // get alertmanager alerts // @@ -41,7 +41,7 @@ import ( // 200: GettableAlerts // 400: ValidationError -// swagger:route POST /api/v1/alerts alertmanager RoutePostAmAlerts +// swagger:route POST /api/am/{DatasourceId}/v1/alerts alertmanager RoutePostAmAlerts // // create alertmanager alerts // @@ -49,7 +49,7 @@ import ( // 200: Ack // 400: ValidationError -// swagger:route GET /api/v1/alerts/groups alertmanager RouteGetAmAlertGroups +// swagger:route GET /api/am/{DatasourceId}/v1/alerts/groups alertmanager RouteGetAmAlertGroups // // get alertmanager alerts // @@ -57,7 +57,7 @@ import ( // 200: AlertGroups // 400: ValidationError -// swagger:route GET /api/v1/silences alertmanager RouteGetSilences +// swagger:route GET /api/am/{DatasourceId}/v1/silences alertmanager RouteGetSilences // // get silences // @@ -65,7 +65,7 @@ import ( // 200: GettableSilences // 400: ValidationError -// swagger:route POST /api/v1/silences alertmanager RouteCreateSilence +// swagger:route POST /api/am/{DatasourceId}/v1/silences alertmanager RouteCreateSilence // // create silence // @@ -73,7 +73,7 @@ import ( // 201: GettableSilence // 400: ValidationError -// swagger:route GET /api/v1/silence/{SilenceId} alertmanager RouteGetSilence +// swagger:route GET /api/am/{DatasourceId}/v1/silence/{SilenceId} alertmanager RouteGetSilence // // get silence // @@ -81,7 +81,7 @@ import ( // 200: GettableSilence // 400: ValidationError -// swagger:route DELETE /api/v1/silence/{SilenceId} alertmanager RouteDeleteSilence +// swagger:route DELETE /api/am/{DatasourceId}/v1/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 65ee2767eac..291d723739b 100644 --- a/spec.json +++ b/spec.json @@ -16,7 +16,7 @@ }, "basePath": "/api/v1", "paths": { - "/api/v1/alerts": { + "/api/am/{DatasourceId}/v1/alerts": { "get": { "description": "get alertmanager alerts", "tags": [ @@ -64,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": { @@ -97,6 +103,12 @@ "$ref": "#/definitions/postableAlert" } } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -115,7 +127,7 @@ } } }, - "/api/v1/alerts/groups": { + "/api/am/{DatasourceId}/v1/alerts/groups": { "get": { "description": "get alertmanager alerts", "tags": [ @@ -163,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": { @@ -181,13 +199,21 @@ } } }, - "/api/v1/config": { + "/api/am/{DatasourceId}/v1/config": { "get": { "description": "gets an Alerting config", "tags": [ "alertmanager" ], "operationId": "RouteGetAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "AlertingConfigResponse", @@ -216,6 +242,12 @@ "schema": { "$ref": "#/definitions/UserConfig" } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -239,6 +271,14 @@ "alertmanager" ], "operationId": "RouteDeleteAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "Ack", @@ -255,6 +295,139 @@ } } }, + "/api/am/{DatasourceId}/v1/silence/{SilenceId}": { + "get": { + "description": "get silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/GettableSilence" + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "delete silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/api/am/{DatasourceId}/v1/silences": { + "get": { + "description": "get silences", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilences", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableSilences", + "schema": { + "$ref": "#/definitions/GettableSilences" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "create silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteCreateSilence", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/SilenceBody" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "$ref": "#/responses/GettableSilence" + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, "/api/v1/namespace/{Namespace}/permissions": { "get": { "description": "sets an Alerting config", @@ -569,113 +742,6 @@ } } }, - "/api/v1/silence/{SilenceId}": { - "get": { - "description": "get silence", - "tags": [ - "alertmanager" - ], - "operationId": "RouteGetSilence", - "parameters": [ - { - "type": "string", - "name": "SilenceId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/GettableSilence" - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - }, - "delete": { - "description": "delete silence", - "tags": [ - "alertmanager" - ], - "operationId": "RouteDeleteSilence", - "parameters": [ - { - "type": "string", - "name": "SilenceId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Ack", - "schema": { - "$ref": "#/definitions/Ack" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - } - }, - "/api/v1/silences": { - "get": { - "description": "get silences", - "tags": [ - "alertmanager" - ], - "operationId": "RouteGetSilences", - "responses": { - "200": { - "description": "GettableSilences", - "schema": { - "$ref": "#/definitions/GettableSilences" - } - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - }, - "post": { - "description": "create silence", - "tags": [ - "alertmanager" - ], - "operationId": "RouteCreateSilence", - "parameters": [ - { - "name": "Body", - "in": "body", - "schema": { - "$ref": "#/definitions/SilenceBody" - } - } - ], - "responses": { - "201": { - "$ref": "#/responses/GettableSilence" - }, - "400": { - "description": "ValidationError", - "schema": { - "$ref": "#/definitions/ValidationError" - } - } - } - } - }, "/api/v1/status/alerts": { "get": { "description": "gets the current alerts", @@ -2378,7 +2444,7 @@ }, "id": { "type": "string", - "x-go-name": "Idd" + "x-go-name": "Id" }, "matchers": { "$ref": "#/definitions/matchers" @@ -2631,9 +2697,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" @@ -2666,7 +2731,7 @@ "$ref": "#/definitions/Userinfo" } }, - "x-go-package": "net/url" + "x-go-package": "github.com/prometheus/common/config" }, "UpdateDashboardAclCommand": { "type": "object",