notificationv2

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2019 License: Apache-2.0, GPL-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// List of time restrictions within alerts will be sent.
	TimeOfDayTimeRestriction           = "time-of-day"
	WeekendAndTimeOfDayTimeRestriction = "weekday-and-time-of-day"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResult

type ActionResult struct {
	Result Result `json:"result"`
}

ActionResult contains result of action with notification rule.

type ActionType

type ActionType string

ActionType is the type of notification action. Instead of

const (
	// Types of action that notification rule will have after creating. It is used to create an alert.
	CreateAlertActionType         ActionType = "create-alert"
	AcknowledgedAlertActionType   ActionType = "acknowledged-alert"
	ClosedAlertActionType         ActionType = "closed-alert"
	AssignedAlertActionType       ActionType = "assigned-alert"
	AddNoteActionType             ActionType = "add-note"
	ScheduleStartActionType       ActionType = "schedule-start"
	ScheduleEndActionType         ActionType = "schedule-end"
	IncomingCallRoutingActionType ActionType = "incoming-call-routing"
)

type Condition

type Condition struct {
	Field         Field     `json:"field"`
	Key           string    `json:"key"`
	Not           bool      `json:"not"`
	Operation     Operation `json:"operation"`
	ExpectedValue string    `json:"expectedValue"`
	Order         int       `json:"order"`
}

Condition defines the conditions that will be checked before applying notification rules.

type ConditionType

type ConditionType string

ConditionType is a type of matching of alert fields, which is used for building criteria of notification.

const (
	// The list of matches which are used for creating criteria of notification.
	MatchAllType           ConditionType = "match-all"
	MatchAnyConditionsType ConditionType = "match-any-condition"
	MatchAllConditionsType ConditionType = "match-all-conditions"
)

type Contact

type Contact struct {
	Method Method `json:"method,omitempty"`
	To     string `json:"to,omitempty"`
}

Contact defines the contact that notification will be sent to.

type CreateNotificationRequest

type CreateNotificationRequest struct {
	*Identifier
	ApiKey           string
	Name             string             `json:"name"`
	ActionType       ActionType         `json:"actionType"`
	Criteria         Criteria           `json:"criteria"`
	NotificationTime []NotificationTime `json:"notificationTime"`
	TimeRestriction  TimeRestriction    `json:"timeRestriction"`
	Schedules        []Schedule         `json:"schedules"`
	Order            int                `json:"order"`
	Steps            []Step             `json:"steps"`
	Repeat           Repeat             `json:"repeat"`
	Enabled          bool               `json:"enabled"`
}

CreateNotificationRequest is a struct of request to crate new notification rule.

func (*CreateNotificationRequest) GenerateUrl

func (r *CreateNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*CreateNotificationRequest) GetApiKey

func (r *CreateNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type CreateNotificationResponse

type CreateNotificationResponse struct {
	ResponseMeta
	Notification Notification `json:"data"`
}

CreateNotificationResponse is a response of creating alert action.

type Criteria

type Criteria struct {
	Type       ConditionType `json:"type"`
	Conditions []Condition   `json:"conditions"`
}

Criteria defines the conditions that will be checked before applying notification rules and type of the operations that will be applied on these conditions.

type Day

type Day string

Day is the text representation of day name of week.

const (
	// The list of week days. These strings are used for generate time restrictions.
	Monday    Day = "monday"
	Tuesday   Day = "tuesday"
	Wednesday Day = "wednesday"
	Thursday  Day = "thursday"
	Friday    Day = "friday"
	Saturday  Day = "saturday"
	Sunday    Day = "sunday"
)

type DeleteNotificationRequest

type DeleteNotificationRequest struct {
	*Identifier
	ApiKey string
}

DeleteNotificationRequest is a struct of request to delete existing notification rule.

func (*DeleteNotificationRequest) GenerateUrl

func (r *DeleteNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*DeleteNotificationRequest) GetApiKey

func (r *DeleteNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type DeleteNotificationResponse

type DeleteNotificationResponse struct {
	ResponseMeta
	ActionResult
}

DeleteNotificationResponse is a struct, which contains result of notification rule deleting.

type DisableNotificationRequest

type DisableNotificationRequest struct {
	*Identifier
	ApiKey string
}

DisableNotificationRequest is a struct of request to disable specified notification rule.

func (*DisableNotificationRequest) GenerateUrl

func (r *DisableNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*DisableNotificationRequest) GetApiKey

func (r *DisableNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type DisableNotificationResponse

type DisableNotificationResponse struct {
	ResponseMeta
	ActionResult
}

DisableNotificationResponse is a response, which contains result of notification rule disabling.

type EnableNotificationRequest

type EnableNotificationRequest struct {
	*Identifier
	ApiKey string
}

EnableNotificationRequest is a struct of request to enable specified notification rule.

func (*EnableNotificationRequest) GenerateUrl

func (r *EnableNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*EnableNotificationRequest) GetApiKey

func (r *EnableNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type EnableNotificationResponse

type EnableNotificationResponse struct {
	ResponseMeta
	ActionResult
}

EnableNotificationResponse is a response, which contains result of notification rule enabling.

type Field

type Field string

Field is the name of alert field, which is used to build filter of alerts.

const (
	// The list of fields, which are used for build filter of alerts.
	ActionsField         Field = "actions"
	AliasField           Field = "alias"
	DescriptionField     Field = "description"
	EntityField          Field = "entity"
	MessageField         Field = "message"
	RecipientsField      Field = "recipients"
	SourceField          Field = "source"
	TeamsField           Field = "teams"
	ExtraPropertiesField Field = "extra-properties"
)

type GetNotificationRequest

type GetNotificationRequest struct {
	*Identifier
	ApiKey string
}

GetNotificationRequest is a struct of request to get notification rule.

func (*GetNotificationRequest) GenerateUrl

func (r *GetNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*GetNotificationRequest) GetApiKey

func (r *GetNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type GetNotificationResponse

type GetNotificationResponse struct {
	ResponseMeta
	Notification *Notification `json:"data"`
}

GetNotificationResponse is a response of getting notification rule.

type Identifier

type Identifier struct {
	UserID   string `json:"-"`
	Username string `json:"-"`
	RuleID   string `json:"-"`
}

Identifier defined the set of attributes for identification notification.

func (*Identifier) GenerateUrl

func (request *Identifier) GenerateUrl() (string, url.Values, error)

GenerateUrl generates API url using specified attributes of identifier.

type ListNotificationRequest

type ListNotificationRequest struct {
	*Identifier
	ApiKey string
}

ListNotificationRequest is a struct of request to get list of existing notification rules.

func (*ListNotificationRequest) GenerateUrl

func (r *ListNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*ListNotificationRequest) GetApiKey

func (r *ListNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type ListNotificationResponse

type ListNotificationResponse struct {
	ResponseMeta
	Notifications []Notification `json:"data"`
}

ListNotificationResponse is a response of getting notification rules list.

type Method

type Method string

Method is a method of notification.

const (
	// The list of notification method.
	SMSNotifyMethod    Method = "sms"
	EmailNotifyMethod  Method = "email"
	VoiceNotifyMethod  Method = "voice"
	MobileNotifyMethod Method = "mobile"
)

type Notification

type Notification struct {
	ID               string             `json:"id,omitempty"`
	Name             string             `json:"name,omitempty"`
	ActionType       ActionType         `json:"actionType,omitempty"`
	NotificationTime []NotificationTime `json:"notificationTime,omitempty"`
	Order            int                `json:"order,omitempty"`
	Steps            []Step             `json:"steps,omitempty"`
	Schedules        []Schedule         `json:"schedules,omitempty"`
	Criteria         Criteria           `json:"criteria,omitempty"`
	Enabled          bool               `json:"enabled,omitempty"`
	Repeat           Repeat             `json:"repeat,omitempty"`
	TimeRestriction  TimeRestriction    `json:"timeRestriction,omitempty"`
}

Notification describes alert data, which is contained in a response.

type NotificationTime

type NotificationTime string

NotificationTime is type of time periods that notification for start/end will be sent.

const (
	// List of time periods that notification for schedule start/end will be sent.
	JustBeforeNotificationTime        NotificationTime = "just-before"
	FifteenMinutesAgoNotificationTime NotificationTime = "15-minutes-ago"
	OneHourAgoNotificationTime        NotificationTime = "1-hour-ago"
	OneDayAgoNotificationTime         NotificationTime = "1-day-ago"
)

type Operation

type Operation string

Operation is type of matching operation, which is used to build filter of alerts.

const (
	// The list of condition operation, which are used for build notification criteria.
	MatchesConditionOperation                Operation = "matches"
	EqualsConditionOperation                 Operation = "equals"
	IsEmptyConditionOperation                Operation = "is-empty"
	ContainsConditionOperation               Operation = "contains"
	StartsWithConditionOperation             Operation = "starts-with"
	EqualsIgnoreWhitespaceConditionOperation Operation = "equals-ignore-whitespace"
	GreaterThanConditionOperation            Operation = "greater-than"
	LessThanConditionOperation               Operation = "less-than"
)

type Repeat

type Repeat struct {
	LoopAfter int  `json:"loopAfter"`
	Enabled   bool `json:"enabled"`
}

Repeat defines the amount of time in minutes that notification steps will be repeatedly apply.

type ResponseMeta

type ResponseMeta struct {
	RequestID      string
	ResponseTime   float32
	RateLimitState string
}

ResponseMeta contains meta data of response.

func (*ResponseMeta) SetRateLimitState

func (rm *ResponseMeta) SetRateLimitState(state string)

SetRateLimitState sets state of rate limit.

func (*ResponseMeta) SetRequestID

func (rm *ResponseMeta) SetRequestID(requestID string)

SetRequestID sets identifier of request.

func (*ResponseMeta) SetResponseTime

func (rm *ResponseMeta) SetResponseTime(responseTime float32)

SetResponseTime sets request execution time.

type Restriction

type Restriction struct {
	StartDay  Day `json:"startDay,omitempty"`
	EndDay    Day `json:"endDay,omitempty"`
	StartHour int `json:"startHour,omitempty"`
	EndHour   int `json:"endHour,omitempty"`
	StartMin  int `json:"startMin,omitempty"`
	EndMin    int `json:"endMin,omitempty"`
}

Restriction defines start and end times.

type Result

type Result string

Result contains string status of notification action result.

const (
	// The list of action results.
	EnabledResult Result = "Enabled"
	DisableResult Result = "Disabled"
	DeletedResult Result = "Deleted"
)

type Schedule

type Schedule struct {
	ID   string `json:"id,omitempty"`
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
}

Schedule defines name and id of schedule. The field "type" is mandatory and should be set as "schedule".

type SendAfter

type SendAfter struct {
	TimeAmount int      `json:"timeAmount,omitempty"`
	TimeUnit   TimeUnit `json:"timeUnit,omitempty"`
}

SendAfter defines minute time period notification will be sent after.

type Step

type Step struct {
	ID        string    `json:"id"`
	Contact   Contact   `json:"contact,omitempty"`
	SendAfter SendAfter `json:"sendAfter,omitempty"`
	Enabled   bool      `json:"enabled,omitempty"`
}

Step is an action that will be added to notification rule.

type TimeRestriction

type TimeRestriction struct {
	Type         TypeRestriction `json:"type,omitempty"`
	Restrictions []Restriction   `json:"restrictions,omitempty"`
	Restriction  Restriction     `json:"restriction, omitempty"`
}

TimeRestriction is used to limit notification rules to certain day and time of the week, using multiple start and end times for each day of the week.

type TimeUnit

type TimeUnit string
const (
	Hours   TimeUnit = "hours"
	Minutes TimeUnit = "minutes"
	Seconds TimeUnit = "seconds"
)

type TypeRestriction

type TypeRestriction string

TypeRestriction is a type of restriction, within alerts will be sent.

type UpdateNotificationRequest

type UpdateNotificationRequest struct {
	*Identifier
	ApiKey           string
	Name             string             `json:"name"`
	Criteria         Criteria           `json:"criteria"`
	NotificationTime []NotificationTime `json:"notificationTime"`
	TimeRestriction  TimeRestriction    `json:"timeRestriction"`
	Schedules        []Schedule         `json:"schedules"`
	Steps            []Step             `json:"steps"`
	Repeat           Repeat             `json:"repeat"`
	Order            int                `json:"order"`
	Enabled          bool               `json:"enabled"`
}

UpdateNotificationRequest is a struct of request to update existing notification rule.

func (*UpdateNotificationRequest) GenerateUrl

func (r *UpdateNotificationRequest) GenerateUrl() (string, url.Values, error)

GenerateUrl generates url to API endpoint.

func (*UpdateNotificationRequest) GetApiKey

func (r *UpdateNotificationRequest) GetApiKey() string

GetApiKey returns api key.

type UpdateNotificationResponse

type UpdateNotificationResponse struct {
	ResponseMeta
	Notification Notification `json:"data"`
}

UpdateNotificationResponse is a response of updating notification rule.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL