2016-04-28 01:23:50 -05:00
|
|
|
package models
|
|
|
|
|
2016-04-28 03:59:46 -05:00
|
|
|
import (
|
|
|
|
"time"
|
2016-06-06 03:31:21 -05:00
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/alerting/alertstates"
|
2016-04-28 03:59:46 -05:00
|
|
|
)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func (this *UpdateAlertStateCommand) IsValidState() bool {
|
2016-06-06 03:31:21 -05:00
|
|
|
for _, v := range alertstates.ValidStates {
|
2016-05-09 05:10:53 -05:00
|
|
|
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"`
|
|
|
|
|
2016-06-10 03:00:00 -05:00
|
|
|
Result *AlertRuleDAO
|
2016-04-28 01:23:50 -05:00
|
|
|
}
|
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
|
|
|
}
|