Skip to content

Commit

Permalink
Merge pull request #248 from PagerDuty/changeEvents_minor-scope-changes
Browse files Browse the repository at this point in the history
Correct namespacing of Change Event resource
  • Loading branch information
Scott McAllister committed Nov 5, 2020
2 parents 4cd79a4 + b968f68 commit bbf15cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions change_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ import (
"errors"
)

const ChangeEventPath = "/v2/change/enqueue"
const changeEventPath = "/v2/change/enqueue"

// ChangeEvent represents a ChangeEvent's request parameters
// https://developer.pagerduty.com/docs/events-api-v2/send-change-events/#parameters
type ChangeEvent struct {
RoutingKey string `json:"routing_key"`
Payload Payload `json:"payload"`
Links []Link `json:"links"`
RoutingKey string `json:"routing_key"`
Payload ChangeEventPayload `json:"payload"`
Links []ChangeEventLink `json:"links"`
}

// Payload ChangeEvent Payload
// ChangeEventPayload ChangeEvent ChangeEventPayload
// https://developer.pagerduty.com/docs/events-api-v2/send-change-events/#example-request-payload
type Payload struct {
type ChangeEventPayload struct {
Source string `json:"source"`
Summary string `json:"summary"`
Timestamp string `json:"timestamp"`
CustomDetails map[string]interface{} `json:"custom_details"`
}

// Link represents a single link in a ChangeEvent
// ChangeEventLink represents a single link in a ChangeEvent
// https://developer.pagerduty.com/docs/events-api-v2/send-change-events/#the-links-property
type Link struct {
type ChangeEventLink struct {
Href string `json:"href"`
Text string `json:"text"`
}
Expand Down Expand Up @@ -57,7 +57,7 @@ func (c *Client) CreateChangeEvent(e ChangeEvent) (*ChangeEventResponse, error)
resp, err := c.doWithEndpoint(
c.v2EventsAPIEndpoint,
"POST",
ChangeEventPath,
changeEventPath,
false,
bytes.NewBuffer(data),
&headers,
Expand Down
8 changes: 4 additions & 4 deletions change_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func TestChangeEvent_Create(t *testing.T) {
eventDetails := map[string]interface{}{"DetailKey1": "DetailValue1", "DetailKey2": "DetailValue2"}
ce := ChangeEvent{
RoutingKey: "a0000000aa0000a0a000aa0a0a0aa000",
Payload: Payload{
Payload: ChangeEventPayload{
Source: "Test runner",
Summary: "Summary can't be blank",
Timestamp: "2020-10-19T03:06:16.318Z",
CustomDetails: eventDetails,
},
Links: []Link{
Links: []ChangeEventLink{
{
Href: "https://acme.pagerduty.dev/build/2",
Text: "View more details in Acme!",
Expand Down Expand Up @@ -92,13 +92,13 @@ func TestChangeEvent_CreateWithPayloadVerification(t *testing.T) {
eventDetails := map[string]interface{}{"DetailKey1": "DetailValue1", "DetailKey2": "DetailValue2"}
ce := ChangeEvent{
RoutingKey: "a0000000aa0000a0a000aa0a0a0aa000",
Payload: Payload{
Payload: ChangeEventPayload{
Source: "Test runner",
Summary: "Summary can't be blank",
Timestamp: "2020-10-19T03:06:16.318Z",
CustomDetails: eventDetails,
},
Links: []Link{
Links: []ChangeEventLink{
{
Href: "https://acme.pagerduty.dev/build/2",
Text: "View more details in Acme!",
Expand Down

0 comments on commit bbf15cc

Please sign in to comment.