annotations.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. )
  42. type Item struct {
  43. Id int64 `json:"id"`
  44. OrgId int64 `json:"orgId"`
  45. DashboardId int64 `json:"dashboardId"`
  46. PanelId int64 `json:"panelId"`
  47. CategoryId int64 `json:"categoryId"`
  48. Type ItemType `json:"type"`
  49. Title string `json:"title"`
  50. Text string `json:"text"`
  51. Metric string `json:"metric"`
  52. AlertId int64 `json:"alertId"`
  53. UserId int64 `json:"userId"`
  54. PrevState string `json:"prevState"`
  55. NewState string `json:"newState"`
  56. Epoch int64 `json:"epoch"`
  57. Data *simplejson.Json `json:"data"`
  58. }