mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06: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:
parent
a5410063c6
commit
7da0a6d3ce
@ -48,6 +48,7 @@ Query Parameters:
|
|||||||
- `limit`: number. Optional - default is 100. Max limit for results returned.
|
- `limit`: number. Optional - default is 100. Max limit for results returned.
|
||||||
- `alertId`: number. Optional. Find annotations for a specified alert.
|
- `alertId`: number. Optional. Find annotations for a specified alert.
|
||||||
- `dashboardId`: number. Optional. Find annotations that are scoped to a specific dashboard
|
- `dashboardId`: number. Optional. Find annotations that are scoped to a specific dashboard
|
||||||
|
- `dashboardUID`: string. Optional. Find annotations that are scoped to a specific dashboard, when dashboardUID presents, dashboardId would be ignored.
|
||||||
- `panelId`: number. Optional. Find annotations that are scoped to a specific panel
|
- `panelId`: number. Optional. Find annotations that are scoped to a specific panel
|
||||||
- `userId`: number. Optional. Find annotations created by a specific user
|
- `userId`: number. Optional. Find annotations created by a specific user
|
||||||
- `type`: string. Optional. `alert`|`annotation` Return alerts or user created annotations
|
- `type`: string. Optional. `alert`|`annotation` Return alerts or user created annotations
|
||||||
|
@ -26,6 +26,7 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
|
|||||||
UserId: c.QueryInt64("userId"),
|
UserId: c.QueryInt64("userId"),
|
||||||
AlertId: c.QueryInt64("alertId"),
|
AlertId: c.QueryInt64("alertId"),
|
||||||
DashboardId: c.QueryInt64("dashboardId"),
|
DashboardId: c.QueryInt64("dashboardId"),
|
||||||
|
DashboardUid: c.Query("dashboardUID"),
|
||||||
PanelId: c.QueryInt64("panelId"),
|
PanelId: c.QueryInt64("panelId"),
|
||||||
Limit: c.QueryInt64("limit"),
|
Limit: c.QueryInt64("limit"),
|
||||||
Tags: c.QueryStrings("tags"),
|
Tags: c.QueryStrings("tags"),
|
||||||
@ -34,6 +35,16 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
|
|||||||
SignedInUser: c.SignedInUser,
|
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()
|
repo := annotations.GetRepository()
|
||||||
|
|
||||||
items, err := repo.Find(c.Req.Context(), query)
|
items, err := repo.Find(c.Req.Context(), query)
|
||||||
|
@ -149,6 +149,10 @@ type GetAnnotationsParams struct {
|
|||||||
// in:query
|
// in:query
|
||||||
// required:false
|
// required:false
|
||||||
DashboardID int64 `json:"dashboardId"`
|
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
|
// Find annotations that are scoped to a specific panel
|
||||||
// in:query
|
// in:query
|
||||||
// required:false
|
// required:false
|
||||||
|
@ -33,6 +33,7 @@ type ItemQuery struct {
|
|||||||
UserId int64 `json:"userId"`
|
UserId int64 `json:"userId"`
|
||||||
AlertId int64 `json:"alertId"`
|
AlertId int64 `json:"alertId"`
|
||||||
DashboardId int64 `json:"dashboardId"`
|
DashboardId int64 `json:"dashboardId"`
|
||||||
|
DashboardUid string `json:"dashboardUID"`
|
||||||
PanelId int64 `json:"panelId"`
|
PanelId int64 `json:"panelId"`
|
||||||
AnnotationId int64 `json:"annotationId"`
|
AnnotationId int64 `json:"annotationId"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
|
@ -2018,6 +2018,12 @@
|
|||||||
"name": "dashboardId",
|
"name": "dashboardId",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Find annotations that are scoped to a specific dashboard",
|
||||||
|
"name": "dashboardUID",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
|
@ -2018,6 +2018,12 @@
|
|||||||
"name": "dashboardId",
|
"name": "dashboardId",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Find annotations that are scoped to a specific dashboard",
|
||||||
|
"name": "dashboardUID",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
|
Loading…
Reference in New Issue
Block a user