2016-04-28 01:23:50 -05:00
|
|
|
package models
|
|
|
|
|
2016-04-28 03:59:46 -05:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2016-04-28 01:23:50 -05:00
|
|
|
|
|
|
|
type AlertStateLog struct {
|
2016-04-28 03:59:46 -05:00
|
|
|
Id int64 `json:"-"`
|
|
|
|
OrgId int64 `json:"-"`
|
|
|
|
AlertId int64 `json:"alertId"`
|
|
|
|
NewState string `json:"newState"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
Info string `json:"info"`
|
2016-04-28 01:23:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
ALERT_STATE_OK = "OK"
|
2016-05-02 07:33:38 -05:00
|
|
|
ALERT_STATE_CRITICAL = "CRITICAL"
|
2016-04-28 01:23:50 -05:00
|
|
|
ALERT_STATE_WARN = "WARN"
|
|
|
|
ALERT_STATE_ACKNOWLEDGED = "ACKNOWLEDGED"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (this *UpdateAlertStateCommand) IsValidState() bool {
|
2016-05-02 07:33:38 -05:00
|
|
|
return this.NewState == ALERT_STATE_OK || this.NewState == ALERT_STATE_WARN || this.NewState == ALERT_STATE_CRITICAL || this.NewState == ALERT_STATE_ACKNOWLEDGED
|
2016-04-28 01:23:50 -05:00
|
|
|
}
|
|
|
|
|
2016-04-28 03:59:46 -05:00
|
|
|
// Commands
|
|
|
|
|
2016-04-28 01:23:50 -05:00
|
|
|
type UpdateAlertStateCommand struct {
|
|
|
|
AlertId int64 `json:"alertId" binding:"Required"`
|
|
|
|
NewState string `json:"newState" binding:"Required"`
|
|
|
|
Info string `json:"info"`
|
|
|
|
|
|
|
|
Result *AlertRule
|
|
|
|
}
|
2016-04-28 03:59:46 -05:00
|
|
|
|
|
|
|
// Queries
|
|
|
|
|
|
|
|
type GetAlertsStateLogCommand struct {
|
|
|
|
OrgId int64 `json:"orgId" binding:"Required"`
|
|
|
|
AlertId int64 `json:"alertId" binding:"Required"`
|
|
|
|
|
|
|
|
Result *[]AlertStateLog
|
|
|
|
}
|