pd

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockError = fmt.Errorf("pd.Mock(): mock error") // Used to mock errors in unit tests

Functions

func AcknowledgeIncident

func AcknowledgeIncident(client PagerDutyClient, incidents []pagerduty.Incident, user *pagerduty.User) ([]pagerduty.Incident, error)

func GetEscalationPolicy added in v0.0.9

func GetIncident

func GetIncident(client PagerDutyClient, id string) (*pagerduty.Incident, error)

func GetNotes

func GetNotes(client PagerDutyClient, id string) ([]pagerduty.IncidentNote, error)

func GetTeamMemberIDs

func GetTeamMemberIDs(client PagerDutyClient, teams []*pagerduty.Team, opts pagerduty.ListTeamMembersOptions) ([]string, error)

func GetTeams

func GetTeams(client PagerDutyClient, teams []string) ([]*pagerduty.Team, error)

func GetUser

func GetUser(client PagerDutyClient, id string, opts pagerduty.GetUserOptions) (*pagerduty.User, error)

func GetUserOnCalls added in v0.0.7

func GetUserOnCalls(client PagerDutyClient, id string, opts pagerduty.ListOnCallOptions) ([]pagerduty.OnCall, error)

func NewListIncidentOptsFromDefaults

func NewListIncidentOptsFromDefaults() pagerduty.ListIncidentsOptions

func PostNote

func PostNote(client PagerDutyClient, id string, user *pagerduty.User, content string) (*pagerduty.IncidentNote, error)

func ReEscalateIncidents added in v0.0.9

func ReEscalateIncidents(client PagerDutyClient, incidents []pagerduty.Incident, policy *pagerduty.EscalationPolicy, level uint) ([]pagerduty.Incident, error)

ReEscalateIncidents re-escalates a list of incidents to an escalation policy at a specific level

func ReassignIncidents

func ReassignIncidents(client PagerDutyClient, incidents []pagerduty.Incident, user *pagerduty.User, users []*pagerduty.User) ([]pagerduty.Incident, error)

ReassignIncidents reassigns a list of incidents to a list of users

Types

type Config

type Config struct {
	Client      PagerDutyClient
	CurrentUser *pagerduty.User

	// List of the users in the Teams
	TeamsMemberIDs     []string
	Teams              []*pagerduty.Team
	EscalationPolicies map[string]*pagerduty.EscalationPolicy

	IgnoredUsers []*pagerduty.User
}

Config is a struct that holds the PagerDuty client used for all the PagerDuty calls, and the config info for teams, and ignored users

func NewConfig

func NewConfig(token string, teams []string, escalation_policies map[string]string, ignoredUsers []string) (*Config, error)

type MockPagerDutyClient added in v0.0.8

type MockPagerDutyClient struct {
	PagerDutyClient
}

func (*MockPagerDutyClient) GetIncidentWithContext added in v0.0.8

func (m *MockPagerDutyClient) GetIncidentWithContext(ctx context.Context, id string) (*pagerduty.Incident, error)

func (*MockPagerDutyClient) GetTeamWithContext added in v0.0.8

func (m *MockPagerDutyClient) GetTeamWithContext(ctx context.Context, team string) (*pagerduty.Team, error)

func (*MockPagerDutyClient) ListIncidentAlertsWithContext added in v0.0.8

func (*MockPagerDutyClient) ListIncidentNotesWithContext added in v0.0.8

func (m *MockPagerDutyClient) ListIncidentNotesWithContext(ctx context.Context, id string) ([]pagerduty.IncidentNote, error)

func (*MockPagerDutyClient) ListIncidentsWithContext added in v0.0.8

func (*MockPagerDutyClient) ManageIncidentsWithContext added in v0.0.9

func (m *MockPagerDutyClient) ManageIncidentsWithContext(ctx context.Context, email string, opts []pagerduty.ManageIncidentsOptions) (*pagerduty.ListIncidentsResponse, error)

type PagerDutyClient

type PagerDutyClient interface {
	PagerDutyClientInterface
}

PagerDutyClient implements PagerDutyClientInterface and is used by the pd package to make calls to PagerDuty This allows for mocking calls that would usually use the pagerduty.Client struct

type PagerDutyClientInterface

type PagerDutyClientInterface interface {
	CreateIncidentNoteWithContext(ctx context.Context, id string, note pagerduty.IncidentNote) (*pagerduty.IncidentNote, error)
	GetCurrentUserWithContext(ctx context.Context, opts pagerduty.GetCurrentUserOptions) (*pagerduty.User, error)
	GetEscalationPolicyWithContext(ctx context.Context, id string, opts *pagerduty.GetEscalationPolicyOptions) (*pagerduty.EscalationPolicy, error)
	GetIncidentWithContext(ctx context.Context, id string) (*pagerduty.Incident, error)
	GetTeamWithContext(ctx context.Context, id string) (*pagerduty.Team, error)
	ListMembersWithContext(ctx context.Context, id string, opts pagerduty.ListTeamMembersOptions) (*pagerduty.ListTeamMembersResponse, error)
	GetUserWithContext(ctx context.Context, id string, opts pagerduty.GetUserOptions) (*pagerduty.User, error)
	ListIncidentAlertsWithContext(ctx context.Context, id string, opts pagerduty.ListIncidentAlertsOptions) (*pagerduty.ListAlertsResponse, error)
	ListIncidentsWithContext(ctx context.Context, opts pagerduty.ListIncidentsOptions) (*pagerduty.ListIncidentsResponse, error)
	ListIncidentNotesWithContext(ctx context.Context, id string) ([]pagerduty.IncidentNote, error)
	ListOnCallsWithContext(ctx context.Context, opts pagerduty.ListOnCallOptions) (*pagerduty.ListOnCallsResponse, error)
	ManageIncidentsWithContext(ctx context.Context, email string, opts []pagerduty.ManageIncidentsOptions) (*pagerduty.ListIncidentsResponse, error)
}

PagerDutyClientInterface is an interface that defines the methods used by the pd package and makes it easier to mock calls to PagerDuty in tests

Jump to

Keyboard shortcuts

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