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

..03-May-2022-

go-pagerduty-cf1437c7c8d6/H03-May-2022-

.gitignoreH A D30-Aug-201912

.goreleaser.ymlH A D30-Aug-2019578

CHANGELOG.mdH A D30-Aug-20199.9 KiB

DockerfileH A D30-Aug-2019160

MakefileH A D30-Aug-2019387

README.mdH A D30-Aug-20192.3 KiB

ability.goH A D30-Aug-2019617

addon.goH A D30-Aug-20192.5 KiB

client.goH A D30-Aug-20195.2 KiB

escalation_policy.goH A D30-Aug-20196.5 KiB

event.goH A D30-Aug-20192.1 KiB

event_v2.goH A D30-Aug-20192.1 KiB

incident.goH A D30-Aug-20198.1 KiB

log_entry.goH A D30-Aug-20192.5 KiB

maintenance_window.goH A D30-Aug-20193.7 KiB

notification.goH A D30-Aug-20191.3 KiB

on_call.goH A D30-Aug-20191.7 KiB

priorites.goH A D30-Aug-2019630

schedule.goH A D30-Aug-20198.6 KiB

service.goH A D30-Aug-20197.4 KiB

team.goH A D30-Aug-20192.9 KiB

user.goH A D30-Aug-20193.6 KiB

vendor.goH A D30-Aug-20192.1 KiB

webhook.goH A D30-Aug-20191.3 KiB

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