mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type AlertState struct {
|
|
Id int64 `json:"-"`
|
|
OrgId int64 `json:"-"`
|
|
AlertId int64 `json:"alertId"`
|
|
NewState string `json:"newState"`
|
|
Created time.Time `json:"created"`
|
|
Info string `json:"info"`
|
|
}
|
|
|
|
var (
|
|
ALERT_STATE_OK = "OK"
|
|
ALERT_STATE_CRITICAL = "CRITICAL"
|
|
ALERT_STATE_WARN = "WARN"
|
|
ALERT_STATE_ACKNOWLEDGED = "ACKNOWLEDGED"
|
|
)
|
|
|
|
func (this *UpdateAlertStateCommand) IsValidState() bool {
|
|
return this.NewState == ALERT_STATE_OK || this.NewState == ALERT_STATE_WARN || this.NewState == ALERT_STATE_CRITICAL || this.NewState == ALERT_STATE_ACKNOWLEDGED
|
|
}
|
|
|
|
// Commands
|
|
|
|
type UpdateAlertStateCommand struct {
|
|
AlertId int64 `json:"alertId" binding:"Required"`
|
|
NewState string `json:"newState" binding:"Required"`
|
|
Info string `json:"info"`
|
|
|
|
Result *AlertRule
|
|
}
|
|
|
|
// Queries
|
|
|
|
type GetAlertsStateCommand struct {
|
|
OrgId int64 `json:"orgId" binding:"Required"`
|
|
AlertId int64 `json:"alertId" binding:"Required"`
|
|
|
|
Result *[]AlertState
|
|
}
|