Documentation ¶
Overview ¶
Package pagerduty provides an API library for interacting with PagerDuty. Much of this code is inspired by https://github.com/google/go-github <3
Index ¶
- func CheckResponse(r *http.Response) error
- type Alert
- type Alerts
- type AlertsOptions
- type AlertsService
- type Channel
- type Client
- func (c *Client) Delete(path string, input, output interface{}) (*http.Response, error)
- func (c *Client) Do(req *http.Request, output interface{}) (*http.Response, error)
- func (c *Client) Get(path string, output interface{}) (*http.Response, error)
- func (c *Client) NewRequest(meth string, path string, input interface{}) (*http.Request, error)
- func (c *Client) Post(path string, input, output interface{}) (*http.Response, error)
- func (c *Client) Put(path string, input, output interface{}) (*http.Response, error)
- type Context
- type ErrorCode
- type ErrorResponse
- type EscalationPolicy
- type Incident
- type IncidentSummary
- type Incidents
- type IncidentsOptions
- type IncidentsService
- func (s *IncidentsService) Get(id string) (*Incident, *http.Response, error)
- func (s *IncidentsService) List(opt *IncidentsOptions) (Incidents, *http.Response, error)
- func (s *IncidentsService) ListAll(opt *IncidentsOptions) ([]Incident, error)
- func (s *IncidentsService) Reassign(id string, opt *ReassignOptions) (*http.Response, error)
- type LogEntries
- type LogEntriesOptions
- type LogEntriesService
- func (s *LogEntriesService) IncidentLogEntries(incident_id string, opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
- func (s *LogEntriesService) LogEntries(opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
- func (s *LogEntriesService) LogEntry(id string, opt *LogEntryOptions) (*LogEntry, *http.Response, error)
- func (s *LogEntriesService) UserLogEntries(user_id string, opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
- type LogEntry
- type LogEntryOptions
- type LogEntryResponse
- type Notification
- type Pagination
- type ReassignOptions
- type Schedule
- type ScheduleEntries
- type ScheduleEntriesOptions
- type ScheduleEntry
- type ScheduleLayer
- type ScheduleWrapper
- type Schedules
- type SchedulesOptions
- type SchedulesService
- type Service
- type Services
- type ServicesOptions
- type ServicesService
- type User
- type UserResponse
- type Users
- type UsersOptions
- type UsersService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, returning them if present. A response is considered to have an error if it has a status code outside the 200 range.
Types ¶
type Alert ¶
type Alert struct { ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` StartedAt string `json:"started_at,omitempty"` UUser User `json:"user,omitempty"` // This is conflicting with the package name on assignment in test. Not sure of the soltuion Address string `json:"address,omitempty"` }
Alert type
type Alerts ¶
type Alerts struct { *Pagination Alerts []Alert `json:"alerts,omitempty"` }
Alerts is a list of alerts
type AlertsOptions ¶
type AlertsOptions struct { Pagination Type string `url:"filter[type],omitempty"` // Can be one of SMS, Email, Phone, or Push Timezone string `url:"time_zone,omitempty"` Since string `url:"since,omitempty"` // Format 2006-01-02T15:04:05-07:00 Until string `url:"until,omitempty"` }
AlertsOptions provides optional parameters to list requests
type AlertsService ¶
type AlertsService struct {
// contains filtered or unexported fields
}
AlertsService type
func (*AlertsService) List ¶
func (s *AlertsService) List(opt *AlertsOptions) (Alerts, *http.Response, error)
List returns a list of alerts
type Client ¶
type Client struct { Subdomain string APIKey string BaseURL *url.URL Incidents *IncidentsService Alerts *AlertsService Users *UsersService Schedules *SchedulesService LogEntries *LogEntriesService // contains filtered or unexported fields }
Client is an API client
func (*Client) NewRequest ¶
NewRequest builds an http.Request, resolves relative URLs, and sets HTTP headers
type ErrorCode ¶
type ErrorCode uint
ErrorCode represents potential errors returned by API calls
const ( ErrInternalError ErrorCode = iota + 2001 ErrInvalidInput ErrArgumentsCausedError ErrMissingArguments ErrInvalidSinceOrUntilParameterValues ErrInvalidQueryDateRange ErrAuthenticationFailed ErrAccountNotFound ErrAccountLocked ErrOnlyHTTPSAllowed ErrAccessDenied ErrRequesterIDRequired ErrAccountExpired )
ErrorCode constants
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response Message string `json:"message"` Code ErrorCode `json:"code"` Errors []string `json:"errors"` }
An ErrorResponse represents one or more errors created by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type EscalationPolicy ¶
type EscalationPolicy struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` DeletedAt string `json:"deleted_at,omitempty"` }
EscalationPolicy type
type Incident ¶
type Incident struct { ID string `json:"id,omitempty"` IncidentNumber int `json:"incident_number,omitempty"` Status string `json:"status,omitempty"` CreatedOn time.Time `json:"created_on,omitempty"` Summary *IncidentSummary `json:"trigger_summary_data,omitempty"` User *User `json:"assigned_to_user,omitempty"` SService *Service `json:"service,omitempty"` // This is conflicting with the package name on assignment in test. Not sure of the soltuion EEscalationPolicy *EscalationPolicy `json:"escalation_policy,omitempty"` // This is conflicting with the package name on assignment in test. Not sure of the soltuion HTMLURL string `json:"html_url,omitempty"` IncidentKey string `json:"incident_key,omitempty"` TriggerDetailsHTMLURL string `json:"trigger_details_html_url,omitempty"` TriggerType string `json:"trigger_type,omitempty"` LastStatusChangeOn string `json:"last_status_change_on,omitempty"` LastStatusChangeBy *User `json:"last_status_change_by,omitempty"` NumberOfEscalations int `json:"number_of_escalations,omitempty"` ResolvedByUser *User `json:"resolved_by_user,omitempty"` AssignedToUser *User `json:"assigned_to_user,omitempty"` AssignedTo []*User `json:"assigned_to,omitempty"` }
Incident type
type IncidentSummary ¶
type IncidentSummary struct { Subject string //`json:"subject,omitempty"` Description string //`json:"description,omitempty"` }
IncidentSummary type
type Incidents ¶
type Incidents struct { Pagination Incidents []Incident }
Incidents is a list of incidents
type IncidentsOptions ¶
type IncidentsOptions struct { Pagination Status string `url:"status,omitempty"` SortBy string `url:"sort_by,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` DateRange string `url:"date_range,omitempty"` Service string `url:"service,omitempty"` AssignedToUser string `url:"assigned_to_user,omitempty"` }
IncidentsOptions provides optional parameters to list requests
type IncidentsService ¶
type IncidentsService struct {
// contains filtered or unexported fields
}
IncidentsService type
func (*IncidentsService) List ¶
func (s *IncidentsService) List(opt *IncidentsOptions) (Incidents, *http.Response, error)
List returns a list of incidents
func (*IncidentsService) ListAll ¶
func (s *IncidentsService) ListAll(opt *IncidentsOptions) ([]Incident, error)
ListAll returns a list of incidents, by recursively calling List and utilising the pagination response
func (*IncidentsService) Reassign ¶
func (s *IncidentsService) Reassign(id string, opt *ReassignOptions) (*http.Response, error)
Reassign an incident according to the options provided
type LogEntries ¶
type LogEntries struct { Pagination LogEntries []LogEntry `json:"log_entries"` }
Group
type LogEntriesOptions ¶
type LogEntriesOptions struct { Pagination Timezone string `url:"time_zone,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` // contains filtered or unexported fields }
ScheduleEntriesOptions provides optional parameters to entries requests
type LogEntriesService ¶
type LogEntriesService struct {
// contains filtered or unexported fields
}
The SchedulesService struct is instantiated in the pagerduty struct instantiation and contains a reference back to the pagerduty client
func (*LogEntriesService) IncidentLogEntries ¶
func (s *LogEntriesService) IncidentLogEntries(incident_id string, opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
LogEntries returns a list of log entries for the search
func (*LogEntriesService) LogEntries ¶
func (s *LogEntriesService) LogEntries(opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
LogEntries returns a list of log entries for the search
func (*LogEntriesService) LogEntry ¶
func (s *LogEntriesService) LogEntry(id string, opt *LogEntryOptions) (*LogEntry, *http.Response, error)
LogEntries returns a list of log entries for the search
func (*LogEntriesService) UserLogEntries ¶
func (s *LogEntriesService) UserLogEntries(user_id string, opt *LogEntriesOptions) (*LogEntries, *http.Response, error)
LogEntries returns a list of log entries for the search
type LogEntry ¶
type LogEntry struct { ID string `json:"id"` Type string `json:"type,omitempty"` CreatedAt time.Time `json:"created_at"` Note string `json:"note,omitempty"` Agent *User `json:"agent,omitempty"` Channel *Channel `json:"channel,omitempty"` Contexts []Context `json:"contexts"` AssignedUser *User `json:"assigned_user,omitempty"` User *User `json:"user,omitempty"` Notification *Notification `json:"notification,omitempty"` }
type LogEntryOptions ¶
type LogEntryOptions struct { Pagination Timezone string `url:"time_zone,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` // contains filtered or unexported fields }
ScheduleEntriesOptions provides optional parameters to entries requests
type LogEntryResponse ¶
type LogEntryResponse struct {
LogEntry LogEntry `json:"log_entry"`
}
Individual
type Notification ¶
type Pagination ¶
type ReassignOptions ¶
type ReassignOptions struct { RequesterID string `json:"requester_id,omitempty"` EscalationPolicy string `json:"escalation_policy,omitempty"` EscalationLevel int `json:"escalation_level,omitempty"` AssignedToUser string `json:"assigned_to_user,omitempty"` }
ReassignOptions provides optional parameters to incident reassign
type Schedule ¶
type Schedule struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Timezone string `json:"time_zone,omitempty"` Today string `json:"today,omitempty"` EscalationPolicies []*EscalationPolicy `json:"escalation_policies,omitempty"` ScheduleLayers []*ScheduleLayer `json:"schedule_layers,omitempty"` OverridesSubschedule *ScheduleLayer `json:"overrides_subschedule,omitempty"` FinalSchedule *ScheduleLayer `json:"final_schedule,omitempty"` }
type ScheduleEntries ¶
type ScheduleEntries struct { ScheduleEntries []*ScheduleEntry `json:"entries,omitempty"` Total int `json:"total,omitempty"` }
type ScheduleEntriesOptions ¶
type ScheduleEntriesOptions struct { Pagination Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` Overflow bool `url:"overflow,omitempty"` Timezone string `url:"time_zone,omitempty"` UserId string `url:"user_id,omitempty"` }
ScheduleEntriesOptions provides optional parameters to entries requests
type ScheduleEntry ¶
type ScheduleLayer ¶
type ScheduleLayer struct { Name string `json:"name,omitempty"` RenderedScheduleEntries []string `json:"rendered_schedule_entries,omitempty"` RestrictionType string `json:"restriction_type,omitempty"` Restrictions []string `json:"restrictions,omitempty"` Priority int `json:"priority,omitempty"` Start string `json:"start,omitempty"` End string `json:"end,omitempty"` RenderedCoveragePercentage int `json:"rendered_coverage_percentage,omitempty"` RotationTurnLengthSeconds int `json:"rotation_turn_length_seconds,omitempty"` RotationVirtualStart string `json:"rotation_virtual_start,omitempty"` Users []*User `json:"users,omitempty"` }
type ScheduleWrapper ¶
type ScheduleWrapper struct {
Schedule *Schedule `json:schedule,omitempty"`
}
The ScheduleWrapper type is necessary because the GET /schedules/:id API returns a nested json object in the form: {"schedule": {"id": ...}}
type Schedules ¶
type Schedules struct { Pagination Schedules []*Schedule `json:"schedules,omitempty"` }
type SchedulesOptions ¶
type SchedulesOptions struct { *Pagination Query string `url:"query,omitempty"` RequesterId string `url:"requester_id,omitempty"` }
SchedulesOptions provides optional parameters to list requests
type SchedulesService ¶
type SchedulesService struct {
// contains filtered or unexported fields
}
The SchedulesService struct is instantiated in the pagerduty struct instantiation and contains a reference back to the pagerduty client
func (*SchedulesService) Entries ¶
func (s *SchedulesService) Entries(id string, opt *ScheduleEntriesOptions) (*ScheduleEntries, *http.Response, error)
Entries returns a list of schedule entries for a schedule by id
func (*SchedulesService) List ¶
func (s *SchedulesService) List(opt *SchedulesOptions) (*Schedules, *http.Response, error)
List returns a list of schedules
type Service ¶
type Service struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` HTMLURL string `json:"html_url,omitempty"` DeletedAt string `json:"deleted_at,omitempty"` }
Service type
type ServicesOptions ¶
type ServicesOptions struct {
Query string `json:"query,omitempty"`
}
ServicesOptions provides optional parameters to list requests
type ServicesService ¶
type ServicesService struct {
// contains filtered or unexported fields
}
ServicesService type
func (*ServicesService) List ¶
func (s *ServicesService) List(opt *ServicesOptions) ([]Service, *http.Response, error)
List returns a list of services
type User ¶
type User struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` Role string `json:"role,omitempty"` JobTitle *string `json:"job_title"` Description string `json:"description"` TimeZone string `json:"time_zone,omitempty"` Color string `json:"color,omitempty"` UserURL string `json:"user_url,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` InvitationSent bool `json:"invitation_sent"` MarketingOptOut bool `json:"marketing_opt_out"` Type string `json:"type,omitempty"` }
User type
type UsersOptions ¶
type UsersOptions struct {
Query string `url:"query,omitempty"`
}
UsersOptions provides optional parameters to list requests
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
UsersService provides the API calls to interact with users
func (*UsersService) List ¶
func (s *UsersService) List(opt *UsersOptions) ([]User, *http.Response, error)
List returns a list of users