pagerduty

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	APIHost    string            `mapstructure:"api_host" yaml:"api_host"`
	Retry      retry.Config      `mapstructure:"retry" yaml:"retry"`
	HTTPClient httpclient.Config `mapstructure:"http_client" yaml:"http_client"`
}

AppConfig is a config loaded when siren is started

func (AppConfig) Validate

func (c AppConfig) Validate() error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg AppConfig, opts ...ClientOption) *Client

func (*Client) NotifyV1

func (c *Client) NotifyV1(ctx context.Context, msg MessageV1) error

type ClientOption

type ClientOption func(*Client)

func ClientWithHTTPClient

func ClientWithHTTPClient(cli *httpclient.Client) ClientOption

ClientWithHTTPClient assigns custom client when creating a pagerduty client

func ClientWithRetrier

func ClientWithRetrier(runner retry.Runner) ClientOption

ClientWithRetrier wraps client call with retrier

type Context

type Context struct {
	Type string `mapstructure:"type" yaml:"type,omitempty" json:"type"`
	Src  string `mapstructure:"src" yaml:"src,omitempty" json:"src"`
	Href string `mapstructure:"href" yaml:"href,omitempty" json:"href"`
	Text string `mapstructure:"text" yaml:"text,omitempty" json:"text"`
	Alt  string `mapstructure:"alt" yaml:"alt,omitempty" json:"alt"`
}

type EvenAction

type EvenAction string
const (
	EvenActionTrigger     EvenAction = "trigger"
	EvenActionAcknowledge EvenAction = "acknowledge"
	EvenActionResolve     EvenAction = "resolve"
)

type MessageV1

type MessageV1 struct {
	ServiceKey  secret.MaskableString  `mapstructure:"service_key" yaml:"service_key,omitempty" json:"service_key,omitempty"`
	EventType   string                 `mapstructure:"event_type" yaml:"event_type,omitempty" json:"event_type,omitempty"`
	IncidentKey string                 `mapstructure:"incident_key" yaml:"incident_key,omitempty" json:"incident_key,omitempty"`
	Description string                 `mapstructure:"description" yaml:"description,omitempty" json:"description,omitempty"`
	Details     map[string]interface{} `mapstructure:"details" yaml:"details,omitempty" json:"details,omitempty"`
	Client      string                 `mapstructure:"client" yaml:"client,omitempty" json:"client,omitempty"`
	ClientURL   string                 `mapstructure:"client_url" yaml:"client_url,omitempty" json:"client_url,omitempty"`
	Contexts    []Context              `mapstructure:"contexts" yaml:"contexts,omitempty" json:"contexts,omitempty"`
}

https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTc4-send-a-v1-event

type NotificationConfig

type NotificationConfig struct {
	ReceiverConfig `mapstructure:",squash"`
}

func (*NotificationConfig) AsMap

func (c *NotificationConfig) AsMap() map[string]interface{}

type PagerDutyCaller

type PagerDutyCaller interface {
	NotifyV1(ctx context.Context, message MessageV1) error
}

type PluginService

type PluginService struct {
	base.UnimplementedService
	// contains filtered or unexported fields
}

func NewPluginService

func NewPluginService(cfg AppConfig, opts ...ServiceOption) *PluginService

func (*PluginService) GetSystemDefaultTemplate

func (s *PluginService) GetSystemDefaultTemplate() string

func (*PluginService) PreHookDBTransformConfigs

func (s *PluginService) PreHookDBTransformConfigs(ctx context.Context, configurations map[string]interface{}) (map[string]interface{}, error)

TODO validation could be done by default and using validator library but we need to use generic for it

func (*PluginService) PreHookQueueTransformConfigs

func (s *PluginService) PreHookQueueTransformConfigs(ctx context.Context, notificationConfigMap map[string]interface{}) (map[string]interface{}, error)

func (*PluginService) Send

func (s *PluginService) Send(ctx context.Context, notificationMessage notification.Message) (bool, error)

type ReceiverConfig

type ReceiverConfig struct {
	ServiceKey secret.MaskableString `mapstructure:"service_key"`
}

TODO need to support versioning later v1 and v2

func (*ReceiverConfig) AsMap

func (c *ReceiverConfig) AsMap() map[string]interface{}

func (*ReceiverConfig) Validate

func (c *ReceiverConfig) Validate() error

type ServiceOption

type ServiceOption func(*PluginService)

func WithHTTPClient

func WithHTTPClient(httpClient *httpclient.Client) ServiceOption

WithHTTPClient assigns custom http client when creating a service

func WithPagerDutyClient

func WithPagerDutyClient(client PagerDutyCaller) ServiceOption

func WithRetrier

func WithRetrier(runner retry.Runner) ServiceOption

WithRetrier wraps client call with retrier

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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