alerting_state.go 916 B

1234567891011121314151617181920212223242526272829303132
  1. package models
  2. import "time"
  3. type AlertStateLog struct {
  4. Id int64 `json:"id"`
  5. OrgId int64 `json:"-"`
  6. AlertId int64 `json:"alertId"`
  7. State string `json:"type"`
  8. Created time.Time `json:"created"`
  9. Acknowledged time.Time `json:"acknowledged"`
  10. Deleted time.Time `json:"deleted"`
  11. }
  12. var (
  13. ALERT_STATE_OK = "OK"
  14. ALERT_STATE_ALERT = "ALERT"
  15. ALERT_STATE_WARN = "WARN"
  16. ALERT_STATE_ACKNOWLEDGED = "ACKNOWLEDGED"
  17. )
  18. func (this *UpdateAlertStateCommand) IsValidState() bool {
  19. return this.NewState == ALERT_STATE_OK || this.NewState == ALERT_STATE_WARN || this.NewState == ALERT_STATE_ALERT || this.NewState == ALERT_STATE_ACKNOWLEDGED
  20. }
  21. type UpdateAlertStateCommand struct {
  22. AlertId int64 `json:"alertId" binding:"Required"`
  23. NewState string `json:"newState" binding:"Required"`
  24. Info string `json:"info"`
  25. Result *AlertRule
  26. }