pagerduty

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

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

Go to latest
Published: Sep 8, 2016 License: MIT Imports: 10 Imported by: 1

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

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 New

func New(sub, key string) *Client

New returns a Client with the default http.Client

func NewClient

func NewClient(sub, key string, httpClient *http.Client) *Client

NewClient returns a default client

func (*Client) Delete

func (c *Client) Delete(path string, input, output interface{}) (*http.Response, error)

Delete makes a DELETE request

func (*Client) Do

func (c *Client) Do(req *http.Request, output interface{}) (*http.Response, error)

Do performs the request

func (*Client) Get

func (c *Client) Get(path string, output interface{}) (*http.Response, error)

Get makes a GET request

func (*Client) NewRequest

func (c *Client) NewRequest(meth string, path string, input interface{}) (*http.Request, error)

NewRequest builds an http.Request, resolves relative URLs, and sets HTTP headers

func (*Client) Post

func (c *Client) Post(path string, input, output interface{}) (*http.Response, error)

Post makes a POST request

func (*Client) Put

func (c *Client) Put(path string, input, output interface{}) (*http.Response, error)

Put makes a PUT request

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 Incidents

type Incidents struct {
	Incidents []Incident
	Limit     int
	Offset    int
	Total     int
}

Incidents is a list of incidents

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"`
	Service   string `url:"service,omitempty"`
	DateRange string `url:"date_range,omitempty"`
	Offset    int    `url:"offset,omitempty"`
}

IncidentsOptions provides optional parameters to list requests

type IncidentsService

type IncidentsService struct {
	// contains filtered or unexported fields
}

IncidentsService type

func (*IncidentsService) Get

Get returns a single incident by id if found

func (*IncidentsService) List

func (s *IncidentsService) List(opt *IncidentsOptions) ([]Incident, 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 ScheduleEntry struct {
	User  *User  `json:"user,omitempty"`
	Start string `json:"start,omitempty"`
	End   string `json:end,omitempty"`
}

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 {
	Schedules []*Schedule `json:"schedules,omitempty"`
	Limit     int         `json:"limit,omitempty"`
	Offset    int         `json:"offset,omitempty"`
	Total     int         `json:"total,omitempty"`
}

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

Entries returns a list of schedule entries for a schedule by id

func (*SchedulesService) Get

Get returns a single schedule by id if found

func (*SchedulesService) List

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 Services

type Services struct {
	Services []Service
}

Services is a list of services

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) Get

func (s *ServicesService) Get(id string) (*Service, *http.Response, error)

Get returns a single service by id if found

func (*ServicesService) List

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 Users

type Users struct {
	Users []User
}

Users is a list of users

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) Get

func (s *UsersService) Get(id string) (*User, *http.Response, error)

Get returns a User by id if found

func (*UsersService) List

func (s *UsersService) List(opt *UsersOptions) ([]User, *http.Response, error)

List returns a list of users

Jump to

Keyboard shortcuts

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