alert_notifications.go 2.6 KB

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