mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Chore: Add dashboard UID as query parameter of Get annotation endpoint (#52764)
* Chore: Add dashboard uid as query parameter of Get annotation endpoint * Update pkg/api/annotations.go Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> * update the dashboarUID Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
co-authored by
Sofia Papagiannaki
parent
a5410063c6
commit
7da0a6d3ce
@@ -26,6 +26,7 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
|
||||
UserId: c.QueryInt64("userId"),
|
||||
AlertId: c.QueryInt64("alertId"),
|
||||
DashboardId: c.QueryInt64("dashboardId"),
|
||||
DashboardUid: c.Query("dashboardUID"),
|
||||
PanelId: c.QueryInt64("panelId"),
|
||||
Limit: c.QueryInt64("limit"),
|
||||
Tags: c.QueryStrings("tags"),
|
||||
@@ -34,6 +35,16 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
|
||||
SignedInUser: c.SignedInUser,
|
||||
}
|
||||
|
||||
// When dashboard UID present in the request, we ignore dashboard ID
|
||||
if query.DashboardUid != "" {
|
||||
dq := models.GetDashboardQuery{Uid: query.DashboardUid, OrgId: c.OrgId}
|
||||
err := hs.DashboardService.GetDashboard(c.Req.Context(), &dq)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "Invalid dashboard UID in the request", err)
|
||||
}
|
||||
query.DashboardId = dq.Id
|
||||
}
|
||||
|
||||
repo := annotations.GetRepository()
|
||||
|
||||
items, err := repo.Find(c.Req.Context(), query)
|
||||
|
||||
@@ -149,6 +149,10 @@ type GetAnnotationsParams struct {
|
||||
// in:query
|
||||
// required:false
|
||||
DashboardID int64 `json:"dashboardId"`
|
||||
// Find annotations that are scoped to a specific dashboard
|
||||
// in:query
|
||||
// required:false
|
||||
DashboardUID string `json:"dashboardUID"`
|
||||
// Find annotations that are scoped to a specific panel
|
||||
// in:query
|
||||
// required:false
|
||||
|
||||
Reference in New Issue
Block a user