annotations.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package annotations
  2. import (
  3. "time"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. )
  6. type Repository interface {
  7. Save(item *Item) error
  8. Find(query *ItemQuery) ([]*Item, error)
  9. }
  10. type ItemQuery struct {
  11. OrgId int64 `json:"orgId"`
  12. Type ItemType `json:"type"`
  13. AlertId int64 `json:"alertId"`
  14. Limit int64 `json:"alertId"`
  15. }
  16. var repositoryInstance Repository
  17. func GetRepository() Repository {
  18. return repositoryInstance
  19. }
  20. func SetRepository(rep Repository) {
  21. repositoryInstance = rep
  22. }
  23. type ItemType string
  24. const (
  25. AlertType ItemType = "alert"
  26. )
  27. type Item struct {
  28. Id int64 `json:"id"`
  29. OrgId int64 `json:"orgId"`
  30. Type ItemType `json:"type"`
  31. Title string `json:"title"`
  32. Text string `json:"text"`
  33. Metric string `json:"metric"`
  34. AlertId int64 `json:"alertId"`
  35. UserId int64 `json:"userId"`
  36. PrevState string `json:"prevState"`
  37. NewState string `json:"newState"`
  38. Timestamp time.Time `json:"timestamp"`
  39. Data *simplejson.Json `json:"data"`
  40. }