pagerduty

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

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

Go to latest
Published: Aug 21, 2015 License: MIT Imports: 11 Imported by: 0

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 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 Channel

type Channel struct {
	Subject string `json:"subject,omitempty"`
	Details string `json:"details,omitempty"`
	Summary string `json:"summary,omitempty"`
	Type    string `json:"type,omitempty"`
}

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 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 Context

type Context struct {
	Type string `json:"type,omitempty"`
	Href string `json:"href,omitempty"`
}

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

Get returns a single incident by id if found

func (*IncidentsService) List

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

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 Notification struct {
	Type    string `json:"type,omitempty"`
	Address string `json:"address,omitempty"`
	Status  string `json:"status,omitempty"`
}

type Pagination

type Pagination struct {
	Limit  int `json:"limit,omitempty" url:"limit,omitempty"`
	Offset int `json:"offset" url:"offset,omitempty"`
	Total  int `json:"total" url:"-"`
}

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 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 {
	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

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"`
	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 UserResponse

type UserResponse struct {
	User *User
}

The user response is a single User

type Users

type Users struct {
	Users []User
}

Users is a list of users

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