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>
pull/33436/head
Kyle Brandt 4 years ago committed by GitHub
parent 2466565862
commit adcba36d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/services/ngalert/api/tooling/Makefile
  2. 7525
      pkg/services/ngalert/api/tooling/post.json
  3. 34
      pkg/services/ngalert/api/tooling/spec.json
  4. 1
      pkg/services/ngalert/models/alert_query.go

@ -4,7 +4,9 @@ API_DIR = definitions
GO_PKG_FILES = $(shell find $(API_DIR) -name *.go -print)
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
go run cmd/clean-swagger/main.go -if $(<) -of $@

File diff suppressed because it is too large Load Diff

@ -1,4 +1,14 @@
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"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": {
"description": "AlertGroups",
"schema": {
"$ref": "#/definitions/AlertGroups"
"$ref": "#/definitions/alertGroups"
}
},
"400": {
@ -295,7 +305,7 @@
"200": {
"description": "GettableSilences",
"schema": {
"$ref": "#/definitions/GettableSilences"
"$ref": "#/definitions/gettableSilences"
}
},
"400": {
@ -971,6 +981,11 @@
"type": "object",
"title": "AlertQuery represents a single query associated with an alert definition.",
"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": {
"description": "JSON is the raw JSON query and includes the above properties as well as custom properties.",
"type": "object",
@ -1415,7 +1430,7 @@
"$ref": "#/definitions/gettableAlert"
},
"GettableAlerts": {
"$ref": "#/definitions/GettableAlerts"
"$ref": "#/definitions/gettableAlerts"
},
"GettableApiAlertingConfig": {
"type": "object",
@ -1681,10 +1696,10 @@
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"GettableSilence": {
"$ref": "#/definitions/GettableSilence"
"$ref": "#/definitions/gettableSilence"
},
"GettableSilences": {
"$ref": "#/definitions/GettableSilences"
"$ref": "#/definitions/gettableSilences"
},
"GettableUserConfig": {
"type": "object",
@ -3247,7 +3262,7 @@
"description": "alerts",
"type": "array",
"items": {
"$ref": "#/definitions/GettableAlert"
"$ref": "#/definitions/gettableAlert"
},
"x-go-name": "Alerts"
},
@ -3455,7 +3470,7 @@
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/GettableAlert"
"$ref": "#/definitions/gettableAlert"
},
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
@ -3818,5 +3833,10 @@
"x-go-name": "VersionInfo",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}
},
"securityDefinitions": {
"basic": {
"type": "basic"
}
}
}

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

Loading…
Cancel
Save