[Alerting]: Several modifications in alert rules (#32983)

* [Alerting]: Use common properties for all rules

* Add Labels in rules

* Fix update ruleGroup API

Return 400 Bad Request response
when the request contains a UID that does not exist

* Check permissions and return namespace id

* Apply suggestions from code review

Co-authored-by: gotjosh <josue@grafana.com>
This commit is contained in:
Sofia Papagiannaki
2021-04-15 15:54:37 +03:00
committed by GitHub
co-authored by gotjosh
parent 34b4f7c717
commit 6bbb2fd4ba
13 changed files with 239 additions and 86 deletions
+5 -5
View File
@@ -17,13 +17,13 @@ func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Res
folder, err := s.GetFolderByUID(c.Params(":uid"))
if err != nil {
return toFolderError(err)
return ToFolderErrorResponse(err)
}
g := guardian.New(folder.Id, c.OrgId, c.SignedInUser)
if canAdmin, err := g.CanAdmin(); err != nil || !canAdmin {
return toFolderError(models.ErrFolderAccessDenied)
return ToFolderErrorResponse(models.ErrFolderAccessDenied)
}
acl, err := g.GetAcl()
@@ -64,17 +64,17 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext, apiCmd dtos.
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
folder, err := s.GetFolderByUID(c.Params(":uid"))
if err != nil {
return toFolderError(err)
return ToFolderErrorResponse(err)
}
g := guardian.New(folder.Id, c.OrgId, c.SignedInUser)
canAdmin, err := g.CanAdmin()
if err != nil {
return toFolderError(err)
return ToFolderErrorResponse(err)
}
if !canAdmin {
return toFolderError(models.ErrFolderAccessDenied)
return ToFolderErrorResponse(models.ErrFolderAccessDenied)
}
var items []*models.DashboardAcl