mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Folders: Forbid performing operations on folders via dashboards HTTP API (#81264)
* Forbid creating folders via dashboard api * Update delete endpoint * Update docs
This commit is contained in:
parent
bd0fd21852
commit
14a36b4040
@ -37,6 +37,8 @@ The uid can have a maximum length of 40 characters.
|
|||||||
|
|
||||||
Creates a new dashboard or updates an existing dashboard. When updating existing dashboards, if you do not define the `folderId` or the `folderUid` property, then the dashboard(s) are moved to the root level. (You need to define only one property, not both).
|
Creates a new dashboard or updates an existing dashboard. When updating existing dashboards, if you do not define the `folderId` or the `folderUid` property, then the dashboard(s) are moved to the root level. (You need to define only one property, not both).
|
||||||
|
|
||||||
|
> **Note:** This endpoint is not intended for creating folders, use `POST /api/folders` for that.
|
||||||
|
|
||||||
**Required permissions**
|
**Required permissions**
|
||||||
|
|
||||||
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
||||||
|
@ -303,6 +303,10 @@ func (hs *HTTPServer) deleteDashboard(c *contextmodel.ReqContext) response.Respo
|
|||||||
return dashboardGuardianResponse(err)
|
return dashboardGuardianResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dash.IsFolder {
|
||||||
|
return response.Error(http.StatusBadRequest, "Use folders endpoint for deleting folders.", nil)
|
||||||
|
}
|
||||||
|
|
||||||
namespaceID, userIDStr := c.SignedInUser.GetNamespacedID()
|
namespaceID, userIDStr := c.SignedInUser.GetNamespacedID()
|
||||||
|
|
||||||
// disconnect all library elements for this dashboard
|
// disconnect all library elements for this dashboard
|
||||||
@ -356,6 +360,7 @@ func (hs *HTTPServer) deleteDashboard(c *contextmodel.ReqContext) response.Respo
|
|||||||
// Create / Update dashboard
|
// Create / Update dashboard
|
||||||
//
|
//
|
||||||
// Creates a new dashboard or updates an existing dashboard.
|
// Creates a new dashboard or updates an existing dashboard.
|
||||||
|
// Note: This endpoint is not intended for creating folders, use `POST /api/folders` for that.
|
||||||
//
|
//
|
||||||
// Responses:
|
// Responses:
|
||||||
// 200: postDashboardResponse
|
// 200: postDashboardResponse
|
||||||
@ -375,6 +380,10 @@ func (hs *HTTPServer) PostDashboard(c *contextmodel.ReqContext) response.Respons
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hs *HTTPServer) postDashboard(c *contextmodel.ReqContext, cmd dashboards.SaveDashboardCommand) response.Response {
|
func (hs *HTTPServer) postDashboard(c *contextmodel.ReqContext, cmd dashboards.SaveDashboardCommand) response.Response {
|
||||||
|
if cmd.IsFolder {
|
||||||
|
return response.Error(http.StatusBadRequest, "Use folders endpoint for saving folders.", nil)
|
||||||
|
}
|
||||||
|
|
||||||
ctx := c.Req.Context()
|
ctx := c.Req.Context()
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -3015,7 +3015,7 @@
|
|||||||
},
|
},
|
||||||
"/dashboards/db": {
|
"/dashboards/db": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a new dashboard or updates an existing dashboard.",
|
"description": "Creates a new dashboard or updates an existing dashboard.\nNote: This endpoint is not intended for creating folders, use `POST /api/folders` for that.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"dashboards"
|
"dashboards"
|
||||||
],
|
],
|
||||||
|
@ -16107,7 +16107,7 @@
|
|||||||
},
|
},
|
||||||
"/dashboards/db": {
|
"/dashboards/db": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Creates a new dashboard or updates an existing dashboard.",
|
"description": "Creates a new dashboard or updates an existing dashboard.\nNote: This endpoint is not intended for creating folders, use `POST /api/folders` for that.",
|
||||||
"operationId": "postDashboard",
|
"operationId": "postDashboard",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
|
Loading…
Reference in New Issue
Block a user