annotations.go 1.3 KB

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