Skip to content

Commit

Permalink
Merge pull request #197 from PagerDuty/useragent
Browse files Browse the repository at this point in the history
Adding User-Agent Headers
  • Loading branch information
Scott McAllister authored Feb 13, 2020
2 parents 4fb5571 + 828c783 commit 44f00b5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 48 deletions.
61 changes: 29 additions & 32 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
project_name: go-pagerduty
release:
github:
owner: PagerDuty
name: go-pagerduty
draft: false
prerelease: true
name_template: "{{.ProjectName}}-v{{.Version}}"
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- goos:
- linux
- darwin
- windows
goarch:
- amd64
- 386
main: ./command/*.go
binary: pd
archive:
format: tar.gz
format_overrides:
- goos: windows
format: zip
replacements:
amd64: 64-bit
darwin: macOS
linux: Tux
name_template: "{{.Binary}}_{{.Version}}_{{.Os}}-{{.Arch}}"
files:
- LICENSE.txt
- README.md
- examples/*
- CHANGELOG.md
- env:
- CGO_ENABLED=0
- ldflags:
- -s -w -X pagerduty.Version={{.Version}}s
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (c *Client) do(method, path string, body io.Reader, headers *map[string]str
req.Header.Set(k, v)
}
}
req.Header.Set("User-Agent", "go-pagerduty/"+Version)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Token token="+c.authToken)

Expand Down
5 changes: 5 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pagerduty

const (
Version = "1.1.1"
)
23 changes: 7 additions & 16 deletions escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@ type EscalationRule struct {
// EscalationPolicy is a collection of escalation rules.
type EscalationPolicy struct {
APIObject
Name string `json:"name,omitempty"`
EscalationRules []EscalationRule `json:"escalation_rules,omitempty"`
Services []APIObject `json:"services,omitempty"`
NumLoops uint `json:"num_loops,omitempty"`
Teams []APIReference `json:"teams"`
OnCall []EscalationPolicyOnCall `json:"on_call"`
Description string `json:"description,omitempty"`
RepeatEnabled bool `json:"repeat_enabled,omitempty"`
}

//
type EscalationPolicyOnCall struct {
Level uint `json:"level"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
User User `json:"user,omitempty"`
Name string `json:"name,omitempty"`
EscalationRules []EscalationRule `json:"escalation_rules,omitempty"`
Services []APIObject `json:"services,omitempty"`
NumLoops uint `json:"num_loops,omitempty"`
Teams []APIReference `json:"teams"`
Description string `json:"description,omitempty"`
RepeatEnabled bool `json:"repeat_enabled,omitempty"`
}

// ListEscalationPoliciesResponse is the data structure returned from calling the ListEscalationPolicies API endpoint.
Expand Down
1 change: 1 addition & 0 deletions event_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func ManageEvent(e V2Event) (*V2EventResponse, error) {
return nil, err
}
req, _ := http.NewRequest("POST", v2eventEndPoint, bytes.NewBuffer(data))
req.Header.Set("User-Agent", "go-pagerduty/"+Version)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
Expand Down

0 comments on commit 44f00b5

Please sign in to comment.