annotations.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. CategoryId int64 `json:"panelId"`
  34. Type ItemType `json:"type"`
  35. Title string `json:"title"`
  36. Text string `json:"text"`
  37. Metric string `json:"metric"`
  38. AlertId int64 `json:"alertId"`
  39. UserId int64 `json:"userId"`
  40. PrevState string `json:"prevState"`
  41. NewState string `json:"newState"`
  42. Epoch int64 `json:"epoch"`
  43. Data *simplejson.Json `json:"data"`
  44. }