Skip to content

Commit f48c8a6

Browse files
committed
add
1 parent 413aa93 commit f48c8a6

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

tencentcloud/services/cls/resource_tc_cls_alarm.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ func ResourceTencentCloudClsAlarm() *schema.Resource {
9999
},
100100

101101
"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.",
106106
},
107107

108108
"alarm_level": {
@@ -114,10 +114,10 @@ func ResourceTencentCloudClsAlarm() *schema.Resource {
114114
},
115115

116116
"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.",
121121
Elem: &schema.Resource{
122122
Schema: map[string]*schema.Schema{
123123
"condition": {
@@ -311,12 +311,14 @@ func resourceTencentCloudClsAlarmCreate(d *schema.ResourceData, meta interface{}
311311
request.MonitorTime = &monitorTime
312312
}
313313

314-
if v, ok := d.GetOk("condition"); ok {
314+
var changeCondition bool
315+
if v, ok := d.GetOk("condition"); ok && v.(string) != "" {
315316
request.Condition = helper.String(v.(string))
316317
request.AlarmLevel = helper.IntUint64(0)
318+
changeCondition = true
317319
}
318320

319-
if v, ok := d.GetOkExists("alarm_level"); ok {
321+
if v, ok := d.GetOkExists("alarm_level"); ok && changeCondition {
320322
request.AlarmLevel = helper.IntUint64(v.(int))
321323
}
322324

@@ -527,12 +529,11 @@ func resourceTencentCloudClsAlarmRead(d *schema.ResourceData, meta interface{})
527529
_ = d.Set("monitor_time", []interface{}{monitorTimeMap})
528530
}
529531

530-
if alarm.Condition != nil {
532+
if alarm.Condition != nil && *alarm.Condition != "" {
531533
_ = 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+
}
536537
}
537538

538539
if alarm.MultiConditions != nil {
@@ -721,12 +722,14 @@ func resourceTencentCloudClsAlarmUpdate(d *schema.ResourceData, meta interface{}
721722
request.MonitorTime = &monitorTime
722723
}
723724

724-
if v, ok := d.GetOk("condition"); ok {
725+
var changeCondition bool
726+
if v, ok := d.GetOk("condition"); ok && v.(string) != "" {
725727
request.Condition = helper.String(v.(string))
726728
request.AlarmLevel = helper.IntUint64(0)
729+
changeCondition = true
727730
}
728731

729-
if v, ok := d.GetOkExists("alarm_level"); ok {
732+
if v, ok := d.GetOkExists("alarm_level"); ok && changeCondition {
730733
request.AlarmLevel = helper.IntUint64(v.(int))
731734
}
732735

0 commit comments

Comments
 (0)