@@ -10,13 +10,15 @@ const (
1010 PosturePolicyListPath = "%s/api/cspm/v1/policy/policies/list"
1111 PosturePolicyCreatePath = "%s/api/cspm/v1/policy"
1212 PosturePolicyGetPath = "%s/api/cspm/v1/policy/posture/policies/%d?include_controls=true"
13+ PosturePolicyDeletePath = "%s/api/cspm/v1/policy/policies/%d"
1314)
1415
1516type PosturePolicyInterface interface {
1617 Base
1718 ListPosturePolicies (ctx context.Context ) ([]PosturePolicy , error )
1819 CreateOrUpdatePosturePolicy (ctx context.Context , p * CreatePosturePolicy ) (* FullPosturePolicy , string , error )
1920 GetPosturePolicy (ctx context.Context , id int64 ) (* FullPosturePolicy , error )
21+ DeletePosturePolicy (ctx context.Context , id int64 ) error
2022}
2123
2224func (client * Client ) ListPosturePolicies (ctx context.Context ) ([]PosturePolicy , error ) {
@@ -69,10 +71,28 @@ func (client *Client) GetPosturePolicy(ctx context.Context, id int64) (*FullPost
6971 return & wrapper .Data , nil
7072}
7173
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+
7288func (client * Client ) getPolicyUrl (id int64 ) string {
7389 return fmt .Sprintf (PosturePolicyGetPath , client .config .url , id )
7490}
7591
92+ func (client * Client ) deletePolicyUrl (id int64 ) string {
93+ return fmt .Sprintf (PosturePolicyDeletePath , client .config .url , id )
94+ }
95+
7696func (client * Client ) getPosturePolicyURL (path string ) string {
7797 return fmt .Sprintf (path , client .config .url )
7898}
0 commit comments