@@ -72,9 +72,6 @@ func (r *csmThreatsAgentRuleResource) Schema(_ context.Context, _ resource.Schem
72
72
"expression" : schema.StringAttribute {
73
73
Required : true ,
74
74
Description : "The SECL expression of the Agent rule" ,
75
- PlanModifiers : []planmodifier.String {
76
- stringplanmodifier .RequiresReplace (),
77
- },
78
75
},
79
76
},
80
77
}
@@ -99,7 +96,7 @@ func (r *csmThreatsAgentRuleResource) Create(ctx context.Context, request resour
99
96
response .Diagnostics .AddError ("error while parsing resource" , err .Error ())
100
97
}
101
98
102
- res , _ , err := r .api .CreateCSMThreatsAgentRule (r .auth , * agentRulePayload )
99
+ res , _ , err := r .api .CreateCloudWorkloadSecurityAgentRule (r .auth , * agentRulePayload )
103
100
if err != nil {
104
101
response .Diagnostics .Append (utils .FrameworkErrorDiag (err , "error creating agent rule" ))
105
102
return
@@ -121,7 +118,7 @@ func (r *csmThreatsAgentRuleResource) Read(ctx context.Context, request resource
121
118
}
122
119
123
120
agentRuleId := state .Id .ValueString ()
124
- res , httpResponse , err := r .api .GetCSMThreatsAgentRule (r .auth , agentRuleId )
121
+ res , httpResponse , err := r .api .GetCloudWorkloadSecurityAgentRule (r .auth , agentRuleId )
125
122
if err != nil {
126
123
if httpResponse != nil && httpResponse .StatusCode == 404 {
127
124
response .State .RemoveResource (ctx )
@@ -154,7 +151,7 @@ func (r *csmThreatsAgentRuleResource) Update(ctx context.Context, request resour
154
151
response .Diagnostics .AddError ("error while parsing resource" , err .Error ())
155
152
}
156
153
157
- res , _ , err := r .api .UpdateCSMThreatsAgentRule (r .auth , state .Id .ValueString (), * agentRulePayload )
154
+ res , _ , err := r .api .UpdateCloudWorkloadSecurityAgentRule (r .auth , state .Id .ValueString (), * agentRulePayload )
158
155
if err != nil {
159
156
response .Diagnostics .Append (utils .FrameworkErrorDiag (err , "error updating agent rule" ))
160
157
return
@@ -180,7 +177,7 @@ func (r *csmThreatsAgentRuleResource) Delete(ctx context.Context, request resour
180
177
181
178
id := state .Id .ValueString ()
182
179
183
- httpResp , err := r .api .DeleteCSMThreatsAgentRule (r .auth , id )
180
+ httpResp , err := r .api .DeleteCloudWorkloadSecurityAgentRule (r .auth , id )
184
181
if err != nil {
185
182
if httpResp != nil && httpResp .StatusCode == 404 {
186
183
return
@@ -204,11 +201,12 @@ func (r *csmThreatsAgentRuleResource) buildCreateCSMThreatsAgentRulePayload(stat
204
201
}
205
202
206
203
func (r * csmThreatsAgentRuleResource ) buildUpdateCSMThreatsAgentRulePayload (state * csmThreatsAgentRuleModel ) (* datadogV2.CloudWorkloadSecurityAgentRuleUpdateRequest , error ) {
207
- agentRuleId , _ , description , enabled , _ := r .extractAgentRuleAttributesFromResource (state )
204
+ agentRuleId , _ , description , enabled , expression := r .extractAgentRuleAttributesFromResource (state )
208
205
209
206
attributes := datadogV2.CloudWorkloadSecurityAgentRuleUpdateAttributes {}
210
207
attributes .Description = description
211
208
attributes .Enabled = & enabled
209
+ attributes .Expression = & expression
212
210
213
211
data := datadogV2 .NewCloudWorkloadSecurityAgentRuleUpdateData (attributes , datadogV2 .CLOUDWORKLOADSECURITYAGENTRULETYPE_AGENT_RULE )
214
212
data .Id = & agentRuleId
0 commit comments