notify

package
v0.0.0-...-4a54890 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ContentLength   = "Content-Length"
	FormContentType = "application/x-www-form-urlencoded"
	JsonContentType = "application/json"
)

Variables

View Source
var (
	NotificationsList []Notify
)

Functions

func AddHeaders

func AddHeaders(req *http.Request, headers map[string]string)

func AddNew

func AddNew(notificationTypes NotificationTypes)

Add model.Notification clients given by user in config file to model.NotificationsList

func GetJsonParamsBody

func GetJsonParamsBody(msgParam MessageParam) (io.Reader, error)

func GetUrlValues

func GetUrlValues(msgParam MessageParam) url.Values

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

func Priority

func Priority(priority string) alertsv2.Priority

func SendErrorNotification

func SendErrorNotification(errorNotification model.ErrorNotification)

Send Error model.Notification to all clients registered

func SendNotification

func SendNotification(notification model.Notification)

Format model.Notification type and send

func SendResponseTimeNotification

func SendResponseTimeNotification(responseTimeNotification model.ResponseTimeNotification)

Send response time model.Notification to all clients registered

func SendTestNotification

func SendTestNotification()

Send Test model.Notification to all registered clients .To make sure everything is working

Types

type HttpNotify

type HttpNotify struct {
	Url         string            `json:"url"`
	RequestType string            `json:"requestType"`
	Headers     map[string]string `json:"headers"`
}

func (HttpNotify) GetClientName

func (httpNotify HttpNotify) GetClientName() string

func (HttpNotify) Initialize

func (httpNotify HttpNotify) Initialize() error

func (HttpNotify) SendErrorNotification

func (httpNotify HttpNotify) SendErrorNotification(errorNotification model.ErrorNotification) error

func (HttpNotify) SendResponseTimeNotification

func (httpNotify HttpNotify) SendResponseTimeNotification(responseTimeNotification model.ResponseTimeNotification) error

type MailNotify

type MailNotify struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"smtpHost"`
	Port     int    `json:"port"`
	From     string `json:"from"`
	To       string `json:"to"`
}

func (MailNotify) GetClientName

func (mailNotify MailNotify) GetClientName() string

func (MailNotify) Initialize

func (mailNotify MailNotify) Initialize() error

func (MailNotify) SendErrorNotification

func (mailNotify MailNotify) SendErrorNotification(errorNotification model.ErrorNotification) error

func (MailNotify) SendResponseTimeNotification

func (mailNotify MailNotify) SendResponseTimeNotification(responseTimeNotification model.ResponseTimeNotification) error

type MessageParam

type MessageParam struct {
	Message string `json:"message"`
}

type NewIncident

type NewIncident struct {
	Priority string `json:""`
	// contains filtered or unexported fields
}

type NotificationTypes

type NotificationTypes struct {
	MailNotify MailNotify     `json:"mail"`
	Slack      SlackNotify    `json:"slack"`
	Http       HttpNotify     `json:"httpEndPoint"`
	Opsgenie   OpsgenieNotify `json:"opsgenie"`
	Samanage   SamanageNotify `json:"samanage"`
}

Diffrent types of clients to deliver model.Notifications

type Notify

type Notify interface {
	GetClientName() string
	Initialize() error
	SendNotification(notification model.Notification) error

	SendResponseTimeNotification(notification model.ResponseTimeNotification) error
	SendResponseCodeNotification(notification model.ResponseCodeNotification) error
	SendResponseBodyNotification(notification model.ResponseBodyNotification) error
	SendErrorNotification(notification model.ErrorNotification) error
}

type OpsgenieNotify

type OpsgenieNotify struct {
	APIKey string `json:"apikey"`
	Alias  string `json:"alias"`
}

func (OpsgenieNotify) GetClientName

func (opsgenieNotify OpsgenieNotify) GetClientName() string

func (OpsgenieNotify) Initialize

func (opsgenieNotify OpsgenieNotify) Initialize() error

func (OpsgenieNotify) SendNotification

func (opsgenieNotify OpsgenieNotify) SendNotification(notification model.Notification) error

type SamanageAPIHeader

type SamanageAPIHeader string
const (
	SamanageUrl              SamanageAPIHeader = "https://api.samanage.com/"
	SamanageTokenKey         SamanageAPIHeader = "X-Samanage-Authorization"
	SamanageAcceptAPIKey     SamanageAPIHeader = "Accept"
	SamanageAcceptAPIValue   SamanageAPIHeader = "application/vnd.samanage.v2.1+json"
	SamanageContentTypeKey   SamanageAPIHeader = "Content-Type"
	SamanageContentTypeValue SamanageAPIHeader = "application/json"
)

func (SamanageAPIHeader) String

func (h SamanageAPIHeader) String() string

type SamanageNotify

type SamanageNotify struct {
	RequestType        string            `json:"requestType"`
	Headers            map[string]string `json:"headers"`
	SamanageTokenValue SamanageAPIHeader `json:"token"`
}

func (SamanageNotify) GetClientName

func (samanageNotify SamanageNotify) GetClientName() string

func (SamanageNotify) Initialize

func (samanageNotify SamanageNotify) Initialize() error

func (SamanageNotify) SendErrorNotification

func (samanageNotify SamanageNotify) SendErrorNotification(errorNotification model.ErrorNotification) error

func (SamanageNotify) SendResponseTimeNotification

func (samanageNotify SamanageNotify) SendResponseTimeNotification(responseTimeNotification model.ResponseTimeNotification) error

type SlackNotify

type SlackNotify struct {
	Username          string `json:"username"`
	ChannelName       string `json:"channelName"` //Not mandatory field
	ChannelWebhookURL string `json:"channelWebhookURL"`
	IconUrl           string `json:"iconUrl"`
}

func (SlackNotify) GetClientName

func (slackNotify SlackNotify) GetClientName() string

func (SlackNotify) Initialize

func (slackNotify SlackNotify) Initialize() error

func (SlackNotify) SendErrorNotification

func (slackNotify SlackNotify) SendErrorNotification(errorNotification model.ErrorNotification) error

func (SlackNotify) SendResponseTimeNotification

func (slackNotify SlackNotify) SendResponseTimeNotification(responseTimeNotification model.ResponseTimeNotification) error

Jump to

Keyboard shortcuts

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