pagerduty

package
v0.0.0-...-2b3799d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CacheKey = `pagerduty.policy_cache`

the key name used for caching the full escalation policy

View Source
const DefaultCacheInterval = "1h"
View Source
const DefaultTopicInterval = "10m"
View Source
const OncallUsage = `` /* 188-byte string literal not displayed */
View Source
const PageDefaultMessage = `your presence is requested in the chat room`
View Source
const PageUsage = `` /* 425-byte string literal not displayed */
View Source
const PagerdutyTokenKey = `pagerduty.token`

the hal.secrets key that should contain the pagerduty auth token

View Source
const V1EventEndpoint = `https://events.pagerduty.com/generic/2010-04-15/create_event.json`

https://developer.pagerduty.com/documentation/integration/events/trigger

View Source
const V2EventEndpoint = `https://events.pagerduty.com/v2/enqueue`

https://v2.developer.pagerduty.com/docs/events-api-v2

Variables

This section is empty.

Functions

func Register

func Register()

Types

type ContactMethod

type ContactMethod struct {
	Id             string `json:"id"`
	Type           string `json:"type"`
	Label          string `json:"label"`
	Address        string `json:"address"`
	SendShortEmail bool   `json:"send_short_email"`
}

type Context

type Context interface {
	GetType() string
}

Context is an interface for the contexts field in V1 PD events.

type ContextImage

type ContextImage struct {
	Type string `json:"type"`
	Src  string `json:"src"`
	Href string `json:"href,omitempty"`
	Alt  string `json:"alt,omitempty"`
}

func (*ContextImage) GetType

func (c *ContextImage) GetType() string
type ContextLink struct {
	Type string `json:"type"`
	Href string `json:"href"`
	Text string `json:"text,omitempty"`
}

func (*ContextLink) GetType

func (c *ContextLink) GetType() string

type Error

type Error struct {
	Message string   `json:"message"`
	Code    int      `json:"code"`
	Errors  []string `json:"errors"`
}

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

type EscalationPolicy

type EscalationPolicy struct {
	Id              string           `json:"id"`
	Summary         string           `json:"summary"`
	Type            string           `json:"type"`
	Self            string           `json:"self"`
	HtmlUrl         string           `json:"html_url"`
	Name            string           `json:"name"`
	Description     string           `json:"description"`
	NumLoops        int              `json:"num_loops"`
	RepeatEnabled   bool             `json:"repeat_enabled"`
	EscalationRules []EscalationRule `json:"escalation_rules"`
	ServiceRefs     []ServiceRef     `json:"services"`
	TeamRefs        []TeamRef        `json:"teams"`
}

func GetEscalationPolicies

func GetEscalationPolicies(token string, params map[string][]string) ([]EscalationPolicy, error)

type EscalationPolicyRef

type EscalationPolicyRef struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Self    string `json:"self"`
	HtmlUrl string `json:"html_url"`
}

type EscalationPolicyResponse

type EscalationPolicyResponse struct {
	EscalationPolicies []EscalationPolicy `json:"escalation_policies"`
	Offset             int                `json:"offset"`
	Limit              int                `json:"limit"`
	More               bool               `json:"more"`
	Total              int                `json:"total,omitempty"`
}

type EscalationRule

type EscalationRule struct {
	Id                       string             `json:"id"`
	EscalationDelayInMinutes int                `json:"escalation_delay_in_minutes"`
	Targets                  []EscalationTarget `json:"targets"`
}

type EscalationTarget

type EscalationTarget struct {
	Id   string `json:"id"`
	Type string `json:"type"`
}

type Event

type Event struct {
	ServiceKey  string                 `json:"service_key"`
	EventType   string                 `json:"event_type"`
	Description string                 `json:"description"`
	IncidentKey string                 `json:"incident_key,omitempty"`
	Details     map[string]interface{} `json:"details,omitempty"` // arbitrary json
	Client      string                 `json:"client,omitempty"`
	ClientUrl   string                 `json:"client_url,omitempty"`
	Contexts    []Context              `json:"contexts,omitempty"`
}

func NewAck

func NewAck(serviceKey, description string) *Event

func NewEvent

func NewEvent(serviceKey, eventType, description string) *Event

NewEvent returns an initialized Event structure. You probably don't want to use this and instead use NewTrigger/NewAck/NewResolve.

func NewResolve

func NewResolve(serviceKey, description string) *Event

func NewTrigger

func NewTrigger(serviceKey, description string) *Event

func (*Event) Send

func (e *Event) Send(token string) (*Response, error)

Send posts the event to Pagerduty using the provided token.

type EventBody

type EventBody struct {
	RoutingKey string       `json:"routing_key"`
	Action     string       `json:"event_action"`        // e.g. "trigger"
	DedupKey   string       `json:"dedup_key,omitempty"` // arbitrary key for server-side dedup
	Payload    EventPayload `json:"payload"`
	Images     []EventImage `json:"images"`
	Client     string       `json:"client"`     // e.g. "Scorebot/#core"
	ClientUrl  string       `json:"client_url"` // e.g. "https://scorebot.prod.netflix.net"
}

func NewV2Event

func NewV2Event(routingKey string) *EventBody

func (*EventBody) Send

func (eb *EventBody) Send(token string) (EventResult, error)

type EventImage

type EventImage struct {
	Src  string `json:"src"`
	Href string `json:"href"`
	Alt  string `json:"alt"`
}

type EventPayload

type EventPayload struct {
	Summary   string            `json:"summary"`             // high-level text
	Severity  string            `json:"severity"`            // enum: info, warning, error, critical
	Source    string            `json:"source,omitempty"`    // e.g. hostname, IP, ARN
	Component string            `json:"component,omitempty"` // e.g. "mysql", "keepalive"
	Group     string            `json:"group,omitempty"`     // e.g. "www", "prod-data"
	Class     string            `json:"class,omitempty"`     // e.g. "High CPU", "Latency"
	Custom    map[string]string `json:"custom_details"`
}

data structures for the PagerDuty Common Event Format Timestamp

type EventResult

type EventResult struct {
	Status     string `json:"status"`    // e.g. "success"
	Message    string `json:"message"`   // e.g. "Event processed"
	DedupKey   string `json:"dedup_key"` // a uuid-ish key
	StatusCode int    `json:"-"`
}

type IncidentCounts

type IncidentCounts struct {
	Triggered    int `json:"triggered"`
	Acknowledged int `json:"acknowledged"`
	Resolved     int `json:"resolved"`
	Total        int `json:"total"`
}

type Integration

type Integration struct {
	Id               string `json:"id"`
	Type             string `json:"type"`
	Summary          string `json:"summary"`
	Self             string `json:"self"`
	HtmlUrl          string `json:"html_url"`
	Name             string `json:"name"`
	CreatedAt        string `json:"created_at"`
	IntegrationKey   string `json:"integration_key"`
	IntegrationEmail string `json:"integration_email"`
}

type NotificationRule

type NotificationRule struct {
	Id                  string        `json:"id"`
	Type                string        `json:"type"`
	StartDelayInMinutes int           `json:"start_delay_in_minutes"`
	CreatedAt           string        `json:"created_at"`
	Urgency             string        `json:"urgency"`
	ContactMethod       ContactMethod `json:"contact_method"`
}

type Oncall

type Oncall struct {
	EscalationPolicy EscalationPolicy `json:"escalation_policy"`
	User             User             `json:"user"`
	Schedule         Schedule         `json:"schedule"`
	EscalationLevel  int              `json:"escalation_level"`
	Start            *time.Time       `json:"start"`
	End              *time.Time       `json:"end"`
}

func GetOncalls

func GetOncalls(token string, query map[string][]string) ([]Oncall, error)

https://v2.developer.pagerduty.com/v2/page/api-reference#!/On-Calls/get_oncalls TODO: figure out if query should be a typed struct or validated

func GetUsersOncall

func GetUsersOncall(token string) ([]Oncall, error)

type OncallsByLevel

type OncallsByLevel []Oncall

OncallsByLevel provides sorting by oncall level for []Oncall.

func (OncallsByLevel) Len

func (a OncallsByLevel) Len() int

func (OncallsByLevel) Less

func (a OncallsByLevel) Less(i, j int) bool

func (OncallsByLevel) Swap

func (a OncallsByLevel) Swap(i, j int)

type OncallsResponse

type OncallsResponse struct {
	Oncalls []Oncall `json:"oncalls"`
	Offset  int      `json:"offset"`
	Limit   int      `json:"limit"`
	More    bool     `json:"more"`
	Total   int      `json:"total,omitempty"`
}

type Override

type Override struct {
	Id    string  `json:"id"`
	Start string  `json:"start"`
	End   string  `json:"end"`
	User  UserRef `json:"user"`
}

type PolicyService

type PolicyService struct {
	Id                 string `json:"id"`
	Name               string `json:"name"`
	IntegrationEmail   string `json:"integration_email"`
	HtmlUrl            string `json:"html_url"`
	EscalationPolicyId string `json:"escalation_policy_id"`
}

type Response

type Response struct {
	Status      string   `json:"status"`
	Message     string   `json:"message"`
	IncidentKey string   `json:"incident_key,omitempty"`
	Errors      []string `json:"errors,omitempty"`
	StatusCode  int      `json:""`
}

func NewResponse

func NewResponse(status, message, incidentKey string) *Response

type Restriction

type Restriction struct {
	Type            string `json:"type"`
	DurationSeconds int    `json:"duration_seconds"`
	StartTimeOfDay  string `json:"start_time_of_day"`
}

type Schedule

type Schedule struct {
	Id                   string             `json:"id"`
	Summary              string             `json:"summary"`
	Type                 string             `json:"type"`
	Self                 string             `json:"self"`
	HtmlUrl              string             `json:"html_url"`
	ScheduleLayers       []ScheduleLayer    `json:"schedule_layers"`
	Timezone             string             `json:"time_zone"`
	Name                 string             `json:"name"`
	Description          string             `json:"description"`
	FinalSchedule        SubSchedule        `json:"final_schedule,omitempty"`
	OverridesSubSchedule SubSchedule        `json:"overrides_subschedule,omitempty"`
	EscalationPolicies   []EscalationPolicy `json:"escalation_policies"`
	Users                []UserRef          `json:"users"`
}

func GetSchedules

func GetSchedules(token string, params map[string][]string) ([]Schedule, error)

type ScheduleLayer

type ScheduleLayer struct {
	Id                         string               `json:"id,omitempty"`
	Start                      *time.Time           `json:"start"`
	End                        *time.Time           `json:"end,omitempty"`
	Type                       string               `json:"type"`
	Summary                    string               `json:"summary"`
	Self                       string               `json:"self"`
	HtmlUrl                    string               `json:"html_url"`
	Users                      []UserRef            `json:"users"`
	Restrictions               []Restriction        `json:"restrictions"`
	RotationVirtualStart       string               `json:"rotation_virtual_start"`
	RotationTurnLengthSeconds  int                  `json:"rotation_turn_length_seconds"`
	Name                       string               `json:"name"`
	RenderedScheduleEntries    []ScheduleLayerEntry `json:"rendered_schedule_entries"`
	RenderedCoveragePercentage float64              `json:"rendered_coverage_percentage"`
}

type ScheduleLayerEntry

type ScheduleLayerEntry struct {
	User  UserRef `json:"user"`
	Start string  `json:"start"`
	End   string  `json:"end"`
}

type ScheduleRef

type ScheduleRef struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Self    string `json:"self"`
	HtmlUrl string `json:"html_url"`
}

type SchedulesResponse

type SchedulesResponse struct {
	Schedules []Schedule `json:"schedules"`
	Offset    int        `json:"offset"`
	Limit     int        `json:"limit"`
	More      bool       `json:"more"`
	Total     int        `json:"total,omitempty"`
}

type Service

type Service struct {
	Id                     string           `json:"id"`
	Type                   string           `json:"type"`
	Name                   string           `json:"name"`
	ServiceUrl             string           `json:"service_url"`
	ServiceKey             string           `json:"service_key"`
	AutoResolveTimeout     int              `json:"auto_resolve_timeout"`
	AcknowledgementTimeout int              `json:"acknowledgement_timeout"`
	CreatedAt              string           `json:"created_at"`
	Status                 string           `json:"status"`
	LastIncidentTimestamp  string           `json:"last_incident_timestamp"`
	EmailIncidentCreation  string           `json:"email_incident_creation"`
	IncidentCounts         IncidentCounts   `json:"incident_counts"`
	EmailFilterMode        string           `json:"email_filter_mode"`
	Description            string           `json:"description"`
	Integrations           []Integration    `json:"integrations"`
	EscalationPolicy       EscalationPolicy `json:"escalation_policy"`
	Teams                  []Team           `json:"teams"`
}

Service represents a Pagerduty service object from /api/v1/services/:id

func GetService

func GetService(token, id string) (Service, error)

func GetServices

func GetServices(token string, params map[string][]string) ([]Service, error)

type ServiceRef

type ServiceRef struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Self    string `json:"self"`
	HtmlUrl string `json:"html_url"`
}

type ServicesResponse

type ServicesResponse struct {
	Services []Service `json:"services"`
	Limit    int       `json:"limit"`
	Offset   int       `json:"offset"`
	More     bool      `json:"more"`
	Total    int       `json:"total"`
}

type SubSchedule

type SubSchedule struct {
	Name                       string               `json:"name"`
	RenderedScheduleEntries    []ScheduleLayerEntry `json:"rendered_schedule_entries"`
	RenderedCoveragePercentage float64              `json:"rendered_coverage_percentage"`
}

type Team

type Team struct {
	Id          string `json:"id"`
	Type        string `json:"type"`
	Summary     string `json:"summary"`
	Self        string `json:"self"`
	HtmlUrl     string `json:"html_url"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

func GetTeams

func GetTeams(token string, params map[string][]string) ([]Team, error)

type TeamRef

type TeamRef struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Self    string `json:"self"`
	HtmlUrl string `json:"html_url"`
}

type TeamsResponse

type TeamsResponse struct {
	Teams  []Team `json:"teams"`
	Offset int    `json:"offset"`
	Limit  int    `json:"limit"`
	More   bool   `json:"more"`
	Total  int    `json:"total,omitempty"`
}

type User

type User struct {
	Id                string             `json:"id"`
	Type              string             `json:"type"`
	Summary           string             `json:"summary"`
	Self              string             `json:"self"`
	HtmlUrl           string             `json:"html_url"`
	Name              string             `json:"name"`
	Email             string             `json:"email"`
	JobTitle          string             `json:"job_title"`
	Timezone          string             `json:"time_zone"`
	Color             string             `json:"color"`
	Role              string             `json:"role,omitempty"`
	AvatarUrl         string             `json:"avatar_url,omitempty"`
	Description       string             `json:"description,omitempty"`
	Billed            bool               `json:"billed,omitempty"`
	UserUrl           string             `json:"user_url,omitempty"`
	InvitationSent    bool               `json:"invitation_sent,omitempty"`
	MarketingOptOut   bool               `json:"marketing_opt_out,omitempty"`
	ContactMethods    []ContactMethod    `json:"contact_methods"`
	NotificationRules []NotificationRule `json:"notification_rules"`
	Teams             []Team             `json:"teams"`
}

func GetUsers

func GetUsers(token string, params map[string][]string) ([]User, error)

type UserRef

type UserRef struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Self    string `json:"self"`
	HtmlUrl string `json:"html_url"`
}

type UsersResponse

type UsersResponse struct {
	Users  []User `json:"users"`
	Offset int    `json:"offset"`
	Limit  int    `json:"limit"`
	More   bool   `json:"more"`
	Total  int    `json:"total"`
}

Jump to

Keyboard shortcuts

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