alert_notifications.go 2.3 KB

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