annotations.go 1.8 KB

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