From 42f69a5e63c1f259a88f4f11d3aefd8f069c0e38 Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> Date: Mon, 11 Jul 2022 17:12:22 +0300 Subject: [PATCH] API: Add playlists endpoints to the swagger spec (#51918) --- pkg/api/docs/definitions/playlists.go | 177 +++++++++++ public/api-merged.json | 413 ++++++++++++++++++++++++++ public/api-spec.json | 413 ++++++++++++++++++++++++++ 3 files changed, 1003 insertions(+) create mode 100644 pkg/api/docs/definitions/playlists.go diff --git a/pkg/api/docs/definitions/playlists.go b/pkg/api/docs/definitions/playlists.go new file mode 100644 index 00000000000..321a137601b --- /dev/null +++ b/pkg/api/docs/definitions/playlists.go @@ -0,0 +1,177 @@ +package definitions + +import ( + "github.com/grafana/grafana/pkg/api/dtos" + "github.com/grafana/grafana/pkg/models" +) + +// swagger:route GET /playlists playlists searchPlaylists +// +// Get playlists. +// +// Responses: +// 200: searchPlaylistsResponse +// 500: internalServerError + +// swagger:route GET /playlists/{uid} playlists getPlaylist +// +// Get playlist by UID. +// +// Responses: +// 200: getPlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /playlists/{uid}/items playlists getPlaylistItems +// +// Get playlist items. +// +// Responses: +// 200: getPlaylistItemsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /playlists/{uid}/dashboards playlists getPlaylistDashboards +// +// Get playlist dashboards. +// +// Responses: +// 200: getPlaylistDashboardsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route DELETE /playlists/{uid} playlists deletePlaylist +// +// Delete pllaylist. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route PUT /playlists/{uid} playlists updatePlaylist +// +// Update playlist. +// +// Responses: +// 200: updatePlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route POST /playlists playlists createPlaylist +// +// Create playlist. +// +// Responses: +// 200: createPlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:parameters searchPlaylists +type SearchPlaylistsParams struct { + // in:query + // required:false + Query string `json:"query"` + // in:limit + // required:false + Limit int `json:"limit"` +} + +// swagger:parameters getPlaylist +type GetPlaylistParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getPlaylistItems +type GetPlaylistItemsParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getPlaylistDashboards +type GetPlaylistDashboardsParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters deletePlaylist +type DeletePlaylistParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters updatePlaylist +type UpdatePlaylistParams struct { + // in:body + // required:true + Body models.UpdatePlaylistCommand + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters createPlaylist +type CreatePlaylistParams struct { + // in:body + // required:true + Body models.CreatePlaylistCommand +} + +// swagger:response searchPlaylistsResponse +type SearchPlaylistsResponse struct { + // The response message + // in: body + Body models.Playlists `json:"body"` +} + +// swagger:response getPlaylistResponse +type GetPlaylistResponse struct { + // The response message + // in: body + Body *models.PlaylistDTO `json:"body"` +} + +// swagger:response getPlaylistItemsResponse +type GetPlaylistItemsResponse struct { + // The response message + // in: body + Body []models.PlaylistItemDTO `json:"body"` +} + +// swagger:response getPlaylistDashboardsResponse +type GetPlaylistDashboardsResponse struct { + // The response message + // in: body + Body dtos.PlaylistDashboardsSlice `json:"body"` +} + +// swagger:response updatePlaylistResponse +type UpdatePlaylistResponseResponse struct { + // The response message + // in: body + Body *models.PlaylistDTO `json:"body"` +} + +// swagger:response createPlaylistResponse +type CreatePlaylistResponse struct { + // The response message + // in: body + Body *models.Playlist `json:"body"` +} diff --git a/public/api-merged.json b/public/api-merged.json index b3a8c4cd583..27606a9ae47 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -5806,6 +5806,231 @@ } } }, + "/playlists": { + "get": { + "tags": ["playlists"], + "summary": "Get playlists.", + "operationId": "searchPlaylists", + "parameters": [ + { + "type": "string", + "name": "query", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "in:limit", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/searchPlaylistsResponse" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "post": { + "tags": ["playlists"], + "summary": "Create playlist.", + "operationId": "createPlaylist", + "parameters": [ + { + "name": "Body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreatePlaylistCommand" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/createPlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist by UID.", + "operationId": "getPlaylist", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "put": { + "tags": ["playlists"], + "summary": "Update playlist.", + "operationId": "updatePlaylist", + "parameters": [ + { + "name": "Body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdatePlaylistCommand" + } + }, + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/updatePlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "delete": { + "tags": ["playlists"], + "summary": "Delete pllaylist.", + "operationId": "deletePlaylist", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/okResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}/dashboards": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist dashboards.", + "operationId": "getPlaylistDashboards", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistDashboardsResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}/items": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist items.", + "operationId": "getPlaylistItems", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistItemsResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, "/query-history": { "get": { "description": "Returns a list of queries in the query history that matches the search criteria.\nQuery history search supports pagination. Use the `limit` parameter to control the maximum number of queries returned; the default limit is 100.\nYou can also use the `page` query parameter to fetch queries from any page other than the first one.", @@ -10040,6 +10265,26 @@ } } }, + "CreatePlaylistCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/Playlist" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + } + } + }, "CreateQueryInQueryHistoryCommand": { "description": "CreateQueryInQueryHistoryCommand is the command for adding query history", "type": "object", @@ -13001,6 +13246,112 @@ "type": "integer", "format": "int64" }, + "Playlist": { + "description": "Playlist model", + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "interval": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "PlaylistDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "PlaylistDashboard": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "order": { + "type": "integer", + "format": "int64" + }, + "slug": { + "type": "string" + }, + "title": { + "type": "string" + }, + "uri": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "PlaylistDashboardsSlice": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistDashboard" + } + }, + "PlaylistItemDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "order": { + "type": "integer", + "format": "int64" + }, + "playlistid": { + "type": "integer", + "format": "int64" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Playlists": { + "type": "array", + "items": { + "$ref": "#/definitions/Playlist" + } + }, "Point": { "type": "object", "title": "Point represents a single data point for a given timestamp.", @@ -15278,6 +15629,29 @@ } } }, + "UpdatePlaylistCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/PlaylistDTO" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, "UpdatePrefsCmd": { "type": "object", "properties": { @@ -16325,6 +16699,12 @@ } } }, + "createPlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/Playlist" + } + }, "createReportResponse": { "description": "", "schema": { @@ -16745,6 +17125,27 @@ "$ref": "#/definitions/AddPermissionDTO" } }, + "getPlaylistDashboardsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDashboardsSlice" + } + }, + "getPlaylistItemsResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + } + }, + "getPlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDTO" + } + }, "getPreferencesResponse": { "description": "", "schema": { @@ -17098,6 +17499,12 @@ } } }, + "searchPlaylistsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/Playlists" + } + }, "searchResponse": { "description": "", "schema": { @@ -17163,6 +17570,12 @@ "$ref": "#/definitions/ErrorResponseBody" } }, + "updatePlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDTO" + } + }, "userResponse": { "description": "", "schema": { diff --git a/public/api-spec.json b/public/api-spec.json index 6166c6c37ab..7cb300331bd 100644 --- a/public/api-spec.json +++ b/public/api-spec.json @@ -5806,6 +5806,231 @@ } } }, + "/playlists": { + "get": { + "tags": ["playlists"], + "summary": "Get playlists.", + "operationId": "searchPlaylists", + "parameters": [ + { + "type": "string", + "name": "query", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "description": "in:limit", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/searchPlaylistsResponse" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "post": { + "tags": ["playlists"], + "summary": "Create playlist.", + "operationId": "createPlaylist", + "parameters": [ + { + "name": "Body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreatePlaylistCommand" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/createPlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist by UID.", + "operationId": "getPlaylist", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "put": { + "tags": ["playlists"], + "summary": "Update playlist.", + "operationId": "updatePlaylist", + "parameters": [ + { + "name": "Body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdatePlaylistCommand" + } + }, + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/updatePlaylistResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "delete": { + "tags": ["playlists"], + "summary": "Delete pllaylist.", + "operationId": "deletePlaylist", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/okResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}/dashboards": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist dashboards.", + "operationId": "getPlaylistDashboards", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistDashboardsResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, + "/playlists/{uid}/items": { + "get": { + "tags": ["playlists"], + "summary": "Get playlist items.", + "operationId": "getPlaylistItems", + "parameters": [ + { + "type": "string", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/getPlaylistItemsResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, "/query-history": { "get": { "description": "Returns a list of queries in the query history that matches the search criteria.\nQuery history search supports pagination. Use the `limit` parameter to control the maximum number of queries returned; the default limit is 100.\nYou can also use the `page` query parameter to fetch queries from any page other than the first one.", @@ -9170,6 +9395,26 @@ } } }, + "CreatePlaylistCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/Playlist" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + } + } + }, "CreateQueryInQueryHistoryCommand": { "description": "CreateQueryInQueryHistoryCommand is the command for adding query history", "type": "object", @@ -11066,6 +11311,112 @@ "type": "integer", "format": "int64" }, + "Playlist": { + "description": "Playlist model", + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "interval": { + "type": "string" + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "PlaylistDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, + "PlaylistDashboard": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "order": { + "type": "integer", + "format": "int64" + }, + "slug": { + "type": "string" + }, + "title": { + "type": "string" + }, + "uri": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "PlaylistDashboardsSlice": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistDashboard" + } + }, + "PlaylistItemDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "order": { + "type": "integer", + "format": "int64" + }, + "playlistid": { + "type": "integer", + "format": "int64" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "Playlists": { + "type": "array", + "items": { + "$ref": "#/definitions/Playlist" + } + }, "PostAnnotationsCmd": { "type": "object", "properties": { @@ -12319,6 +12670,29 @@ } } }, + "UpdatePlaylistCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/PlaylistDTO" + }, + "interval": { + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + }, + "name": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, "UpdatePrefsCmd": { "type": "object", "properties": { @@ -12784,6 +13158,12 @@ } } }, + "createPlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/Playlist" + } + }, "createReportResponse": { "description": "", "schema": { @@ -13204,6 +13584,27 @@ "$ref": "#/definitions/AddPermissionDTO" } }, + "getPlaylistDashboardsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDashboardsSlice" + } + }, + "getPlaylistItemsResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PlaylistItemDTO" + } + } + }, + "getPlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDTO" + } + }, "getPreferencesResponse": { "description": "", "schema": { @@ -13557,6 +13958,12 @@ } } }, + "searchPlaylistsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/Playlists" + } + }, "searchResponse": { "description": "", "schema": { @@ -13622,6 +14029,12 @@ "$ref": "#/definitions/ErrorResponseBody" } }, + "updatePlaylistResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/PlaylistDTO" + } + }, "userResponse": { "description": "", "schema": {