From c78dbc086a6e52a64cb3b5d83c8ace9d9e97e34c Mon Sep 17 00:00:00 2001 From: Rob Best Date: Wed, 30 Nov 2022 15:37:28 +0000 Subject: [PATCH 1/2] Add GetAll for violations Signed-off-by: Rob Best --- policy_violation.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/policy_violation.go b/policy_violation.go index a7c0360..6270452 100644 --- a/policy_violation.go +++ b/policy_violation.go @@ -22,6 +22,25 @@ type PolicyViolationService struct { client *Client } +func (pvs PolicyViolationService) GetAll(ctx context.Context, suppressed bool, po PageOptions) (p Page[PolicyViolation], err error) { + params := map[string]string{ + "suppressed": strconv.FormatBool(suppressed), + } + + req, err := pvs.client.newRequest(ctx, http.MethodGet, "/api/v1/violation", withParams(params), withPageOptions(po)) + if err != nil { + return + } + + res, err := pvs.client.doRequest(req, &p.Items) + if err != nil { + return + } + + p.TotalCount = res.TotalCount + return +} + func (pvs PolicyViolationService) GetAllForProject(ctx context.Context, projectUUID uuid.UUID, suppressed bool, po PageOptions) (p Page[PolicyViolation], err error) { params := map[string]string{ "suppressed": strconv.FormatBool(suppressed), From 9dc054db4c29459195194cf63fdc845e39c44659 Mon Sep 17 00:00:00 2001 From: Rob Best Date: Thu, 1 Dec 2022 15:05:21 +0000 Subject: [PATCH 2/2] Add Analysis field to PolicyViolation Signed-off-by: Rob Best --- policy_violation.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/policy_violation.go b/policy_violation.go index 6270452..012b0b9 100644 --- a/policy_violation.go +++ b/policy_violation.go @@ -11,11 +11,12 @@ import ( type PolicyViolation struct { UUID uuid.UUID - Component Component `json:"component"` - Project Project `json:"project"` - PolicyCondition *PolicyCondition `json:"policyCondition,omitempty"` - Type string `json:"type"` - Text string `json:"text"` + Component Component `json:"component"` + Project Project `json:"project"` + PolicyCondition *PolicyCondition `json:"policyCondition,omitempty"` + Type string `json:"type"` + Text string `json:"text"` + Analysis *ViolationAnalysis `json:"analysis,omitempty"` } type PolicyViolationService struct {