gopherduty

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2014 License: GPL-2.0, GPL-2.0 Imports: 7 Imported by: 0

README

gopherduty Build Status

A simple Go client for PagerDuty. This includes a retry feature when sending to PagerDuty

Usage

Get library
$ go get github.com/darkcrux/gopherduty
Use library
import "github.com/darkcrux/gopherduty"
Create client
client := gopherduty.NewClient("e93facc04764012d7bfb002500d5d1a6")
Configure client
client.MaxRetries = 5 // set max retries to 5 before failing, Defaults to 0.
client.RetryBaseInterval = 5 // set first retry to 5s. Defaults to 10s.
Trigger an incident
response := client.Trigger("check-01", "something failed", "my-monitoring-client", "http://my.url.com", details)
Acknowledge an incident
response := client.Acknowledge("check1", "haxxor is fixing it naw", details)
Resolve an incident
response := client.Resolve("check1", "haxxor has fixed. Can haxxor has cheezburger", details)
Verify response
response.HasErrors() // true if there were errors even after all the retries. :(
response.Status // the status code
response.Message // the return message
response.IncidentKey // the incident key of the request
response.Errors // list of errors

More Info

More info can be found here.

Documentation

Overview

A simple Go client for PagerDuty's API. This includes the trigger, acknowledge, and resolve event types. This also includes a retry feature when sending to PagerDuty fails.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PagerDuty

type PagerDuty struct {
	ServiceKey        string // The Service key needed to access PagerDuty.
	MaxRetry          int    // Maximum API call retries. Defaults to 0.
	RetryBaseInterval int    // Starting delay for a retry in seconds. Defaults to 10.
	// contains filtered or unexported fields
}

PagerDuty requires a Service Key to work. API call can be retried if MaxRetry is set to > 1. This retries the request with an exponential delay for each retry.

func NewClient

func NewClient(serviceKey string) *PagerDuty

Convenience method to create a new PagerDuty struct.

func (*PagerDuty) Acknowledge

func (p *PagerDuty) Acknowledge(incidentKey, description string, details interface{}) *PagerDutyResponse

Send an ACKNOWLEDGE event.

func (*PagerDuty) Resolve

func (p *PagerDuty) Resolve(incidentKey, description string, details interface{}) *PagerDutyResponse

Send a RESOLVE event.

func (*PagerDuty) Trigger

func (p *PagerDuty) Trigger(incidentKey, description, client, clientUrl string, details interface{}) *PagerDutyResponse

Send a TRIGGER event. The incidentKey may be left empty and PagerDuty will generate one.

type PagerDutyResponse

type PagerDutyResponse struct {
	Status      string   `json:"status"`
	Message     string   `json:"message"`
	IncidentKey string   `json:"incident_key,omitempty"`
	Errors      []string `json:"errors,omitempty"`
}

The response from calling the PagerDuty API. This can contain errors if the API call failed. Also, any errors encountered when calling the API is added to the Errors list.

func (*PagerDutyResponse) Error

func (p *PagerDutyResponse) Error() string

Error interface implementation.

func (*PagerDutyResponse) HasErrors

func (p *PagerDutyResponse) HasErrors() bool

Returns true if there are any errors during API call.

func (*PagerDutyResponse) String

func (p *PagerDutyResponse) String() string

Return the JSON string.

Jump to

Keyboard shortcuts

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