AlertingAPI: update swagger json files match datasourceUid change (#33332)

* update swagger json files match datasourceUid change
underlying change made in https://github.com/grafana/grafana/pull/33282
* Document DatasourceUID field in AlertQuery model
* Run spec generation from inside a docker container
* Generate latest spec

Co-authored-by: Sofia Papagiannaki <sofia@grafana.com>
This commit is contained in:
Kyle Brandt 2021-04-27 10:50:30 -04:00 committed by GitHub
parent 2466565862
commit adcba36d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3845 additions and 3795 deletions

View File

@ -4,7 +4,9 @@ API_DIR = definitions
GO_PKG_FILES = $(shell find $(API_DIR) -name *.go -print) GO_PKG_FILES = $(shell find $(API_DIR) -name *.go -print)
spec.json: $(GO_PKG_FILES) spec.json: $(GO_PKG_FILES)
swagger generate spec -m -w $(API_DIR) -o $@ # this is slow because this image does not use the cache
# https://github.com/go-swagger/go-swagger/blob/v0.27.0/Dockerfile#L5
docker run --rm -it -e GOPATH=${GOPATH} -v ${GOPATH}:${GOPATH} -w $$(pwd) go-swagger generate spec -m -o $@
post.json: spec.json post.json: spec.json
go run cmd/clean-swagger/main.go -if $(<) -of $@ go run cmd/clean-swagger/main.go -if $(<) -of $@

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,14 @@
{ {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "Package definitions includes the types required for generating or consuming an OpenAPI\nspec for the Unified Alerting API.\nDocumentation of the API.", "description": "Package definitions includes the types required for generating or consuming an OpenAPI\nspec for the Unified Alerting API.\nDocumentation of the API.",
@ -180,7 +190,7 @@
"200": { "200": {
"description": "AlertGroups", "description": "AlertGroups",
"schema": { "schema": {
"$ref": "#/definitions/AlertGroups" "$ref": "#/definitions/alertGroups"
} }
}, },
"400": { "400": {
@ -295,7 +305,7 @@
"200": { "200": {
"description": "GettableSilences", "description": "GettableSilences",
"schema": { "schema": {
"$ref": "#/definitions/GettableSilences" "$ref": "#/definitions/gettableSilences"
} }
}, },
"400": { "400": {
@ -971,6 +981,11 @@
"type": "object", "type": "object",
"title": "AlertQuery represents a single query associated with an alert definition.", "title": "AlertQuery represents a single query associated with an alert definition.",
"properties": { "properties": {
"datasourceUid": {
"description": "Grafana data source unique identifer; it should be '-100' for a Server Side Expression operation.",
"type": "string",
"x-go-name": "DatasourceUID"
},
"model": { "model": {
"description": "JSON is the raw JSON query and includes the above properties as well as custom properties.", "description": "JSON is the raw JSON query and includes the above properties as well as custom properties.",
"type": "object", "type": "object",
@ -1415,7 +1430,7 @@
"$ref": "#/definitions/gettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"GettableAlerts": { "GettableAlerts": {
"$ref": "#/definitions/GettableAlerts" "$ref": "#/definitions/gettableAlerts"
}, },
"GettableApiAlertingConfig": { "GettableApiAlertingConfig": {
"type": "object", "type": "object",
@ -1681,10 +1696,10 @@
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
}, },
"GettableSilence": { "GettableSilence": {
"$ref": "#/definitions/GettableSilence" "$ref": "#/definitions/gettableSilence"
}, },
"GettableSilences": { "GettableSilences": {
"$ref": "#/definitions/GettableSilences" "$ref": "#/definitions/gettableSilences"
}, },
"GettableUserConfig": { "GettableUserConfig": {
"type": "object", "type": "object",
@ -3247,7 +3262,7 @@
"description": "alerts", "description": "alerts",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/GettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"x-go-name": "Alerts" "x-go-name": "Alerts"
}, },
@ -3455,7 +3470,7 @@
"description": "GettableAlerts gettable alerts", "description": "GettableAlerts gettable alerts",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/GettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"x-go-name": "GettableAlerts", "x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
@ -3818,5 +3833,10 @@
"x-go-name": "VersionInfo", "x-go-name": "VersionInfo",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
} }
},
"securityDefinitions": {
"basic": {
"type": "basic"
}
} }
} }

View File

@ -68,6 +68,7 @@ type AlertQuery struct {
// RelativeTimeRange is the relative Start and End of the query as sent by the frontend. // RelativeTimeRange is the relative Start and End of the query as sent by the frontend.
RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"` RelativeTimeRange RelativeTimeRange `json:"relativeTimeRange"`
// Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation.
DatasourceUID string `json:"datasourceUid"` DatasourceUID string `json:"datasourceUid"`
// JSON is the raw JSON query and includes the above properties as well as custom properties. // JSON is the raw JSON query and includes the above properties as well as custom properties.