annotations.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package annotations
  2. import "github.com/grafana/grafana/pkg/components/simplejson"
  3. type Repository interface {
  4. Save(item *Item) error
  5. Find(query *ItemQuery) ([]*Item, error)
  6. Delete(params *DeleteParams) error
  7. }
  8. type ItemQuery struct {
  9. OrgId int64 `json:"orgId"`
  10. From int64 `json:"from"`
  11. To int64 `json:"from"`
  12. Type ItemType `json:"type"`
  13. AlertId int64 `json:"alertId"`
  14. DashboardId int64 `json:"dashboardId"`
  15. PanelId int64 `json:"panelId"`
  16. NewState []string `json:"newState"`
  17. Limit int64 `json:"alertId"`
  18. }
  19. type DeleteParams struct {
  20. AlertId int64 `json:"alertId"`
  21. DashboardId int64 `json:"dashboardId"`
  22. PanelId int64 `json:"panelId"`
  23. }
  24. var repositoryInstance Repository
  25. func GetRepository() Repository {
  26. return repositoryInstance
  27. }
  28. func SetRepository(rep Repository) {
  29. repositoryInstance = rep
  30. }
  31. type ItemType string
  32. const (
  33. AlertType ItemType = "alert"
  34. )
  35. type Item struct {
  36. Id int64 `json:"id"`
  37. OrgId int64 `json:"orgId"`
  38. DashboardId int64 `json:"dashboardId"`
  39. PanelId int64 `json:"panelId"`
  40. CategoryId int64 `json:"panelId"`
  41. Type ItemType `json:"type"`
  42. Title string `json:"title"`
  43. Text string `json:"text"`
  44. Metric string `json:"metric"`
  45. AlertId int64 `json:"alertId"`
  46. UserId int64 `json:"userId"`
  47. PrevState string `json:"prevState"`
  48. NewState string `json:"newState"`
  49. Epoch int64 `json:"epoch"`
  50. Data *simplejson.Json `json:"data"`
  51. }