From e54a68d6f10fe5bd5f613f7e5464cc6435ff45a7 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Mon, 11 Sep 2023 15:12:07 -0400 Subject: [PATCH] add UpdateInvestigation method --- client.go | 21 +++++++++++++++++++++ types.go | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/client.go b/client.go index 19be9c5..8b927d0 100644 --- a/client.go +++ b/client.go @@ -89,6 +89,27 @@ func (idr *IDR) Investigations(q ...*InvestigationsQuery) (investigations []*Inv return } +func (idr *IDR) UpdateInvestigation(id string, update *InvestigationUpdateRequest) (*Investigation, error) { + req := idr.http.R() + req.SetError(&APIError{}) + req.SetBody(&update) + res, err := req.Patch(idr.URL("/v2/investigations", id)) + if err != nil { + return nil, err + } + if res.IsError() { + e := res.Error().(*APIError) + err := fmt.Errorf("%s: %s", res.Status(), e.Message) + return nil, err + } + var inv *Investigation + err = json.Unmarshal(res.Body(), &inv) + if err != nil { + return nil, err + } + return inv, nil +} + func newIDR(region, apiKey string) (idr *IDR, err error) { h := resty.New() urlS := fmt.Sprintf("https://%s.api.insight.rapid7.com", strings.ToLower(region)) diff --git a/types.go b/types.go index 39ac9e8..a112687 100644 --- a/types.go +++ b/types.go @@ -154,3 +154,15 @@ type InvestigationComments struct { Data []InvestigationCommentData `json:"data"` Metadata Metadata `json:"metadata"` } + +type InvestigationAssignee struct { + Email string `json:"email"` +} + +type InvestigationUpdateRequest struct { + Assignee *InvestigationAssignee `json:"assignee,omitempty"` + Disposition InvestigationDisposition `json:"disposition,omitempty"` + Priority InvestigationPriority `json:"priority,omitempty"` + Status InvestigationStatus `json:"status,omitempty"` + Title string `json:"title,omitempty"` +}