From 216653aa2e12651f4d919afdff3e95a356a48b26 Mon Sep 17 00:00:00 2001 From: atomicules Date: Sat, 31 Mar 2018 13:27:52 +0100 Subject: [PATCH] Add MergeIncidents (using APIObject) 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.APIObject{ ID: rest[i], Type: "incident_reference", } tomerge = append(tomerge, inc) } result := client.MergeIncidents(email, first, tomerge) --- incident.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/incident.go b/incident.go index 3c7a4330..1d6d249d 100644 --- a/incident.go +++ b/incident.go @@ -90,6 +90,17 @@ func (c *Client) ManageIncidents(from string, incidents []Incident) error { return e } +// MergeIncidents +// Uses APIObject for cleaner creation +func (c *Client) MergeIncidents(from string, id string, incidents []APIObject) error { + r := make(map[string][]APIObject) + 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)