diff --git a/docs/sources/developer-resources/api-reference/http-api/dashboard_versions.md b/docs/sources/developer-resources/api-reference/http-api/dashboard_versions.md index f4b46adad3f..370b1fed7e4 100644 --- a/docs/sources/developer-resources/api-reference/http-api/dashboard_versions.md +++ b/docs/sources/developer-resources/api-reference/http-api/dashboard_versions.md @@ -171,146 +171,3 @@ Status Codes: - **200** - Ok - **401** - Unauthorized - **404** - Dashboard version not found - -## Restore dashboard by dashboard UID - -`POST /api/dashboards/uid/:uid/restore` - -Restores a dashboard to a given dashboard version using `uid`. - -**Example request for restoring a dashboard version**: - -```http -POST /api/dashboards/uid/QA7wKklGz/restore -Accept: application/json -Content-Type: application/json -Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk - -{ - "version": 1 -} -``` - -JSON body schema: - -- **version** - The dashboard version to restore to - -**Example response**: - -```http -HTTP/1.1 200 OK -Content-Type: application/json; charset=UTF-8 -Content-Length: 67 - -{ - "id": 70, - "slug": "my-dashboard", - "status": "success", - "uid": "QA7wKklGz", - "url": "/d/QA7wKklGz/my-dashboard", - "version": 3 -} -``` - -JSON response body schema: - -- **slug** - the URL friendly slug of the dashboard's title -- **status** - whether the restoration was successful or not -- **version** - the new dashboard version, following the restoration - -Status codes: - -- **200** - OK -- **400** - Bad request (specified version has the same content as the current dashboard) -- **401** - Unauthorized -- **404** - Not found (dashboard not found or dashboard version not found) -- **500** - Internal server error (indicates issue retrieving dashboard tags from database) - -**Example error response** - -```http -HTTP/1.1 404 Not Found -Content-Type: application/json; charset=UTF-8 -Content-Length: 46 - -{ - "message": "Dashboard version not found" -} -``` - -JSON response body schema: - -- **message** - Message explaining the reason for the request failure. - -## Compare dashboard versions - -`POST /api/dashboards/calculate-diff` - -Compares two dashboard versions by calculating the JSON diff of them. - -**Example request**: - -```http -POST /api/dashboards/calculate-diff HTTP/1.1 -Accept: text/html -Content-Type: application/json -Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk - -{ - "base": { - "dashboardId": 1, - "version": 1 - }, - "new": { - "dashboardId": 1, - "version": 2 - }, - "diffType": "json" -} -``` - -JSON body schema: - -- **base** - an object representing the base dashboard version -- **new** - an object representing the new dashboard version -- **diffType** - the type of diff to return. Can be "json" or "basic". - -**Example response (JSON diff)**: - -```http -HTTP/1.1 200 OK -Content-Type: text/html; charset=UTF-8 - -

- -

-``` - -The response is a textual representation of the diff, with the dashboard values being in JSON, similar to the diffs seen on sites like GitHub or GitLab. - -Status Codes: - -- **200** - Ok -- **400** - Bad request (invalid JSON sent) -- **401** - Unauthorized -- **404** - Not found - -**Example response (basic diff)**: - -```http -HTTP/1.1 200 OK -Content-Type: text/html; charset=UTF-8 - -
- -
-``` - -The response here is a summary of the changes, derived from the diff between the two JSON objects. - -Status Codes: - -- **200** - OK -- **400** - Bad request (invalid JSON sent) -- **401** - Unauthorized -- **404** - Not found diff --git a/packages/grafana-api-clients/src/clients/rtkq/legacy/endpoints.gen.ts b/packages/grafana-api-clients/src/clients/rtkq/legacy/endpoints.gen.ts index 4ceed793cad..0fbbb9cddc9 100644 --- a/packages/grafana-api-clients/src/clients/rtkq/legacy/endpoints.gen.ts +++ b/packages/grafana-api-clients/src/clients/rtkq/legacy/endpoints.gen.ts @@ -727,17 +727,6 @@ const injectedRtkApi = api }), invalidatesTags: ['dashboards', 'permissions'], }), - restoreDashboardVersionByUid: build.mutation< - RestoreDashboardVersionByUidApiResponse, - RestoreDashboardVersionByUidApiArg - >({ - query: (queryArg) => ({ - url: `/dashboards/uid/${queryArg.uid}/restore`, - method: 'POST', - body: queryArg.restoreDashboardVersionCommand, - }), - invalidatesTags: ['dashboards', 'versions'], - }), getDashboardVersionsByUid: build.query({ query: (queryArg) => ({ url: `/dashboards/uid/${queryArg.uid}/versions`, @@ -2628,26 +2617,6 @@ export type UpdateDashboardPermissionsByUidApiArg = { uid: string; updateDashboardAclCommand: UpdateDashboardAclCommand; }; -export type RestoreDashboardVersionByUidApiResponse = /** status 200 (empty) */ { - /** FolderUID The unique identifier (uid) of the folder the dashboard belongs to. */ - folderUid?: string; - /** ID The unique identifier (id) of the created/updated dashboard. */ - id: number; - /** Status status of the response. */ - status: string; - /** Slug The slug of the dashboard. */ - title: string; - /** UID The unique identifier (uid) of the created/updated dashboard. */ - uid: string; - /** URL The relative URL for accessing the created/updated dashboard. */ - url: string; - /** Version The version of the dashboard. */ - version: number; -}; -export type RestoreDashboardVersionByUidApiArg = { - uid: string; - restoreDashboardVersionCommand: RestoreDashboardVersionCommand; -}; export type GetDashboardVersionsByUidApiResponse = /** status 200 (empty) */ DashboardVersionResponseMeta; export type GetDashboardVersionsByUidApiArg = { uid: string; @@ -4568,9 +4537,6 @@ export type DashboardAclUpdateItem = { export type UpdateDashboardAclCommand = { items?: DashboardAclUpdateItem[]; }; -export type RestoreDashboardVersionCommand = { - version?: number; -}; export type DashboardVersionMeta = { created?: string; createdBy?: string; @@ -6633,7 +6599,6 @@ export const { useGetDashboardPermissionsListByUidQuery, useLazyGetDashboardPermissionsListByUidQuery, useUpdateDashboardPermissionsByUidMutation, - useRestoreDashboardVersionByUidMutation, useGetDashboardVersionsByUidQuery, useLazyGetDashboardVersionsByUidQuery, useGetDashboardVersionByUidQuery, diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index a560ff47c5d..2e3b955a247 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -795,6 +795,10 @@ func (hs *HTTPServer) GetDashboardVersion(c *contextmodel.ReqContext) response.R // swagger:route POST /dashboards/uid/{uid}/restore dashboards versions restoreDashboardVersionByUID // // Restore a dashboard to a given dashboard version using UID. +// This API will be removed when /apis/dashboards.grafana.app/v1 is released. +// You can restore a dashboard by reading it from history, then creating it again. +// +// Deprecated: true // // Responses: // 200: postDashboardResponse diff --git a/public/api-merged.json b/public/api-merged.json index d511139c7bd..8dc5868bb41 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -4024,12 +4024,14 @@ }, "/dashboards/uid/{uid}/restore": { "post": { + "description": "This API will be removed when /apis/dashboards.grafana.app/v1 is released.\nYou can restore a dashboard by reading it from history, then creating it again.", "tags": [ "dashboards", "versions" ], "summary": "Restore a dashboard to a given dashboard version using UID.", "operationId": "restoreDashboardVersionByUID", + "deprecated": true, "parameters": [ { "name": "Body", diff --git a/public/openapi3.json b/public/openapi3.json index 4a7c5f6be08..8dac2bbc044 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -18377,6 +18377,8 @@ }, "/dashboards/uid/{uid}/restore": { "post": { + "deprecated": true, + "description": "This API will be removed when /apis/dashboards.grafana.app/v1 is released.\nYou can restore a dashboard by reading it from history, then creating it again.", "operationId": "restoreDashboardVersionByUID", "parameters": [ {