annotations.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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) ([]*ItemDTO, 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. UserId int64 `json:"userId"`
  14. AlertId int64 `json:"alertId"`
  15. DashboardId int64 `json:"dashboardId"`
  16. PanelId int64 `json:"panelId"`
  17. AnnotationId int64 `json:"annotationId"`
  18. RegionId int64 `json:"regionId"`
  19. Tags []string `json:"tags"`
  20. Type string `json:"type"`
  21. MatchAny bool `json:"matchAny"`
  22. Limit int64 `json:"limit"`
  23. }
  24. type PostParams struct {
  25. DashboardId int64 `json:"dashboardId"`
  26. PanelId int64 `json:"panelId"`
  27. Epoch int64 `json:"epoch"`
  28. Title string `json:"title"`
  29. Text string `json:"text"`
  30. Icon string `json:"icon"`
  31. }
  32. type DeleteParams struct {
  33. OrgId int64
  34. Id int64
  35. AlertId int64
  36. DashboardId int64
  37. PanelId int64
  38. RegionId int64
  39. }
  40. var repositoryInstance Repository
  41. func GetRepository() Repository {
  42. return repositoryInstance
  43. }
  44. func SetRepository(rep Repository) {
  45. repositoryInstance = rep
  46. }
  47. type Item struct {
  48. Id int64 `json:"id"`
  49. OrgId int64 `json:"orgId"`
  50. UserId int64 `json:"userId"`
  51. DashboardId int64 `json:"dashboardId"`
  52. PanelId int64 `json:"panelId"`
  53. RegionId int64 `json:"regionId"`
  54. Text string `json:"text"`
  55. AlertId int64 `json:"alertId"`
  56. PrevState string `json:"prevState"`
  57. NewState string `json:"newState"`
  58. Epoch int64 `json:"epoch"`
  59. Created int64 `json:"created"`
  60. Updated int64 `json:"updated"`
  61. Tags []string `json:"tags"`
  62. Data *simplejson.Json `json:"data"`
  63. // needed until we remove it from db
  64. Type string
  65. Title string
  66. }
  67. type ItemDTO struct {
  68. Id int64 `json:"id"`
  69. AlertId int64 `json:"alertId"`
  70. AlertName string `json:"alertName"`
  71. DashboardId int64 `json:"dashboardId"`
  72. PanelId int64 `json:"panelId"`
  73. UserId int64 `json:"userId"`
  74. NewState string `json:"newState"`
  75. PrevState string `json:"prevState"`
  76. Created int64 `json:"created"`
  77. Updated int64 `json:"updated"`
  78. Time int64 `json:"time"`
  79. Text string `json:"text"`
  80. RegionId int64 `json:"regionId"`
  81. Tags []string `json:"tags"`
  82. Login string `json:"login"`
  83. Email string `json:"email"`
  84. AvatarUrl string `json:"avatarUrl"`
  85. Data *simplejson.Json `json:"data"`
  86. }