Documentation ¶
Overview ¶
Package pagerduty contains wrappers for pagerduty api calls
Index ¶
- Constants
- type AlertDetails
- type Client
- type CreateEventError
- type FileNotFoundError
- type IncidentData
- type IncidentNotFoundError
- type IntegrationNotFoundError
- type InvalidInputParamsError
- type InvalidTokenError
- type NewAlert
- type NewAlertCustomDetails
- type SdkClient
- func (c *SdkClient) AcknowledgeIncident() error
- func (c *SdkClient) AddNote(noteContent string) error
- func (c *SdkClient) AddNoteToIncident(incidentID string, noteContent string) error
- func (c *SdkClient) AssignToUser(userID string) error
- func (c *SdkClient) CreateNewAlert(newAlert NewAlert, serviceID string) error
- func (c *SdkClient) EscalateAlert() error
- func (c *SdkClient) EscalateAlertWithNote(notes string) error
- func (c *SdkClient) GetAlertListDetails(alertList *[]sdk.IncidentAlert) ([]AlertDetails, error)
- func (c *SdkClient) GetAlertsForIncident(incidentID string) (*[]sdk.IncidentAlert, error)
- func (c *SdkClient) GetIncidentID() string
- func (c *SdkClient) GetIncidentRef() string
- func (c *SdkClient) GetOnCallEscalationPolicy() string
- func (c *SdkClient) GetServiceID() string
- func (c *SdkClient) GetServiceName() string
- func (c *SdkClient) GetSilentEscalationPolicy() string
- func (c *SdkClient) GetTitle() string
- func (c *SdkClient) MoveToEscalationPolicy(escalationPolicyID string) error
- func (c *SdkClient) ResolveIncident(incident *pagerduty.Incident) error
- func (c *SdkClient) RetrieveClusterID() (string, error)
- func (c *SdkClient) SetIncidentData(incidentData *IncidentData)
- func (c *SdkClient) SilenceAlert() error
- func (c *SdkClient) SilenceAlertWithNote(notes string) error
- type ServiceNotFoundError
- type UnmarshalError
Constants ¶
const ( // InvalidInputParamsErrorCode is exposed from the PagerDuty's API error response, used to distinguish between different error codes. // for more details see https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTYz-errors#pagerduty-error-codes InvalidInputParamsErrorCode = 2001 // CADEmailAddress is the email address for the 'Configuration-Anomaly-Detection' PagerDuty User CADEmailAddress = "sd-sre-platform+pagerduty-configuration-anomaly-detection-agent@redhat.com" // CADIntegrationName is the name of the PD integration used to escalate alerts to Primary. CADIntegrationName = "Dead Man's Snitch" // IncidentResolved is an incident event type IncidentResolved = "incident.resolved" // IncidentTriggered is an incident event type IncidentTriggered = "incident.triggered" // IncidentEscalated is an incident event type IncidentEscalated = "incident.escalated" // IncidentReopened is an incident event type IncidentReopened = "incident.reopened" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertDetails ¶
AlertDetails exposes the required info we need from an alert
type Client ¶
type Client interface { SilenceAlert() error SilenceAlertWithNote(notes string) error AddNote(notes string) error CreateNewAlert(newAlert NewAlert, serviceID string) error GetServiceID() string EscalateAlertWithNote(notes string) error EscalateAlert() error }
Client is the interface exposing pagerduty functions
type CreateEventError ¶
type CreateEventError struct {
Err error
}
CreateEventError wraps the errors returned when failing to create a PagerDuty event
func (CreateEventError) Error ¶
func (c CreateEventError) Error() string
Error prints the wrapped and original error
func (CreateEventError) Is ¶
func (CreateEventError) Is(target error) bool
Is indicates whether the supplied error is a CreateEventError
type FileNotFoundError ¶
FileNotFoundError wraps the filesystem NotFound Error
func (FileNotFoundError) Error ¶
func (f FileNotFoundError) Error() string
Error prints the wrapped error and the original one
func (FileNotFoundError) Is ¶
func (f FileNotFoundError) Is(target error) bool
Is ignores the internal error, thus making errors.Is work (as by default it compares the internal objects)
type IncidentData ¶
type IncidentData struct { IncidentTitle string // e.g. InfraNodesNeedResizingSRE CRITICAL (1) IncidentID string // e.g. Q2I4AV3ZURABC IncidentRef string // e.g. https://<>.pagerduty.com/incidents/Q2I4AV3ZURABC ServiceID string // e.g. PCH1XGB ServiceSummary string // e.g. prod-deadmanssnitch }
IncidentData represents the data contained in an incident
type IncidentNotFoundError ¶
type IncidentNotFoundError struct {
Err error
}
IncidentNotFoundError wraps the PagerDuty not found error while adding notes to an incident
func (IncidentNotFoundError) Error ¶
func (i IncidentNotFoundError) Error() string
Error prints the wrapped error and the original one
func (IncidentNotFoundError) Is ¶
func (IncidentNotFoundError) Is(target error) bool
Is ignores the internal error, thus making errors.Is work (as by default it compares the internal objects)
type IntegrationNotFoundError ¶
type IntegrationNotFoundError struct {
Err error
}
IntegrationNotFoundError wraps the errors returned when a PagerDuty service's integration cannot be found
func (IntegrationNotFoundError) Error ¶
func (i IntegrationNotFoundError) Error() string
Error prints the wrapped and original error
func (IntegrationNotFoundError) Is ¶
func (IntegrationNotFoundError) Is(target error) bool
Is indicates whether the supplied error is an IntegrationNotFoundError
type InvalidInputParamsError ¶
type InvalidInputParamsError struct {
Err error
}
InvalidInputParamsError wraps the PagerDuty Invalid parameters error TODO: the API also returns any other error in here, if this persists, think on renaming to "ClientMisconfiguration"
func (InvalidInputParamsError) Error ¶
func (i InvalidInputParamsError) Error() string
Error prints the wrapped error and the original one
func (InvalidInputParamsError) Is ¶
func (InvalidInputParamsError) Is(target error) bool
Is ignores the internal error, thus making errors.Is work (as by default it compares the internal objects)
type InvalidTokenError ¶
type InvalidTokenError struct {
Err error
}
InvalidTokenError wraps the PagerDuty token invalid error
func (InvalidTokenError) Error ¶
func (i InvalidTokenError) Error() string
Error prints the wrapped error and the original one
func (InvalidTokenError) Is ¶
func (InvalidTokenError) Is(target error) bool
Is ignores the internal error, thus making errors.Is work (as by default it compares the internal objects)
type NewAlert ¶
type NewAlert struct { // The alert description acts as a title for the resulting incident Description string Details NewAlertCustomDetails }
NewAlert is a type for alerts to create on pagerduty
type NewAlertCustomDetails ¶
type NewAlertCustomDetails struct { ClusterID string `json:"Cluster ID"` Error string `json:"Error"` Resolution string `json:"Resolution"` SOP string `json:"SOP"` }
NewAlertCustomDetails is a format for the alert details shown in the pagerduty incident
type SdkClient ¶
type SdkClient struct {
// contains filtered or unexported fields
}
SdkClient will hold all the required fields for any SdkClient Operation
func GetPDClient ¶
GetPDClient will retrieve the PagerDuty from the 'pagerduty' package
func NewWithToken ¶
func NewWithToken(escalationPolicy string, silentPolicy string, webhookPayload []byte, authToken string, options ...sdk.ClientOptions) (*SdkClient, error)
NewWithToken initializes a new SdkClient The token can be created using the docs https://support.pagerduty.com/docs/api-access-keys#section-generate-a-user-token-rest-api-key
func (*SdkClient) AcknowledgeIncident ¶
AcknowledgeIncident will acknowledge an incident This is currently not needed by anything
func (*SdkClient) AddNoteToIncident ¶
AddNoteToIncident will add a note to an incident
func (*SdkClient) AssignToUser ¶
AssignToUser will assign the incident to the provided user This is currently not needed by anything
func (*SdkClient) CreateNewAlert ¶
CreateNewAlert triggers an alert using the Deadmanssnitch integration for the given service. If the provided service does not have a DMS integration, an error is returned
func (*SdkClient) EscalateAlert ¶
EscalateAlert escalates the alert to the on call escalation policy
func (*SdkClient) EscalateAlertWithNote ¶
EscalateAlertWithNote annotates the PagerDuty alert with the given notes and escalates it by assigning to the on call escalation policy
func (*SdkClient) GetAlertListDetails ¶
func (c *SdkClient) GetAlertListDetails(alertList *[]sdk.IncidentAlert) ([]AlertDetails, error)
GetAlertListDetails will retrieve the required details for a list of alerts and return an array of alertDetails in the same order
func (*SdkClient) GetAlertsForIncident ¶
func (c *SdkClient) GetAlertsForIncident(incidentID string) (*[]sdk.IncidentAlert, error)
GetAlertsForIncident gets all alerts that are part of an incident
func (*SdkClient) GetIncidentID ¶
GetIncidentID returns the event type of the webhook
func (*SdkClient) GetIncidentRef ¶
GetIncidentRef returns a link to the pagerduty incident
func (*SdkClient) GetOnCallEscalationPolicy ¶
GetOnCallEscalationPolicy returns the set on call escalation policy
func (*SdkClient) GetServiceID ¶
GetServiceID returns the event type of the webhook
func (*SdkClient) GetServiceName ¶
GetServiceName returns the event type of the webhook
func (*SdkClient) GetSilentEscalationPolicy ¶
GetSilentEscalationPolicy returns the set policy for silencing alerts
func (*SdkClient) MoveToEscalationPolicy ¶
MoveToEscalationPolicy will move the incident's EscalationPolicy to the new EscalationPolicy
func (*SdkClient) ResolveIncident ¶
ResolveIncident resolves an incident
func (*SdkClient) RetrieveClusterID ¶
RetrieveClusterID returns the clusterID for the current alert context of the SdkClient. The cluster id is not on the payload so the first time it is called it will retrieve the clusterID from pagerduty, and update the client.
func (*SdkClient) SetIncidentData ¶
func (c *SdkClient) SetIncidentData(incidentData *IncidentData)
SetIncidentData sets the Client's incidentData
func (*SdkClient) SilenceAlert ¶
SilenceAlert silences the alert by assigning the "Silent Test" escalation policy
func (*SdkClient) SilenceAlertWithNote ¶
SilenceAlertWithNote annotates the PagerDuty alert with the given notes and silences it by assigning the "Silent Test" escalation policy
type ServiceNotFoundError ¶
type ServiceNotFoundError struct {
Err error
}
ServiceNotFoundError wraps the errors returned when PagerDuty services cannot be retrieved
func (ServiceNotFoundError) Error ¶
func (s ServiceNotFoundError) Error() string
Error prints the wrapped and original error
func (ServiceNotFoundError) Is ¶
func (ServiceNotFoundError) Is(target error) bool
Is indicates whether the supplied error is a ServiceNotFoundError
type UnmarshalError ¶
type UnmarshalError struct {
Err error
}
UnmarshalError wraps JSON's json.SyntaxError
func (UnmarshalError) Error ¶
func (u UnmarshalError) Error() string
Error prints the wrapped error and the original one
func (UnmarshalError) Is ¶
func (u UnmarshalError) Is(target error) bool
Is ignores the internal error, thus making errors.Is work (as by default it compares the internal objects)