Skip to content

Commit

Permalink
add UpdateInvestigation method
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Sep 11, 2023
1 parent 47442c6 commit e54a68d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 12 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit e54a68d

Please sign in to comment.