Folder/parent subresource (#98392)

* Expose get folder parents endpoint

* Add tests
This commit is contained in:
Leonor Oliveira
2025-01-03 10:43:56 +01:00
committed by GitHub
parent 0836f71da6
commit 937e8dea2d
3 changed files with 136 additions and 41 deletions

View File

@ -76,6 +76,7 @@ func (hs *HTTPServer) registerFolderAPI(apiRoute routing.RouteRegister, authoriz
} else {
folderUidRoute.Post("/move", authorize(accesscontrol.EvalPermission(dashboards.ActionFoldersWrite, uidScope)), routing.Wrap(hs.MoveFolder))
}
folderUidRoute.Get("parents", handler.getFolderParents)
})
} else {
folderRoute.Post("/", authorize(accesscontrol.EvalPermission(dashboards.ActionFoldersCreate)), routing.Wrap(hs.CreateFolder))
@ -816,6 +817,23 @@ func (fk8s *folderK8sHandler) countFolderContent(c *contextmodel.ReqContext) {
c.JSON(http.StatusOK, out)
}
func (fk8s *folderK8sHandler) getFolderParents(c *contextmodel.ReqContext) {
client, ok := fk8s.getClient(c)
if !ok {
return
}
uid := web.Params(c.Req)[":uid"]
out, err := client.Get(c.Req.Context(), uid, v1.GetOptions{}, "parents")
if err != nil {
fk8s.writeError(c, err)
return
}
c.JSON(http.StatusOK, out)
}
func (fk8s *folderK8sHandler) getFolder(c *contextmodel.ReqContext) {
client, ok := fk8s.getClient(c)
if !ok {