Skip to content

Commit

Permalink
Add MergeIncidents (using Incident)
Browse files Browse the repository at this point in the history
Allows for merging of incidents as follows:

    incidents := make([]string, 3)
    incidents[0] = "PXXXXXX"
    incidents[1] = "PYYYYYY"
    incidents[2] = "PZZZZZZ"

    first := incidents[0]
    rest := incidents[1:]

    tomerge := make([]pagerduty.APIObject, 0)

    for i := range rest {
	    inc := pagerduty.Incident{
		APIObject: pagerduty.APIObject{
		    ID:   rest[i],
		    Type: "incident_reference",
		},
	    }
	    tomerge = append(tomerge, inc)
    }
    result := client.MergeIncidents(email, first, tomerge)
  • Loading branch information
atomicules committed Mar 31, 2018
1 parent 078a328 commit 5f7f220
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ func (c *Client) ManageIncidents(from string, incidents []Incident) error {
return e
}

// MergeIncidents
// Uses Incident to match ManageIncidents
func (c *Client) MergeIncidents(from string, id string, incidents []Incident) error {
r := make(map[string][]Incident)
r["source_incidents"] = incidents
headers := make(map[string]string)
headers["From"] = from
_, e := c.put("/incidents/" + id + "/merge", r, &headers)
return e
}

// GetIncident shows detailed information about an incident.
func (c *Client) GetIncident(id string) (*Incident, error) {
resp, err := c.get("/incidents/" + id)
Expand Down

0 comments on commit 5f7f220

Please sign in to comment.