grafana/pkg/models/alert_notifications.go

116 lines
3.3 KiB
Go
Raw Normal View History

2016-06-13 09:39:00 -05:00
package models
import (
2018-05-25 13:14:33 -05:00
"errors"
2016-06-13 09:39:00 -05:00
"time"
"github.com/grafana/grafana/pkg/components/simplejson"
)
2018-05-25 13:14:33 -05:00
var (
ErrNotificationFrequencyNotFound = errors.New("Notification frequency not specified")
ErrAlertNotificationStateNotFound = errors.New("alert notification state not found")
ErrAlertNotificationStateVersionConflict = errors.New("alert notification state update version conflict")
ErrAlertNotificationStateAlreadyExist = errors.New("alert notification state already exists.")
)
type AlertNotificationStateType string
var (
AlertNotificationStatePending = AlertNotificationStateType("pending")
AlertNotificationStateCompleted = AlertNotificationStateType("completed")
AlertNotificationStateUnknown = AlertNotificationStateType("unknown")
2018-05-25 13:14:33 -05:00
)
2016-06-13 09:39:00 -05:00
type AlertNotification struct {
Id int64 `json:"id"`
OrgId int64 `json:"-"`
Name string `json:"name"`
Type string `json:"type"`
SendReminder bool `json:"sendReminder"`
Frequency time.Duration `json:"frequency"`
IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
2016-06-13 09:39:00 -05:00
}
type CreateAlertNotificationCommand struct {
Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"`
Frequency string `json:"frequency"`
IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings"`
2016-06-13 09:39:00 -05:00
OrgId int64 `json:"-"`
2016-06-13 09:39:00 -05:00
Result *AlertNotification
}
type UpdateAlertNotificationCommand struct {
Id int64 `json:"id" binding:"Required"`
Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"`
Frequency string `json:"frequency"`
IsDefault bool `json:"isDefault"`
Settings *simplejson.Json `json:"settings" binding:"Required"`
2016-06-13 09:39:00 -05:00
OrgId int64 `json:"-"`
2016-06-13 09:39:00 -05:00
Result *AlertNotification
}
type DeleteAlertNotificationCommand struct {
Id int64
OrgId int64
}
type GetAlertNotificationsQuery struct {
Name string
Id int64
OrgId int64
Result *AlertNotification
}
type GetAlertNotificationsToSendQuery struct {
Ids []int64
OrgId int64
2016-06-13 09:39:00 -05:00
Result []*AlertNotification
}
type GetAllAlertNotificationsQuery struct {
OrgId int64
Result []*AlertNotification
}
2018-09-26 10:26:02 -05:00
type AlertNotificationState struct {
Id int64
OrgId int64
AlertId int64
NotifierId int64
State AlertNotificationStateType
Version int64
UpdatedAt int64
AlertRuleStateUpdatedVersion int64
}
type SetAlertNotificationStateToPendingCommand struct {
AlertRuleStateUpdatedVersion int64
State *AlertNotificationState
}
type SetAlertNotificationStateToCompleteCommand struct {
State *AlertNotificationState
}
2018-09-26 10:26:02 -05:00
type GetNotificationStateQuery struct {
OrgId int64
AlertId int64
NotifierId int64
2018-09-26 10:26:02 -05:00
Result *AlertNotificationState
}