PublicDashboards: Add swagger documentation (#75318)
This commit is contained in:
@@ -56,8 +56,9 @@ func (api *Api) RegisterAPIEndpoints() {
|
||||
// circular dependency
|
||||
|
||||
api.RouteRegister.Get("/api/public/dashboards/:accessToken", routing.Wrap(api.ViewPublicDashboard))
|
||||
api.RouteRegister.Get("/api/public/dashboards/:accessToken/annotations", routing.Wrap(api.GetPublicAnnotations))
|
||||
|
||||
api.RouteRegister.Post("/api/public/dashboards/:accessToken/panels/:panelId/query", routing.Wrap(api.QueryPublicDashboard))
|
||||
api.RouteRegister.Get("/api/public/dashboards/:accessToken/annotations", routing.Wrap(api.GetAnnotations))
|
||||
|
||||
// Auth endpoints
|
||||
auth := accesscontrol.Middleware(api.AccessControl)
|
||||
@@ -87,8 +88,15 @@ func (api *Api) RegisterAPIEndpoints() {
|
||||
routing.Wrap(api.DeletePublicDashboard))
|
||||
}
|
||||
|
||||
// ListPublicDashboards Gets list of public dashboards by orgId
|
||||
// GET /api/dashboards/public-dashboards
|
||||
// swagger:route GET /dashboards/public-dashboards dashboard_public listPublicDashboards
|
||||
//
|
||||
// Get list of public dashboards
|
||||
//
|
||||
// Responses:
|
||||
// 200: listPublicDashboardsResponse
|
||||
// 401: unauthorisedPublicError
|
||||
// 403: forbiddenPublicError
|
||||
// 500: internalServerPublicError
|
||||
func (api *Api) ListPublicDashboards(c *contextmodel.ReqContext) response.Response {
|
||||
perPage := c.QueryInt("perpage")
|
||||
if perPage <= 0 {
|
||||
@@ -114,8 +122,17 @@ func (api *Api) ListPublicDashboards(c *contextmodel.ReqContext) response.Respon
|
||||
return response.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetPublicDashboard Gets public dashboard for dashboard
|
||||
// GET /api/dashboards/uid/:dashboardUid/public-dashboards
|
||||
// swagger:route GET /dashboards/uid/{dashboardUid}/public-dashboards dashboard_public getPublicDashboard
|
||||
//
|
||||
// Get public dashboard by dashboardUid
|
||||
//
|
||||
// Responses:
|
||||
// 200: getPublicDashboardResponse
|
||||
// 400: badRequestPublicError
|
||||
// 401: unauthorisedPublicError
|
||||
// 403: forbiddenPublicError
|
||||
// 404: notFoundPublicError
|
||||
// 500: internalServerPublicError
|
||||
func (api *Api) GetPublicDashboard(c *contextmodel.ReqContext) response.Response {
|
||||
// exit if we don't have a valid dashboardUid
|
||||
dashboardUid := web.Params(c.Req)[":dashboardUid"]
|
||||
@@ -135,8 +152,19 @@ func (api *Api) GetPublicDashboard(c *contextmodel.ReqContext) response.Response
|
||||
return response.JSON(http.StatusOK, pd)
|
||||
}
|
||||
|
||||
// CreatePublicDashboard Sets public dashboard for dashboard
|
||||
// POST /api/dashboards/uid/:dashboardUid/public-dashboards
|
||||
// swagger:route POST /dashboards/uid/{dashboardUid}/public-dashboards dashboard_public createPublicDashboard
|
||||
//
|
||||
// Create public dashboard for a dashboard
|
||||
//
|
||||
// Produces:
|
||||
// - application/json
|
||||
//
|
||||
// Responses:
|
||||
// 200: createPublicDashboardResponse
|
||||
// 400: badRequestPublicError
|
||||
// 401: unauthorisedPublicError
|
||||
// 403: forbiddenPublicError
|
||||
// 500: internalServerPublicError
|
||||
func (api *Api) CreatePublicDashboard(c *contextmodel.ReqContext) response.Response {
|
||||
// exit if we don't have a valid dashboardUid
|
||||
dashboardUid := web.Params(c.Req)[":dashboardUid"]
|
||||
@@ -178,8 +206,19 @@ func (api *Api) CreatePublicDashboard(c *contextmodel.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, pd)
|
||||
}
|
||||
|
||||
// UpdatePublicDashboard Sets public dashboard for dashboard
|
||||
// PATCH /api/dashboards/uid/:dashboardUid/public-dashboards/:uid
|
||||
// swagger:route PATCH /dashboards/uid/{dashboardUid}/public-dashboards/{uid} dashboard_public updatePublicDashboard
|
||||
//
|
||||
// Update public dashboard for a dashboard
|
||||
//
|
||||
// Produces:
|
||||
// - application/json
|
||||
//
|
||||
// Responses:
|
||||
// 200: updatePublicDashboardResponse
|
||||
// 400: badRequestPublicError
|
||||
// 401: unauthorisedPublicError
|
||||
// 403: forbiddenPublicError
|
||||
// 500: internalServerPublicError
|
||||
func (api *Api) UpdatePublicDashboard(c *contextmodel.ReqContext) response.Response {
|
||||
// exit if we don't have a valid dashboardUid
|
||||
dashboardUid := web.Params(c.Req)[":dashboardUid"]
|
||||
@@ -215,8 +254,16 @@ func (api *Api) UpdatePublicDashboard(c *contextmodel.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, pd)
|
||||
}
|
||||
|
||||
// Delete a public dashboard
|
||||
// DELETE /api/dashboards/uid/:dashboardUid/public-dashboards/:uid
|
||||
// swagger:route DELETE /dashboards/uid/{dashboardUid}/public-dashboards/{uid} dashboard_public deletePublicDashboard
|
||||
//
|
||||
// Delete public dashboard for a dashboard
|
||||
//
|
||||
// Responses:
|
||||
// 200: okResponse
|
||||
// 400: badRequestPublicError
|
||||
// 401: unauthorisedPublicError
|
||||
// 403: forbiddenPublicError
|
||||
// 500: internalServerPublicError
|
||||
func (api *Api) DeletePublicDashboard(c *contextmodel.ReqContext) response.Response {
|
||||
uid := web.Params(c.Req)[":uid"]
|
||||
if !validation.IsValidShortUID(uid) {
|
||||
@@ -252,3 +299,66 @@ func toJsonStreamingResponse(features *featuremgmt.FeatureManager, qdr *backend.
|
||||
|
||||
return response.JSONStreaming(statusCode, qdr)
|
||||
}
|
||||
|
||||
// swagger:response listPublicDashboardsResponse
|
||||
type ListPublicDashboardsResponse struct {
|
||||
// in: body
|
||||
Body PublicDashboardListResponseWithPagination `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:parameters getPublicDashboard
|
||||
type GetPublicDashboardParams struct {
|
||||
// in:path
|
||||
DashboardUid string `json:"dashboardUid"`
|
||||
}
|
||||
|
||||
// swagger:response getPublicDashboardResponse
|
||||
type GetPublicDashboardResponse struct {
|
||||
// in: body
|
||||
Body PublicDashboard `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:parameters createPublicDashboard
|
||||
type CreatePublicDashboardParams struct {
|
||||
// in:path
|
||||
// required:true
|
||||
DashboardUid string `json:"dashboardUid"`
|
||||
// in:body
|
||||
// required:true
|
||||
Body PublicDashboardDTO
|
||||
}
|
||||
|
||||
// swagger:response createPublicDashboardResponse
|
||||
type CreatePublicDashboardResponse struct {
|
||||
// in: body
|
||||
Body PublicDashboard `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:parameters updatePublicDashboard
|
||||
type UpdatePublicDashboardParams struct {
|
||||
// in:path
|
||||
// required:true
|
||||
DashboardUid string `json:"dashboardUid"`
|
||||
// in:path
|
||||
// required:true
|
||||
Uid string `json:"uid"`
|
||||
// in:body
|
||||
// required:true
|
||||
Body PublicDashboardDTO
|
||||
}
|
||||
|
||||
// swagger:response updatePublicDashboardResponse
|
||||
type UpdatePublicDashboardResponse struct {
|
||||
// in: body
|
||||
Body PublicDashboard `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:parameters deletePublicDashboard
|
||||
type DeletePublicDashboardParams struct {
|
||||
// in:path
|
||||
// required:true
|
||||
DashboardUid string `json:"dashboardUid"`
|
||||
// in:path
|
||||
// required:true
|
||||
Uid string `json:"uid"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user