alert_notifications.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. "github.com/grafana/grafana/pkg/components/simplejson"
  6. )
  7. var (
  8. ErrNotificationFrequencyNotFound = errors.New("Notification frequency not specified")
  9. )
  10. type AlertNotification struct {
  11. Id int64 `json:"id"`
  12. OrgId int64 `json:"-"`
  13. Name string `json:"name"`
  14. Type string `json:"type"`
  15. SendReminder bool `json:"sendReminder"`
  16. Frequency time.Duration `json:"frequency"`
  17. IsDefault bool `json:"isDefault"`
  18. Settings *simplejson.Json `json:"settings"`
  19. Created time.Time `json:"created"`
  20. Updated time.Time `json:"updated"`
  21. }
  22. type CreateAlertNotificationCommand struct {
  23. Name string `json:"name" binding:"Required"`
  24. Type string `json:"type" binding:"Required"`
  25. SendReminder bool `json:"sendReminder"`
  26. Frequency string `json:"frequency"`
  27. IsDefault bool `json:"isDefault"`
  28. Settings *simplejson.Json `json:"settings"`
  29. OrgId int64 `json:"-"`
  30. Result *AlertNotification
  31. }
  32. type UpdateAlertNotificationCommand struct {
  33. Id int64 `json:"id" binding:"Required"`
  34. Name string `json:"name" binding:"Required"`
  35. Type string `json:"type" binding:"Required"`
  36. SendReminder bool `json:"sendReminder"`
  37. Frequency string `json:"frequency"`
  38. IsDefault bool `json:"isDefault"`
  39. Settings *simplejson.Json `json:"settings" binding:"Required"`
  40. OrgId int64 `json:"-"`
  41. Result *AlertNotification
  42. }
  43. type DeleteAlertNotificationCommand struct {
  44. Id int64
  45. OrgId int64
  46. }
  47. type GetAlertNotificationsQuery struct {
  48. Name string
  49. Id int64
  50. OrgId int64
  51. Result *AlertNotification
  52. }
  53. type GetAlertNotificationsToSendQuery struct {
  54. Ids []int64
  55. OrgId int64
  56. Result []*AlertNotification
  57. }
  58. type GetAllAlertNotificationsQuery struct {
  59. OrgId int64
  60. Result []*AlertNotification
  61. }
  62. type AlertNotificationJournal struct {
  63. Id int64
  64. OrgId int64
  65. AlertId int64
  66. NotifierId int64
  67. SentAt time.Time
  68. Success bool
  69. }
  70. type RecordNotificationJournalCommand struct {
  71. OrgId int64
  72. AlertId int64
  73. NotifierId int64
  74. SentAt time.Time
  75. Success bool
  76. }
  77. type GetLatestNotificationQuery struct {
  78. OrgId int64
  79. AlertId int64
  80. NotifierId int64
  81. Result *AlertNotificationJournal
  82. }
  83. type CleanNotificationJournalCommand struct {
  84. OrgId int64
  85. AlertId int64
  86. NotifierId int64
  87. }