annotations.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. Tags []string `json:"tags"`
  19. Type string `json:"type"`
  20. MatchAny bool `json:"matchAny"`
  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. }
  38. var repositoryInstance Repository
  39. func GetRepository() Repository {
  40. return repositoryInstance
  41. }
  42. func SetRepository(rep Repository) {
  43. repositoryInstance = rep
  44. }
  45. type Item struct {
  46. Id int64 `json:"id"`
  47. OrgId int64 `json:"orgId"`
  48. UserId int64 `json:"userId"`
  49. DashboardId int64 `json:"dashboardId"`
  50. PanelId int64 `json:"panelId"`
  51. Text string `json:"text"`
  52. AlertId int64 `json:"alertId"`
  53. PrevState string `json:"prevState"`
  54. NewState string `json:"newState"`
  55. Epoch int64 `json:"epoch"`
  56. EpochEnd int64 `json:"epochEnd"`
  57. Created int64 `json:"created"`
  58. Updated int64 `json:"updated"`
  59. Tags []string `json:"tags"`
  60. Data *simplejson.Json `json:"data"`
  61. // needed until we remove it from db
  62. Type string
  63. Title string
  64. }
  65. type ItemDTO struct {
  66. Id int64 `json:"id"`
  67. AlertId int64 `json:"alertId"`
  68. AlertName string `json:"alertName"`
  69. DashboardId int64 `json:"dashboardId"`
  70. PanelId int64 `json:"panelId"`
  71. UserId int64 `json:"userId"`
  72. NewState string `json:"newState"`
  73. PrevState string `json:"prevState"`
  74. Created int64 `json:"created"`
  75. Updated int64 `json:"updated"`
  76. Time int64 `json:"time"`
  77. TimeEnd int64 `json:"timeEnd"`
  78. Text string `json:"text"`
  79. Tags []string `json:"tags"`
  80. Login string `json:"login"`
  81. Email string `json:"email"`
  82. AvatarUrl string `json:"avatarUrl"`
  83. Data *simplejson.Json `json:"data"`
  84. }