annotations.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. }
  7. type ItemQuery struct {
  8. OrgId int64 `json:"orgId"`
  9. From int64 `json:"from"`
  10. To int64 `json:"from"`
  11. Type ItemType `json:"type"`
  12. AlertId int64 `json:"alertId"`
  13. DashboardId int64 `json:"dashboardId"`
  14. PanelId int64 `json:"panelId"`
  15. Limit int64 `json:"alertId"`
  16. }
  17. var repositoryInstance Repository
  18. func GetRepository() Repository {
  19. return repositoryInstance
  20. }
  21. func SetRepository(rep Repository) {
  22. repositoryInstance = rep
  23. }
  24. type ItemType string
  25. const (
  26. AlertType ItemType = "alert"
  27. )
  28. type Item struct {
  29. Id int64 `json:"id"`
  30. OrgId int64 `json:"orgId"`
  31. DashboardId int64 `json:"dashboardId"`
  32. PanelId int64 `json:"panelId"`
  33. Type ItemType `json:"type"`
  34. Title string `json:"title"`
  35. Text string `json:"text"`
  36. Metric string `json:"metric"`
  37. AlertId int64 `json:"alertId"`
  38. UserId int64 `json:"userId"`
  39. PrevState string `json:"prevState"`
  40. NewState string `json:"newState"`
  41. Epoch int64 `json:"epoch"`
  42. Data *simplejson.Json `json:"data"`
  43. }