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)
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 $@

View File

@ -1,4 +1,8 @@
{
"basePath": "/api/v1",
"consumes": [
"application/json"
],
"definitions": {
"Ack": {
"type": "object",
@ -136,6 +140,11 @@
},
"AlertQuery": {
"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",
@ -575,8 +584,12 @@
"Failure": {
"$ref": "#/definitions/ResponseDetails"
},
"GettableAlert": {},
"GettableAlerts": {},
"GettableAlert": {
"$ref": "#/definitions/gettableAlert"
},
"GettableAlerts": {
"$ref": "#/definitions/gettableAlerts"
},
"GettableApiAlertingConfig": {
"properties": {
"global": {
@ -843,7 +856,9 @@
"GettableSilence": {
"$ref": "#/definitions/gettableSilence"
},
"GettableSilences": {},
"GettableSilences": {
"$ref": "#/definitions/gettableSilences"
},
"GettableUserConfig": {
"properties": {
"alertmanager_config": {
@ -2395,7 +2410,7 @@
"alerts": {
"description": "alerts",
"items": {
"$ref": "#/definitions/GettableAlert"
"$ref": "#/definitions/gettableAlert"
},
"type": "array",
"x-go-name": "Alerts"
@ -2609,7 +2624,7 @@
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/GettableAlert"
"$ref": "#/definitions/gettableAlert"
},
"type": "array",
"x-go-name": "GettableAlerts",
@ -3151,7 +3166,7 @@
"200": {
"description": "AlertGroups",
"schema": {
"$ref": "#/definitions/AlertGroups"
"$ref": "#/definitions/alertGroups"
}
},
"400": {
@ -3266,7 +3281,7 @@
"200": {
"description": "GettableSilences",
"schema": {
"$ref": "#/definitions/GettableSilences"
"$ref": "#/definitions/gettableSilences"
}
},
"400": {
@ -3804,5 +3819,17 @@
}
}
},
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"securityDefinitions": {
"basic": {
"type": "basic"
}
},
"swagger": "2.0"
}

View File

@ -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"
}
}
}

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 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.