annotations.go 1.1 KB

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