@@ -99,10 +99,10 @@ func ResourceTencentCloudClsAlarm() *schema.Resource {
99
99
},
100
100
101
101
"condition" : {
102
- Optional : true ,
103
- Type : schema .TypeString ,
104
- ConflictsWith : []string {"multi_conditions" },
105
- Description : "Trigger condition." ,
102
+ Optional : true ,
103
+ Type : schema .TypeString ,
104
+ ExactlyOneOf : []string {"multi_conditions" },
105
+ Description : "Trigger condition." ,
106
106
},
107
107
108
108
"alarm_level" : {
@@ -114,10 +114,10 @@ func ResourceTencentCloudClsAlarm() *schema.Resource {
114
114
},
115
115
116
116
"multi_conditions" : {
117
- Optional : true ,
118
- Type : schema .TypeList ,
119
- ConflictsWith : []string {"condition" , "alarm_level " },
120
- Description : "Multiple triggering conditions." ,
117
+ Optional : true ,
118
+ Type : schema .TypeList ,
119
+ ExactlyOneOf : []string {"condition" },
120
+ Description : "Multiple triggering conditions." ,
121
121
Elem : & schema.Resource {
122
122
Schema : map [string ]* schema.Schema {
123
123
"condition" : {
@@ -311,12 +311,14 @@ func resourceTencentCloudClsAlarmCreate(d *schema.ResourceData, meta interface{}
311
311
request .MonitorTime = & monitorTime
312
312
}
313
313
314
- if v , ok := d .GetOk ("condition" ); ok {
314
+ var changeCondition bool
315
+ if v , ok := d .GetOk ("condition" ); ok && v .(string ) != "" {
315
316
request .Condition = helper .String (v .(string ))
316
317
request .AlarmLevel = helper .IntUint64 (0 )
318
+ changeCondition = true
317
319
}
318
320
319
- if v , ok := d .GetOkExists ("alarm_level" ); ok {
321
+ if v , ok := d .GetOkExists ("alarm_level" ); ok && changeCondition {
320
322
request .AlarmLevel = helper .IntUint64 (v .(int ))
321
323
}
322
324
@@ -527,12 +529,11 @@ func resourceTencentCloudClsAlarmRead(d *schema.ResourceData, meta interface{})
527
529
_ = d .Set ("monitor_time" , []interface {}{monitorTimeMap })
528
530
}
529
531
530
- if alarm .Condition != nil {
532
+ if alarm .Condition != nil && * alarm . Condition != "" {
531
533
_ = d .Set ("condition" , alarm .Condition )
532
- }
533
-
534
- if alarm .AlarmLevel != nil {
535
- _ = d .Set ("alarm_level" , alarm .AlarmLevel )
534
+ if alarm .AlarmLevel != nil {
535
+ _ = d .Set ("alarm_level" , alarm .AlarmLevel )
536
+ }
536
537
}
537
538
538
539
if alarm .MultiConditions != nil {
@@ -721,12 +722,14 @@ func resourceTencentCloudClsAlarmUpdate(d *schema.ResourceData, meta interface{}
721
722
request .MonitorTime = & monitorTime
722
723
}
723
724
724
- if v , ok := d .GetOk ("condition" ); ok {
725
+ var changeCondition bool
726
+ if v , ok := d .GetOk ("condition" ); ok && v .(string ) != "" {
725
727
request .Condition = helper .String (v .(string ))
726
728
request .AlarmLevel = helper .IntUint64 (0 )
729
+ changeCondition = true
727
730
}
728
731
729
- if v , ok := d .GetOkExists ("alarm_level" ); ok {
732
+ if v , ok := d .GetOkExists ("alarm_level" ); ok && changeCondition {
730
733
request .AlarmLevel = helper .IntUint64 (v .(int ))
731
734
}
732
735
0 commit comments