Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
feat: add GetAll for PolicyViolations and add Analysis field (#40)
Browse files Browse the repository at this point in the history
* Add GetAll for violations

Signed-off-by: Rob Best <[email protected]>

* Add Analysis field to PolicyViolation

Signed-off-by: Rob Best <[email protected]>

Signed-off-by: Rob Best <[email protected]>
  • Loading branch information
ribbybibby authored Dec 1, 2022
1 parent e54e936 commit 15d88af
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions policy_violation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,37 @@ 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 {
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),
Expand Down

0 comments on commit 15d88af

Please sign in to comment.