annotations.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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:"to"`
  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:"limit"`
  18. }
  19. type PostParams struct {
  20. DashboardId int64 `json:"dashboardId"`
  21. PanelId int64 `json:"panelId"`
  22. Epoch int64 `json:"epoch"`
  23. Title string `json:"title"`
  24. Text string `json:"text"`
  25. }
  26. type DeleteParams struct {
  27. AlertId int64 `json:"alertId"`
  28. DashboardId int64 `json:"dashboardId"`
  29. PanelId int64 `json:"panelId"`
  30. }
  31. var repositoryInstance Repository
  32. func GetRepository() Repository {
  33. return repositoryInstance
  34. }
  35. func SetRepository(rep Repository) {
  36. repositoryInstance = rep
  37. }
  38. type ItemType string
  39. const (
  40. AlertType ItemType = "alert"
  41. EventType ItemType = "event"
  42. )
  43. type Item struct {
  44. Id int64 `json:"id"`
  45. OrgId int64 `json:"orgId"`
  46. DashboardId int64 `json:"dashboardId"`
  47. PanelId int64 `json:"panelId"`
  48. CategoryId int64 `json:"categoryId"`
  49. Type ItemType `json:"type"`
  50. Title string `json:"title"`
  51. Text string `json:"text"`
  52. Metric string `json:"metric"`
  53. AlertId int64 `json:"alertId"`
  54. UserId int64 `json:"userId"`
  55. PrevState string `json:"prevState"`
  56. NewState string `json:"newState"`
  57. Epoch int64 `json:"epoch"`
  58. Data *simplejson.Json `json:"data"`
  59. }