opsgenie

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Scheme is the identifying part of this service's configuration URL
	Scheme = "opsgenie"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertPayload

type AlertPayload struct {
	Message     string            `json:"message"`
	Alias       string            `json:"alias,omitempty"`
	Description string            `json:"description,omitempty"`
	Responders  []Entity          `json:"responders,omitempty"`
	VisibleTo   []Entity          `json:"visibleTo,omitempty"`
	Actions     []string          `json:"actions,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Details     map[string]string `json:"details,omitempty"`
	Entity      string            `json:"entity,omitempty"`
	Source      string            `json:"source,omitempty"`
	Priority    string            `json:"priority,omitempty"`
	User        string            `json:"user,omitempty"`
	Note        string            `json:"note,omitempty"`
}

AlertPayload represents the payload being sent to the OpsGenie API

See: https://docs.opsgenie.com/docs/alert-api#create-alert

Some fields contain complex values like arrays and objects. Because `params` are strings only we cannot pass in slices or maps. Instead we "preserve" the JSON in those fields. That way we can pass in complex types as JSON like so:

service.Send("An example alert message", &types.Params{
	"alias":       "Life is too short for no alias",
	"description": "Every alert needs a description",
	"responders":  `[{"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c","type":"team"},{"name":"NOC","type":"team"}]`,
	"visibleTo":   `[{"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c","type":"team"},{"name":"rocket_team","type":"team"}]`,
	"details":     `{"key1": "value1", "key2": "value2"}`,
})

type Config

type Config struct {
	APIKey      string            `url:"path" desc:"The OpsGenie API key"`
	Host        string            `url:"host" desc:"The OpsGenie API host. Use 'api.eu.opsgenie.com' for EU instances" default:"api.opsgenie.com"`
	Port        uint16            `url:"port" desc:"The OpsGenie API port." default:"443"`
	Alias       string            `key:"alias" desc:"Client-defined identifier of the alert" optional:"true"`
	Description string            `key:"description" desc:"Description field of the alert" optional:"true"`
	Responders  []Entity          `` /* 131-byte string literal not displayed */
	VisibleTo   []Entity          `key:"visibleTo" desc:"Teams and users that the alert will become visible to without sending any notification" optional:"true"`
	Actions     []string          `key:"actions" desc:"Custom actions that will be available for the alert" optional:"true"`
	Tags        []string          `key:"tags" desc:"Tags of the alert" optional:"true"`
	Details     map[string]string `key:"details" desc:"Map of key-value pairs to use as custom properties of the alert" optional:"true"`
	Entity      string            `` /* 138-byte string literal not displayed */
	Source      string            `key:"source" desc:"Source field of the alert" optional:"true"`
	Priority    string            `key:"priority" desc:"Priority level of the alert. Possible values are P1, P2, P3, P4 and P5" optional:"true"`
	Note        string            `key:"note" desc:"Additional note that will be added while creating the alert" optional:"true"`
	User        string            `key:"user" desc:"Display name of the request owner" optional:"true"`
	Title       string            `key:"title" default:"" desc:"notification title, optionally set by the sender"`
}

Config for use within the opsgenie service

func (Config) Enums

func (config Config) Enums() map[string]types.EnumFormatter

Enums returns an empty map because the OpsGenie service doesn't use Enums

func (*Config) GetURL

func (config *Config) GetURL() *url.URL

GetURL is the public version of getURL that creates a new PropKeyResolver when accessed from outside the package

func (*Config) SetURL

func (config *Config) SetURL(url *url.URL) error

SetURL updates a ServiceConfig from a URL representation of it's field values

type Entity

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

Entity represents either a user or a team

The different variations are:

{ "id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c", "type":"team" } { "name":"rocket_team", "type":"team" } { "id":"bb4d9938-c3c2-455d-aaab-727aa701c0d8", "type":"user" } { "username":"trinity@opsgenie.com", "type":"user" }

func (*Entity) GetPropValue

func (e *Entity) GetPropValue() (string, error)

GetPropValue serializes an entity

func (*Entity) SetFromProp

func (e *Entity) SetFromProp(propValue string) error

SetFromProp deserializes an entity

type Service

type Service struct {
	standard.Standard
	// contains filtered or unexported fields
}

Service providing OpsGenie as a notification service

func (*Service) Initialize

func (service *Service) Initialize(configURL *url.URL, logger types.StdLogger) error

Initialize loads ServiceConfig from configURL and sets logger for this Service

func (*Service) Send

func (service *Service) Send(message string, params *types.Params) error

Send a notification message to OpsGenie See: https://docs.opsgenie.com/docs/alert-api#create-alert

Jump to

Keyboard shortcuts

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