annotations.go 846 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. }
  9. var repositoryInstance Repository
  10. func GetRepository() Repository {
  11. return repositoryInstance
  12. }
  13. func SetRepository(rep Repository) {
  14. repositoryInstance = rep
  15. }
  16. type ItemType string
  17. const (
  18. AlertType ItemType = "alert"
  19. )
  20. type Item struct {
  21. Id int64 `json:"id"`
  22. OrgId int64 `json:"orgId"`
  23. Type ItemType `json:"type"`
  24. Title string `json:"title"`
  25. Text string `json:"text"`
  26. Metric string `json:"metric"`
  27. AlertId int64 `json:"alertId"`
  28. UserId int64 `json:"userId"`
  29. PrevState string `json:"prevState"`
  30. NewState string `json:"newState"`
  31. Timestamp time.Time `json:"timestamp"`
  32. Data *simplejson.Json `json:"data"`
  33. }