annotations.go 2.9 KB

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