alerting_state.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package models
  2. import (
  3. "time"
  4. )
  5. type AlertStateLog struct {
  6. Id int64 `json:"-"`
  7. OrgId int64 `json:"-"`
  8. AlertId int64 `json:"alertId"`
  9. NewState string `json:"newState"`
  10. Created time.Time `json:"created"`
  11. Info string `json:"info"`
  12. }
  13. var (
  14. ALERT_STATE_OK = "OK"
  15. ALERT_STATE_ALERT = "ALERT"
  16. ALERT_STATE_WARN = "WARN"
  17. ALERT_STATE_ACKNOWLEDGED = "ACKNOWLEDGED"
  18. )
  19. func (this *UpdateAlertStateCommand) IsValidState() bool {
  20. return this.NewState == ALERT_STATE_OK || this.NewState == ALERT_STATE_WARN || this.NewState == ALERT_STATE_ALERT || this.NewState == ALERT_STATE_ACKNOWLEDGED
  21. }
  22. // Commands
  23. type UpdateAlertStateCommand struct {
  24. AlertId int64 `json:"alertId" binding:"Required"`
  25. NewState string `json:"newState" binding:"Required"`
  26. Info string `json:"info"`
  27. Result *AlertRule
  28. }
  29. // Queries
  30. type GetAlertsStateLogCommand struct {
  31. OrgId int64 `json:"orgId" binding:"Required"`
  32. AlertId int64 `json:"alertId" binding:"Required"`
  33. Result *[]AlertStateLog
  34. }