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

Add GetAll for PolicyViolations and add Analysis field #40

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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