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 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 ErrorCode
- type ErrorResponse
- type EscalationPolicy
- type Incident
- type IncidentSummary
- type Incidents
- type IncidentsOptions
- type IncidentsService
- 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 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 Client ¶
type Client struct { Subdomain string APIKey string BaseURL *url.URL Incidents *IncidentsService Users *UsersService Schedules *SchedulesService // 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 string `json:"created_on,omitempty"` Summary *IncidentSummary `json:"trigger_summary_data,omitempty"` User *User `json:"assigned_to_user,omitempty"` Service *Service `json:"service,omitempty"` EscalationPolicy *EscalationPolicy `json:"escalation_policy,omitempty"` 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 IncidentsOptions ¶
type IncidentsOptions struct { Status string `url:"status,omitempty"` SortBy string `url:"sort_by,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,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) ([]Incident, *http.Response, error)
List returns a list of incidents
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 { 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 SchedulesOptions ¶
type SchedulesOptions struct { 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"` TimeZone string `json:"time_zone,omitempty"` Color string `json:"color,omitempty"` UserURL string `json:"user_url,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` }
User type
type UsersOptions ¶
type UsersOptions struct {
Query string `json:"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