11package v1client
22
33import (
4- "bytes"
5- "encoding/json"
64 "fmt"
75 "net/http"
8-
9- "github.com/google/go-querystring/query"
106)
117
128func (c * V1ApiClient ) CloudPostureListAccounts (queryParams QueryParameters ) (* http.Response , error ) {
13- p , err := query .Values (queryParams )
14- if err != nil {
15- return nil , err
16- }
17- r , err := c .newRequest (
18- http .MethodGet ,
19- "beta/cloudPosture/accounts" ,
20- http .NoBody ,
21- withUrlParameters (p ),
22- )
23- if err != nil {
24- return nil , err
25- }
26-
27- return c .client .Do (r )
9+ return c .searchAndFilter ("beta/cloudPosture/accounts" , "" , queryParams )
2810}
2911
3012func (c * V1ApiClient ) CloudPostureListAccountChecks (filter string , qp QueryParameters ) (* http.Response , error ) {
31- p , err := query .Values (qp )
32- if err != nil {
33- return nil , err
34- }
35- r , err := c .newRequest (
36- http .MethodGet ,
37- "beta/cloudPosture/checks" ,
38- http .NoBody ,
39- withFilter (filter ),
40- withUrlParameters (p ),
41- )
42- if err != nil {
43- return nil , err
44- }
45-
46- return c .client .Do (r )
13+ return c .searchAndFilter ("beta/cloudPosture/checks" , filter , qp )
4714}
4815
4916func (c * V1ApiClient ) CloudPostureScanTemplate (content string , templateType string ) (* http.Response , error ) {
50- jsonInput := map [string ]any {
17+ body := map [string ]any {
5118 "content" : content ,
5219 "type" : templateType ,
5320 }
54- b , err := json .Marshal (jsonInput )
55- if err != nil {
56- return nil , err
57- }
58-
59- r , err := c .newRequest (
60- http .MethodPost ,
61- "beta/cloudPosture/scanTemplate" ,
62- bytes .NewReader (b ),
63- )
64- if err != nil {
65- return nil , err
66- }
67-
68- contentTypeJSON (r )
69-
70- return c .client .Do (r )
21+ return c .genericJSONPost ("beta/cloudPosture/scanTemplate" , body )
7122}
7223
7324func (c * V1ApiClient ) CloudPostureScanAccount (accountId string ) (* http.Response , error ) {
74- r , err := c .newRequest (
75- http .MethodPost ,
76- fmt .Sprintf ("beta/cloudPosture/accounts/%s/scan" , accountId ),
77- http .NoBody ,
78- )
79- if err != nil {
80- return nil , err
81- }
82- return c .client .Do (r )
25+ return c .genericPost (fmt .Sprintf ("beta/cloudPosture/accounts/%s/scan" , accountId ))
8326}
8427
8528func (c * V1ApiClient ) CloudPostureGetAccountScanSettings (accountId string ) (* http.Response , error ) {
86- r , err := c .newRequest (
87- http .MethodGet ,
88- fmt .Sprintf ("beta/cloudPosture/accounts/%s/scanSetting" , accountId ),
89- http .NoBody ,
90- )
91- if err != nil {
92- return nil , err
93- }
94- return c .client .Do (r )
29+ return c .genericGet (fmt .Sprintf ("beta/cloudPosture/accounts/%s/scanSetting" , accountId ))
9530}
9631
9732type UpdateAccountScanSettings struct {
@@ -104,24 +39,70 @@ func (c *V1ApiClient) CloudPostureUpdateAccountScanSettings(
10439 enabled * bool ,
10540 interval int ,
10641) (* http.Response , error ) {
107- apiInput := UpdateAccountScanSettings {
42+ body := UpdateAccountScanSettings {
10843 Enabled : enabled ,
10944 Interval : interval ,
11045 }
111- b , err := json .Marshal (apiInput )
112- if err != nil {
113- return nil , err
114- }
115- r , err := c .newRequest (
116- http .MethodPatch ,
117- fmt .Sprintf ("beta/cloudPosture/accounts/%s/scanSetting" , accountId ),
118- bytes .NewReader (b ),
119- )
120- if err != nil {
121- return nil , err
122- }
46+ return c .genericJSONPatch (fmt .Sprintf ("beta/cloudPosture/accounts/%s/scanSetting" , accountId ), body )
47+ }
48+
49+ func (c * V1ApiClient ) CloudPostureListCustomRules (queryParams QueryParameters ) (* http.Response , error ) {
50+ return c .searchAndFilter ("beta/cloudPosture/customRules" , "" , queryParams )
51+ }
52+
53+ func (c * V1ApiClient ) CloudPostureGetCustomRule (ruleId string ) (* http.Response , error ) {
54+ return c .genericGet (fmt .Sprintf ("beta/cloudPosture/customRules/%s" , ruleId ))
55+ }
56+
57+ type CustomRuleInput struct {
58+ Name string `json:"name"`
59+ Description string `json:"description,omitempty"`
60+ Categories []string `json:"categories"`
61+ RiskLevel string `json:"riskLevel"`
62+ Provider string `json:"provider"`
63+ ResolutionReferenceLink string `json:"resolutionReferenceLink,omitempty"`
64+ RemediationNote string `json:"remediationNote,omitempty"`
65+ Enabled bool `json:"enabled"`
66+ Service string `json:"service"`
67+ ResourceType string `json:"resourceType"`
68+ Attributes []any `json:"attributes"`
69+ EventRules []any `json:"eventRules"`
70+ Slug string `json:"slug,omitempty"`
71+ }
72+
73+ func (c * V1ApiClient ) CloudPostureCreateCustomRule (input CustomRuleInput ) (* http.Response , error ) {
74+ return c .genericJSONPost ("beta/cloudPosture/customRules" , input )
75+ }
76+
77+ type CustomRuleUpdateInput struct {
78+ Name string `json:"name,omitempty"`
79+ Description string `json:"description,omitempty"`
80+ Categories []string `json:"categories,omitempty"`
81+ RiskLevel string `json:"riskLevel,omitempty"`
82+ Provider string `json:"provider,omitempty"`
83+ ResolutionReferenceLink string `json:"resolutionReferenceLink,omitempty"`
84+ RemediationNote string `json:"remediationNote,omitempty"`
85+ Enabled * bool `json:"enabled,omitempty"`
86+ Service string `json:"service,omitempty"`
87+ ResourceType string `json:"resourceType,omitempty"`
88+ Attributes []any `json:"attributes,omitempty"`
89+ EventRules []any `json:"eventRules,omitempty"`
90+ }
91+
92+ func (c * V1ApiClient ) CloudPostureUpdateCustomRule (ruleId string , input CustomRuleUpdateInput ) (* http.Response , error ) {
93+ return c .genericJSONPatch (fmt .Sprintf ("beta/cloudPosture/customRules/%s" , ruleId ), input )
94+ }
95+
96+ func (c * V1ApiClient ) CloudPostureDeleteCustomRule (ruleId string ) (* http.Response , error ) {
97+ return c .genericDelete (fmt .Sprintf ("beta/cloudPosture/customRules/%s" , ruleId ))
98+ }
12399
124- contentTypeJSON (r )
100+ type CustomRuleTestInput struct {
101+ AccountId string `json:"accountId,omitempty"`
102+ Configuration any `json:"configuration"`
103+ Resource any `json:"resource,omitempty"`
104+ }
125105
126- return c .client .Do (r )
106+ func (c * V1ApiClient ) CloudPostureTestCustomRule (input CustomRuleTestInput ) (* http.Response , error ) {
107+ return c .genericJSONPost ("beta/cloudPosture/customRules/test" , input )
127108}
0 commit comments