@@ -10,13 +10,15 @@ const (
10
10
PosturePolicyListPath = "%s/api/cspm/v1/policy/policies/list"
11
11
PosturePolicyCreatePath = "%s/api/cspm/v1/policy"
12
12
PosturePolicyGetPath = "%s/api/cspm/v1/policy/posture/policies/%d?include_controls=true"
13
+ PosturePolicyDeletePath = "%s/api/cspm/v1/policy/policies/%d"
13
14
)
14
15
15
16
type PosturePolicyInterface interface {
16
17
Base
17
18
ListPosturePolicies (ctx context.Context ) ([]PosturePolicy , error )
18
19
CreateOrUpdatePosturePolicy (ctx context.Context , p * CreatePosturePolicy ) (* FullPosturePolicy , string , error )
19
20
GetPosturePolicy (ctx context.Context , id int64 ) (* FullPosturePolicy , error )
21
+ DeletePosturePolicy (ctx context.Context , id int64 ) error
20
22
}
21
23
22
24
func (client * Client ) ListPosturePolicies (ctx context.Context ) ([]PosturePolicy , error ) {
@@ -69,10 +71,28 @@ func (client *Client) GetPosturePolicy(ctx context.Context, id int64) (*FullPost
69
71
return & wrapper .Data , nil
70
72
}
71
73
74
+ func (client * Client ) DeletePosturePolicy (ctx context.Context , id int64 ) error {
75
+ response , err := client .requester .Request (ctx , http .MethodDelete , client .deletePolicyUrl (id ), nil )
76
+ if err != nil {
77
+ return err
78
+ }
79
+ defer response .Body .Close ()
80
+
81
+ if response .StatusCode != http .StatusNoContent && response .StatusCode != http .StatusOK && response .StatusCode != http .StatusNotFound {
82
+ return client .ErrorFromResponse (response )
83
+ }
84
+
85
+ return nil
86
+ }
87
+
72
88
func (client * Client ) getPolicyUrl (id int64 ) string {
73
89
return fmt .Sprintf (PosturePolicyGetPath , client .config .url , id )
74
90
}
75
91
92
+ func (client * Client ) deletePolicyUrl (id int64 ) string {
93
+ return fmt .Sprintf (PosturePolicyDeletePath , client .config .url , id )
94
+ }
95
+
76
96
func (client * Client ) getPosturePolicyURL (path string ) string {
77
97
return fmt .Sprintf (path , client .config .url )
78
98
}
0 commit comments