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

Commit 15d88af

Browse files
authored
feat: add GetAll for PolicyViolations and add Analysis field (#40)
* 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]>
1 parent e54e936 commit 15d88af

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

policy_violation.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,37 @@ import (
1111

1212
type PolicyViolation struct {
1313
UUID uuid.UUID
14-
Component Component `json:"component"`
15-
Project Project `json:"project"`
16-
PolicyCondition *PolicyCondition `json:"policyCondition,omitempty"`
17-
Type string `json:"type"`
18-
Text string `json:"text"`
14+
Component Component `json:"component"`
15+
Project Project `json:"project"`
16+
PolicyCondition *PolicyCondition `json:"policyCondition,omitempty"`
17+
Type string `json:"type"`
18+
Text string `json:"text"`
19+
Analysis *ViolationAnalysis `json:"analysis,omitempty"`
1920
}
2021

2122
type PolicyViolationService struct {
2223
client *Client
2324
}
2425

26+
func (pvs PolicyViolationService) GetAll(ctx context.Context, suppressed bool, po PageOptions) (p Page[PolicyViolation], err error) {
27+
params := map[string]string{
28+
"suppressed": strconv.FormatBool(suppressed),
29+
}
30+
31+
req, err := pvs.client.newRequest(ctx, http.MethodGet, "/api/v1/violation", withParams(params), withPageOptions(po))
32+
if err != nil {
33+
return
34+
}
35+
36+
res, err := pvs.client.doRequest(req, &p.Items)
37+
if err != nil {
38+
return
39+
}
40+
41+
p.TotalCount = res.TotalCount
42+
return
43+
}
44+
2545
func (pvs PolicyViolationService) GetAllForProject(ctx context.Context, projectUUID uuid.UUID, suppressed bool, po PageOptions) (p Page[PolicyViolation], err error) {
2646
params := map[string]string{
2747
"suppressed": strconv.FormatBool(suppressed),

0 commit comments

Comments
 (0)