• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H03-May-2019-1211

command/H03-May-2019-3,1542,593

examples/H03-May-2019-9889

.gitignoreH A D03-May-201912 32

.goreleaser.ymlH A D03-May-2019578 3333

CHANGELOG.mdH A D03-May-20199.9 KiB8980

DockerfileH A D03-May-2019160 54

MakefileH A D03-May-2019387 248

README.mdH A D03-May-20192.3 KiB8563

ability.goH A D03-May-2019617 2316

addon.goH A D03-May-20192.5 KiB9878

client.goH A D03-May-20195.2 KiB180137

escalation_policy.goH A D03-May-20196.5 KiB187146

event.goH A D03-May-20192.1 KiB6347

event_v2.goH A D03-May-20192.1 KiB6958

incident.goH A D03-May-20198.1 KiB245196

log_entry.goH A D03-May-20192.5 KiB9574

maintenance_window.goH A D03-May-20193.7 KiB10280

notification.goH A D03-May-20191.3 KiB4535

on_call.goH A D03-May-20191.7 KiB4939

priorites.goH A D03-May-2019630 3425

schedule.goH A D03-May-20198.6 KiB265214

service.goH A D03-May-20197.4 KiB205160

team.goH A D03-May-20192.9 KiB10778

user.goH A D03-May-20193.6 KiB126100

vendor.goH A D03-May-20192.1 KiB7557

webhook.goH A D03-May-20191.3 KiB3830

README.md

1[![GoDoc](https://godoc.org/github.com/PagerDuty/go-pagerduty?status.svg)](http://godoc.org/github.com/PagerDuty/go-pagerduty) [![Go Report Card](https://goreportcard.com/badge/github.com/PagerDuty/go-pagerduty)](https://goreportcard.com/report/github.com/PagerDuty/go-pagerduty) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gojp/goreportcard/blob/master/LICENSE)
2# go-pagerduty
3
4go-pagerduty is a CLI and [go](https://golang.org/) client library for the [PagerDuty v2 API](https://v2.developer.pagerduty.com/v2/page/api-reference).
5
6## Installation
7
8```
9go get github.com/PagerDuty/go-pagerduty
10```
11
12## Usage
13
14### CLI
15
16The CLI requires an [authentication token](https://v2.developer.pagerduty.com/docs/authentication), which can be sepcified in `.pd.yml`
17file in the home directory of the user, or passed as a command-line argument.
18Example of config file:
19
20```yaml
21---
22authtoken: fooBar
23```
24
25#### Install
26```cli
27cd $GOPATH/github.com/PagerDuty/go-pagerduty
28go build -o $GOPATH/bin/pd command/*
29```
30
31#### Commands
32`pd` command provides a single entrypoint for all the API endpoints, with individual
33API represented by their own sub commands. For an exhaustive list of sub-commands, try:
34```
35pd --help
36```
37
38An example of the `service` sub-command
39
40```
41pd service list
42```
43
44
45### Client Library
46
47```go
48package main
49
50import (
51	"fmt"
52	"github.com/PagerDuty/go-pagerduty"
53)
54
55var	authtoken = "" // Set your auth token here
56
57func main() {
58	var opts pagerduty.ListEscalationPoliciesOptions
59	client := pagerduty.NewClient(authtoken)
60	if eps, err := client.ListEscalationPolicies(opts); err != nil {
61		panic(err)
62	} else {
63		for _, p := range eps.EscalationPolicies {
64			fmt.Println(p.Name)
65		}
66	}
67}
68```
69
70The PagerDuty API client also exposes its HTTP client as the `HTTPClient` field.
71If you need to use your own HTTP client, for doing things like defining your own
72transport settings, you can replace the default HTTP client with your own by
73simply by setting a new value in the `HTTPClient` field.
74
75## Contributing
76
771. Fork it ( https://github.com/PagerDuty/go-pagerduty/fork )
782. Create your feature branch (`git checkout -b my-new-feature`)
793. Commit your changes (`git commit -am 'Add some feature'`)
804. Push to the branch (`git push origin my-new-feature`)
815. Create a new Pull Request
82
83## License
84[Apache 2](http://www.apache.org/licenses/LICENSE-2.0)
85