Skip to content
master
Go to file
Code
This branch is 1 commit ahead, 273 commits behind PagerDuty:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

GoDoc Go Report Card License

go-pagerduty

go-pagerduty is a CLI and go client library for the PagerDuty v2 API.

Installation

go get github.com/PagerDuty/go-pagerduty

Usage

CLI

The CLI requires an authentication token, which can be sepcified in .pd.yml file in the home directory of the user, or passed as a command-line argument. Example of config file:

---
authtoken: fooBar

Install

cd $GOPATH/github.com/PagerDuty/go-pagerduty
go build -o $GOPATH/bin/pd command/*

Commands

pd command provides a single entrypoint for all the API endpoints, with individual API represented by their own sub commands. For an exhaustive list of sub-commands, try:

pd --help

An example of the service sub-command

pd service list

Client Library

package main

import (
	"fmt"
	"github.com/PagerDuty/go-pagerduty"
)

var	authtoken = "" // Set your auth token here

func main() {
	var opts pagerduty.ListEscalationPoliciesOptions
	client := pagerduty.NewClient(authtoken)
	if eps, err := client.ListEscalationPolicies(opts); err != nil {
		panic(err)
	} else {
		for _, p := range eps.EscalationPolicies {
			fmt.Println(p.Name)
		}
	}
}

The PagerDuty API client also exposes its HTTP client as the HTTPClient field. If you need to use your own HTTP client, for doing things like defining your own transport settings, you can replace the default HTTP client with your own by simply by setting a new value in the HTTPClient field.

Contributing

  1. Fork it ( https://github.com/PagerDuty/go-pagerduty/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Apache 2

About

go client library for PagerDuty v2 API

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.