@@ -84,14 +84,6 @@ func (r *deploymentRuleResource) Schema(_ context.Context, _ resource.SchemaRequ
8484 Optional : true ,
8585 Description : "The duration for the rule." ,
8686 },
87- "operation_name" : schema.StringAttribute {
88- Optional : true ,
89- Description : "The operation name for faulty deployment detection." ,
90- },
91- "wait_time" : schema.Int64Attribute {
92- Optional : true ,
93- Description : "The wait time for faulty deployment detection." ,
94- },
9587 "query" : schema.StringAttribute {
9688 Optional : true ,
9789 Description : "The query for monitor rules." ,
@@ -253,15 +245,13 @@ func (r *deploymentRuleResource) updateState(ctx context.Context, state *deploym
253245 }
254246
255247 if typeVar , ok := attributes .GetTypeOk (); ok {
256- state .Type = types .StringValue (* typeVar )
248+ state .Type = types .StringValue (string ( * typeVar ) )
257249 }
258250
259251 // Handle options from the response
260252 if options , ok := attributes .GetOptionsOk (); ok {
261253 if state .Options == nil {
262254 state .Options = & deploymentRuleOptionsModel {
263- OperationName : types .StringNull (),
264- WaitTime : types .Int64Null (),
265255 ExcludedResources : types .ListNull (types .StringType ),
266256 Duration : types .Int64Null (),
267257 Query : types .StringNull (),
@@ -271,11 +261,8 @@ func (r *deploymentRuleResource) updateState(ctx context.Context, state *deploym
271261 // Handle options based on rule type like the data source does
272262 if state .Type .ValueString () == "faulty_deployment_detection" {
273263 if fddOptions := options .DeploymentRuleOptionsFaultyDeploymentDetection ; fddOptions != nil {
274- if operationName , ok := fddOptions .GetOperationNameOk (); ok {
275- state .Options .OperationName = types .StringPointerValue (operationName )
276- }
277- if waitTime , ok := fddOptions .GetWaitTimeOk (); ok {
278- state .Options .WaitTime = types .Int64PointerValue (waitTime )
264+ if duration , ok := fddOptions .GetDurationOk (); ok {
265+ state .Options .Duration = types .Int64PointerValue (duration )
279266 }
280267 if excludedResources , ok := fddOptions .GetExcludedResourcesOk (); ok {
281268 if excludedResources != nil && len (* excludedResources ) > 0 {
@@ -317,17 +304,14 @@ func (r *deploymentRuleResource) buildDeploymentRuleRequestBody(ctx context.Cont
317304
318305 // Handle options based on rule type
319306 if state .Options != nil {
320- options := datadogV2.CreateDeploymentRuleParamsDataAttributesOptions {}
307+ options := datadogV2.DeploymentRulesOptions {}
321308
322309 if state .Type .ValueString () == "faulty_deployment_detection" {
323310 fddOptions := state .Options
324311 options .DeploymentRuleOptionsFaultyDeploymentDetection = & datadogV2.DeploymentRuleOptionsFaultyDeploymentDetection {}
325312
326- if ! fddOptions .OperationName .IsNull () {
327- options .DeploymentRuleOptionsFaultyDeploymentDetection .OperationName = fddOptions .OperationName .ValueStringPointer ()
328- }
329- if ! fddOptions .WaitTime .IsNull () {
330- options .DeploymentRuleOptionsFaultyDeploymentDetection .WaitTime = fddOptions .WaitTime .ValueInt64Pointer ()
313+ if ! fddOptions .Duration .IsNull () {
314+ options .DeploymentRuleOptionsFaultyDeploymentDetection .Duration = fddOptions .Duration .ValueInt64Pointer ()
331315 }
332316 if ! fddOptions .ExcludedResources .IsNull () {
333317 var excludedResources []string
@@ -371,17 +355,14 @@ func (r *deploymentRuleResource) buildDeploymentRuleUpdateRequestBody(ctx contex
371355
372356 // Handle options based on rule type
373357 if state .Options != nil {
374- options := datadogV2.UpdateDeploymentRuleParamsDataAttributesOptions {}
358+ options := datadogV2.DeploymentRulesOptions {}
375359
376360 if state .Type .ValueString () == "faulty_deployment_detection" {
377361 fddOptions := state .Options
378362 options .DeploymentRuleOptionsFaultyDeploymentDetection = & datadogV2.DeploymentRuleOptionsFaultyDeploymentDetection {}
379363
380- if ! fddOptions .OperationName .IsNull () {
381- options .DeploymentRuleOptionsFaultyDeploymentDetection .OperationName = fddOptions .OperationName .ValueStringPointer ()
382- }
383- if ! fddOptions .WaitTime .IsNull () {
384- options .DeploymentRuleOptionsFaultyDeploymentDetection .WaitTime = fddOptions .WaitTime .ValueInt64Pointer ()
364+ if ! fddOptions .Duration .IsNull () {
365+ options .DeploymentRuleOptionsFaultyDeploymentDetection .Duration = fddOptions .Duration .ValueInt64Pointer ()
385366 }
386367 if ! fddOptions .ExcludedResources .IsNull () {
387368 var excludedResources []string
@@ -406,7 +387,7 @@ func (r *deploymentRuleResource) buildDeploymentRuleUpdateRequestBody(ctx contex
406387 }
407388
408389 req := datadogV2 .NewUpdateDeploymentRuleParamsWithDefaults ()
409- req .Data = datadogV2 .NewUpdateDeploymentRuleParamsDataWithDefaults ()
390+ req .Data = * datadogV2 .NewUpdateDeploymentRuleParamsDataWithDefaults ()
410391 req .Data .SetAttributes (* attributes )
411392
412393 return req , diags
@@ -422,24 +403,22 @@ func (r *deploymentRuleResource) validateTypeOptionsMatch(ctx context.Context, s
422403 ruleType := state .Type .ValueString ()
423404
424405 // Check for faulty_deployment_detection specific options
425- hasFddOptions := (! state .Options .OperationName .IsNull () ||
426- ! state .Options .WaitTime .IsNull () ||
427- ! state .Options .ExcludedResources .IsNull ())
406+ hasFddOptions :=
407+ ! state .Options .ExcludedResources .IsNull ()
428408
429409 // Check for monitor specific options
430- hasMonitorOptions := (! state .Options .Duration .IsNull () ||
431- ! state .Options .Query .IsNull ())
410+ hasMonitorOptions := ! state .Options .Query .IsNull ()
432411
433412 if ruleType == "faulty_deployment_detection" && hasMonitorOptions {
434413 diags .AddError (
435414 "Invalid options for deployment rule type" ,
436- "Rule type 'faulty_deployment_detection' cannot use monitor options (duration, query). " +
437- "Use faulty deployment detection options instead: operation_name, wait_time , excluded_resources." ,
415+ "Rule type 'faulty_deployment_detection' cannot use monitor options (query). " +
416+ "Use faulty deployment detection options instead: duration , excluded_resources." ,
438417 )
439418 } else if ruleType == "monitor" && hasFddOptions {
440419 diags .AddError (
441420 "Invalid options for deployment rule type" ,
442- "Rule type 'monitor' cannot use faulty deployment detection options (operation_name, wait_time, excluded_resources). " +
421+ "Rule type 'monitor' cannot use faulty deployment detection options (excluded_resources). " +
443422 "Use monitor options instead: duration, query." ,
444423 )
445424 }
0 commit comments