diff --git a/Makefile b/Makefile index fb4e6b4611c..c75ddf54aea 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ $(SPEC_TARGET): $(API_DEFINITION_FILES) ## Generate API spec -x "github.com/prometheus/alertmanager" \ -i /grafana/pkg/api/docs/tags.json -swagger-api-spec: gen-go $(SPEC_TARGET) $(MERGED_SPEC_TARGET) +swagger-api-spec: gen-go $(SPEC_TARGET) $(MERGED_SPEC_TARGET) validate-api-spec $(NGALERT_SPEC_TARGET): +$(MAKE) -C pkg/services/ngalert/api/tooling api.json @@ -67,7 +67,7 @@ ensure_go-swagger_mac: -x "github.com/prometheus/alertmanager" \ -i pkg/api/docs/tags.json -swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET) +swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET) validate-api-spec validate-api-spec: $(MERGED_SPEC_TARGET) ## Validate API spec docker run --rm -it \ diff --git a/pkg/api/docs/definitions/annotations.go b/pkg/api/docs/definitions/annotations.go index 019a02acd52..85a1e60333b 100644 --- a/pkg/api/docs/definitions/annotations.go +++ b/pkg/api/docs/definitions/annotations.go @@ -113,7 +113,7 @@ import ( // 401: unauthorisedError // 500: internalServerError -// swagger:parameters updateAnnotation patchAnnotation deleteAnnotation +// swagger:parameters getAnnotation updateAnnotation patchAnnotation deleteAnnotation type AnnotationIDParam struct { // in:path // required:true diff --git a/pkg/api/docs/definitions/datasources.go b/pkg/api/docs/definitions/datasources.go index 728dd8c813d..a7262cf64a9 100644 --- a/pkg/api/docs/definitions/datasources.go +++ b/pkg/api/docs/definitions/datasources.go @@ -334,7 +334,6 @@ import ( // 500: internalServerError // swagger:parameters updateDatasourceByID deleteDatasourceByID getDatasourceByID datasourceProxyGETcalls datasourceProxyPOSTcalls datasourceProxyDELETEcalls -// swagger:parameters enablePermissions disablePermissions getPermissions deletePermissions // swagger:parameters checkDatasourceHealthByID fetchDatasourceResourcesByID type DatasourceID struct { // in:path diff --git a/public/api-merged.json b/public/api-merged.json index 127c27216ae..8b1ceb434a9 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -2258,6 +2258,15 @@ "tags": ["annotations"], "summary": "Get Annotation by Id.", "operationId": "getAnnotation", + "parameters": [ + { + "type": "string", + "x-go-name": "AnnotationID", + "name": "annotation_id", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/getAnnotationResponse" @@ -3809,7 +3818,7 @@ } } }, - "/datasources/{datasource_id}/disable-permissions": { + "/datasources/{datasourceId}/disable-permissions": { "post": { "description": "Disables permissions for the data source with the given id. All existing permissions will be removed and anyone will be able to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3819,7 +3828,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3846,7 +3855,7 @@ } } }, - "/datasources/{datasource_id}/enable-permissions": { + "/datasources/{datasourceId}/enable-permissions": { "post": { "description": "Enables permissions for the data source with the given id.\nNo one except Org Admins will be able to query the data source until permissions have been added\nwhich permit certain users or teams to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3856,7 +3865,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3883,7 +3892,7 @@ } } }, - "/datasources/{datasource_id}/permissions": { + "/datasources/{datasourceId}/permissions": { "get": { "description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3893,7 +3902,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3917,7 +3926,7 @@ } } }, - "/datasources/{datasource_id}/permissions/{permissionId}": { + "/datasources/{datasourceId}/permissions/{permissionId}": { "delete": { "description": "Removes the permission with the given permissionId for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:delete` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3926,15 +3935,15 @@ "parameters": [ { "type": "string", - "x-go-name": "PermissionID", - "name": "permissionId", + "x-go-name": "DatasourceID", + "name": "datasourceId", "in": "path", "required": true }, { "type": "string", - "x-go-name": "DatasourceID", - "name": "id", + "x-go-name": "PermissionID", + "name": "permissionId", "in": "path", "required": true } diff --git a/public/api-spec.json b/public/api-spec.json index 613a959e23b..ed857c22670 100644 --- a/public/api-spec.json +++ b/public/api-spec.json @@ -2258,6 +2258,15 @@ "tags": ["annotations"], "summary": "Get Annotation by Id.", "operationId": "getAnnotation", + "parameters": [ + { + "type": "string", + "x-go-name": "AnnotationID", + "name": "annotation_id", + "in": "path", + "required": true + } + ], "responses": { "200": { "$ref": "#/responses/getAnnotationResponse" @@ -3809,7 +3818,7 @@ } } }, - "/datasources/{datasource_id}/disable-permissions": { + "/datasources/{datasourceId}/disable-permissions": { "post": { "description": "Disables permissions for the data source with the given id. All existing permissions will be removed and anyone will be able to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3819,7 +3828,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3846,7 +3855,7 @@ } } }, - "/datasources/{datasource_id}/enable-permissions": { + "/datasources/{datasourceId}/enable-permissions": { "post": { "description": "Enables permissions for the data source with the given id.\nNo one except Org Admins will be able to query the data source until permissions have been added\nwhich permit certain users or teams to query the data source.\n\nYou need to have a permission with action `datasources.permissions:toggle` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3856,7 +3865,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3883,7 +3892,7 @@ } } }, - "/datasources/{datasource_id}/permissions": { + "/datasources/{datasourceId}/permissions": { "get": { "description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3893,7 +3902,7 @@ { "type": "string", "x-go-name": "DatasourceID", - "name": "id", + "name": "datasourceId", "in": "path", "required": true } @@ -3917,7 +3926,7 @@ } } }, - "/datasources/{datasource_id}/permissions/{permissionId}": { + "/datasources/{datasourceId}/permissions/{permissionId}": { "delete": { "description": "Removes the permission with the given permissionId for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:delete` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], @@ -3926,15 +3935,15 @@ "parameters": [ { "type": "string", - "x-go-name": "PermissionID", - "name": "permissionId", + "x-go-name": "DatasourceID", + "name": "datasourceId", "in": "path", "required": true }, { "type": "string", - "x-go-name": "DatasourceID", - "name": "id", + "x-go-name": "PermissionID", + "name": "permissionId", "in": "path", "required": true }