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
|
|
|
|
2016-05-04 07:58:00 -05:00
|
|
|
type AlertState 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 (
|
2016-05-25 10:21:20 -05:00
|
|
|
VALID_STATES = []string{
|
2016-05-26 00:41:23 -05:00
|
|
|
AlertStateOk,
|
|
|
|
AlertStateWarn,
|
|
|
|
AlertStateCritical,
|
|
|
|
AlertStateAcknowledged,
|
|
|
|
AlertStateMaintenance,
|
2016-05-25 10:21:20 -05:00
|
|
|
}
|
|
|
|
|
2016-05-26 00:41:23 -05:00
|
|
|
AlertStateOk = "OK"
|
|
|
|
AlertStateWarn = "WARN"
|
|
|
|
AlertStateCritical = "CRITICAL"
|
|
|
|
AlertStateAcknowledged = "ACKNOWLEDGED"
|
|
|
|
AlertStateMaintenance = "MAINTENANCE"
|
2016-06-03 02:04:20 -05:00
|
|
|
AlertStatePending = "PENDING"
|
2016-04-28 01:23:50 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func (this *UpdateAlertStateCommand) IsValidState() bool {
|
2016-05-09 05:10:53 -05:00
|
|
|
for _, v := range VALID_STATES {
|
|
|
|
if this.NewState == v {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
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
|
|
|
|
|
2016-05-09 07:30:28 -05:00
|
|
|
type GetAlertsStateQuery struct {
|
2016-04-28 03:59:46 -05:00
|
|
|
OrgId int64 `json:"orgId" binding:"Required"`
|
|
|
|
AlertId int64 `json:"alertId" binding:"Required"`
|
|
|
|
|
2016-05-04 07:58:00 -05:00
|
|
|
Result *[]AlertState
|
2016-04-28 03:59:46 -05:00
|
|
|
}
|