@@ -28,56 +28,62 @@ func ResourceTencentCloudClsAlarmNotice() *schema.Resource {
28
28
"name" : {
29
29
Required : true ,
30
30
Type : schema .TypeString ,
31
- Description : "alarm notice name." ,
31
+ Description : "Alarm notice name." ,
32
32
},
33
33
34
34
"type" : {
35
35
Required : true ,
36
36
Type : schema .TypeString ,
37
- Description : "notice type." ,
37
+ Description : "Notice type. Value: Trigger, Recovery, All ." ,
38
38
},
39
39
40
40
"notice_receivers" : {
41
41
Optional : true ,
42
42
Type : schema .TypeList ,
43
- Description : "notice receivers." ,
43
+ Description : "Notice receivers." ,
44
44
Elem : & schema.Resource {
45
45
Schema : map [string ]* schema.Schema {
46
46
"receiver_type" : {
47
47
Type : schema .TypeString ,
48
48
Required : true ,
49
- Description : "receiver type, Uin or Group." ,
49
+ Description : "Receiver type, Uin or Group." ,
50
50
},
51
51
"receiver_ids" : {
52
52
Type : schema .TypeSet ,
53
53
Elem : & schema.Schema {
54
54
Type : schema .TypeInt ,
55
55
},
56
56
Required : true ,
57
- Description : "receiver id." ,
57
+ Description : "Receiver id list ." ,
58
58
},
59
59
"receiver_channels" : {
60
60
Type : schema .TypeSet ,
61
61
Elem : & schema.Schema {
62
62
Type : schema .TypeString ,
63
63
},
64
64
Required : true ,
65
- Description : "receiver channels, Email,Sms,WeChat or Phone." ,
65
+ Description : "Receiver channels, Value: Email, Sms, WeChat, Phone." ,
66
+ },
67
+ "notice_content_id" : {
68
+ Type : schema .TypeString ,
69
+ Optional : true ,
70
+ Description : "Notice content ID." ,
66
71
},
67
72
"start_time" : {
68
73
Type : schema .TypeString ,
69
74
Optional : true ,
70
- Description : "start time allowed to receive messages." ,
75
+ Description : "Start time allowed to receive messages." ,
71
76
},
72
77
"end_time" : {
73
78
Type : schema .TypeString ,
74
79
Optional : true ,
75
- Description : "end time allowed to receive messages." ,
80
+ Description : "End time allowed to receive messages." ,
76
81
},
77
82
"index" : {
78
83
Type : schema .TypeInt ,
79
84
Optional : true ,
80
- Description : "index." ,
85
+ Computed : true ,
86
+ Description : "Index. The input parameter is invalid, but the output parameter is valid." ,
81
87
},
82
88
},
83
89
},
@@ -86,41 +92,71 @@ func ResourceTencentCloudClsAlarmNotice() *schema.Resource {
86
92
"web_callbacks" : {
87
93
Optional : true ,
88
94
Type : schema .TypeList ,
89
- Description : "callback info." ,
95
+ Description : "Callback info." ,
90
96
Elem : & schema.Resource {
91
97
Schema : map [string ]* schema.Schema {
92
- "url " : {
98
+ "callback_type " : {
93
99
Type : schema .TypeString ,
94
100
Required : true ,
95
- Description : "callback url ." ,
101
+ Description : "Callback type, Values: Http, WeCom, DingTalk, Lark ." ,
96
102
},
97
- "callback_type " : {
103
+ "url " : {
98
104
Type : schema .TypeString ,
99
105
Required : true ,
100
- Description : "callback type, WeCom or Http." ,
106
+ Description : "Callback url." ,
107
+ },
108
+ "web_callback_id" : {
109
+ Type : schema .TypeString ,
110
+ Optional : true ,
111
+ Description : "Integration configuration ID." ,
101
112
},
102
113
"method" : {
103
114
Type : schema .TypeString ,
104
115
Optional : true ,
105
116
Description : "Method, POST or PUT." ,
106
117
},
118
+ "notice_content_id" : {
119
+ Type : schema .TypeString ,
120
+ Optional : true ,
121
+ Description : "Notice content ID." ,
122
+ },
123
+ "remind_type" : {
124
+ Type : schema .TypeInt ,
125
+ Optional : true ,
126
+ Description : "Remind type. 0: Do not remind; 1: Specified person; 2: Everyone." ,
127
+ },
128
+ "mobiles" : {
129
+ Type : schema .TypeSet ,
130
+ Optional : true ,
131
+ Elem : & schema.Schema {Type : schema .TypeString },
132
+ Description : "Telephone list." ,
133
+ },
134
+ "user_ids" : {
135
+ Type : schema .TypeSet ,
136
+ Optional : true ,
137
+ Elem : & schema.Schema {Type : schema .TypeString },
138
+ Description : "User ID list." ,
139
+ },
107
140
"headers" : {
108
141
Type : schema .TypeSet ,
109
142
Elem : & schema.Schema {
110
143
Type : schema .TypeString ,
111
144
},
112
145
Optional : true ,
113
- Description : "abandoned." ,
146
+ Deprecated : "This parameter is deprecated. Please use `notice_content_id`." ,
147
+ Description : "Request headers." ,
114
148
},
115
149
"body" : {
116
150
Type : schema .TypeString ,
117
151
Optional : true ,
118
- Description : "abandoned." ,
152
+ Deprecated : "This parameter is deprecated. Please use `notice_content_id`." ,
153
+ Description : "Request body." ,
119
154
},
120
155
"index" : {
121
156
Type : schema .TypeInt ,
122
157
Optional : true ,
123
- Description : "index." ,
158
+ Computed : true ,
159
+ Description : "Index. The input parameter is invalid, but the output parameter is valid." ,
124
160
},
125
161
},
126
162
},
@@ -175,14 +211,17 @@ func resourceTencentCloudClsAlarmNoticeCreate(d *schema.ResourceData, meta inter
175
211
noticeReceiver .ReceiverChannels = append (noticeReceiver .ReceiverChannels , & receiverChannels )
176
212
}
177
213
}
178
- if v , ok := dMap ["start_time" ]; ok {
179
- noticeReceiver .StartTime = helper .String (v .(string ))
214
+ if v , ok := dMap ["notice_content_id" ].(string ); ok && v != "" {
215
+ noticeReceiver .NoticeContentId = helper .String (v )
216
+ }
217
+ if v , ok := dMap ["start_time" ].(string ); ok && v != "" {
218
+ noticeReceiver .StartTime = helper .String (v )
180
219
}
181
- if v , ok := dMap ["end_time" ]; ok {
182
- noticeReceiver .EndTime = helper .String (v .( string ) )
220
+ if v , ok := dMap ["end_time" ].( string ) ; ok && v != "" {
221
+ noticeReceiver .EndTime = helper .String (v )
183
222
}
184
- if v , ok := dMap ["index" ]; ok {
185
- noticeReceiver .Index = helper .IntInt64 (v .( int ) )
223
+ if v , ok := dMap ["index" ].( int ) ; ok && v != 0 {
224
+ noticeReceiver .Index = helper .IntInt64 (v )
186
225
}
187
226
request .NoticeReceivers = append (request .NoticeReceivers , & noticeReceiver )
188
227
}
@@ -192,14 +231,37 @@ func resourceTencentCloudClsAlarmNoticeCreate(d *schema.ResourceData, meta inter
192
231
for _ , item := range v .([]interface {}) {
193
232
dMap := item .(map [string ]interface {})
194
233
webCallback := cls.WebCallback {}
234
+ if v , ok := dMap ["callback_type" ]; ok {
235
+ webCallback .CallbackType = helper .String (v .(string ))
236
+ }
195
237
if v , ok := dMap ["url" ]; ok {
196
238
webCallback .Url = helper .String (v .(string ))
197
239
}
198
- if v , ok := dMap ["callback_type" ]; ok {
199
- webCallback .CallbackType = helper .String (v .(string ))
240
+ if v , ok := dMap ["web_callback_id" ].(string ); ok && v != "" {
241
+ webCallback .WebCallbackId = helper .String (v )
242
+ }
243
+ if v , ok := dMap ["method" ].(string ); ok && v != "" {
244
+ webCallback .Method = helper .String (v )
200
245
}
201
- if v , ok := dMap ["method" ]; ok {
202
- webCallback .Method = helper .String (v .(string ))
246
+ if v , ok := dMap ["notice_content_id" ].(string ); ok && v != "" {
247
+ webCallback .NoticeContentId = helper .String (v )
248
+ }
249
+ if v , ok := dMap ["remind_type" ]; ok {
250
+ webCallback .RemindType = helper .IntUint64 (v .(int ))
251
+ }
252
+ if v , ok := dMap ["mobiles" ]; ok {
253
+ mobilesSet := v .(* schema.Set ).List ()
254
+ for i := range mobilesSet {
255
+ mobile := mobilesSet [i ].(string )
256
+ webCallback .Mobiles = append (webCallback .Mobiles , & mobile )
257
+ }
258
+ }
259
+ if v , ok := dMap ["user_ids" ]; ok {
260
+ userIdsSet := v .(* schema.Set ).List ()
261
+ for i := range userIdsSet {
262
+ userId := userIdsSet [i ].(string )
263
+ webCallback .UserIds = append (webCallback .UserIds , & userId )
264
+ }
203
265
}
204
266
if v , ok := dMap ["headers" ]; ok {
205
267
headersSet := v .(* schema.Set ).List ()
@@ -211,8 +273,8 @@ func resourceTencentCloudClsAlarmNoticeCreate(d *schema.ResourceData, meta inter
211
273
if v , ok := dMap ["body" ]; ok {
212
274
webCallback .Body = helper .String (v .(string ))
213
275
}
214
- if v , ok := dMap ["index" ]; ok {
215
- webCallback .Index = helper .IntInt64 (v .( int ) )
276
+ if v , ok := dMap ["index" ].( int ) ; ok && v != 0 {
277
+ webCallback .Index = helper .IntInt64 (v )
216
278
}
217
279
request .WebCallbacks = append (request .WebCallbacks , & webCallback )
218
280
}
@@ -297,6 +359,10 @@ func resourceTencentCloudClsAlarmNoticeRead(d *schema.ResourceData, meta interfa
297
359
noticeReceiversMap ["receiver_channels" ] = noticeReceiver .ReceiverChannels
298
360
}
299
361
362
+ if noticeReceiver .NoticeContentId != nil {
363
+ noticeReceiversMap ["notice_content_id" ] = noticeReceiver .NoticeContentId
364
+ }
365
+
300
366
if noticeReceiver .StartTime != nil {
301
367
noticeReceiversMap ["start_time" ] = noticeReceiver .StartTime
302
368
}
@@ -321,20 +387,55 @@ func resourceTencentCloudClsAlarmNoticeRead(d *schema.ResourceData, meta interfa
321
387
for _ , webCallback := range alarmNotice .WebCallbacks {
322
388
webCallbacksMap := map [string ]interface {}{}
323
389
390
+ if webCallback .CallbackType != nil {
391
+ webCallbacksMap ["callback_type" ] = webCallback .CallbackType
392
+ }
393
+
324
394
if webCallback .Url != nil {
325
395
webCallbacksMap ["url" ] = webCallback .Url
326
396
}
327
397
328
- if webCallback .CallbackType != nil {
329
- webCallbacksMap ["callback_type " ] = webCallback .CallbackType
398
+ if webCallback .WebCallbackId != nil {
399
+ webCallbacksMap ["web_callback_id " ] = webCallback .WebCallbackId
330
400
}
331
401
332
402
if webCallback .Method != nil {
333
403
webCallbacksMap ["method" ] = webCallback .Method
334
404
}
335
405
406
+ if webCallback .NoticeContentId != nil {
407
+ webCallbacksMap ["notice_content_id" ] = webCallback .NoticeContentId
408
+ }
409
+
410
+ if webCallback .RemindType != nil {
411
+ webCallbacksMap ["remind_type" ] = webCallback .RemindType
412
+ }
413
+
414
+ if webCallback .Mobiles != nil {
415
+ tmpList := make ([]string , 0 , len (webCallback .Mobiles ))
416
+ for _ , item := range webCallback .Mobiles {
417
+ tmpList = append (tmpList , * item )
418
+ }
419
+
420
+ webCallbacksMap ["mobiles" ] = tmpList
421
+ }
422
+
423
+ if webCallback .UserIds != nil {
424
+ tmpList := make ([]string , 0 , len (webCallback .UserIds ))
425
+ for _ , item := range webCallback .UserIds {
426
+ tmpList = append (tmpList , * item )
427
+ }
428
+
429
+ webCallbacksMap ["user_ids" ] = tmpList
430
+ }
431
+
336
432
if webCallback .Headers != nil {
337
- webCallbacksMap ["headers" ] = webCallback .Headers
433
+ tmpList := make ([]string , 0 , len (webCallback .Headers ))
434
+ for _ , item := range webCallback .Headers {
435
+ tmpList = append (tmpList , * item )
436
+ }
437
+
438
+ webCallbacksMap ["headers" ] = tmpList
338
439
}
339
440
340
441
if webCallback .Body != nil {
@@ -397,8 +498,8 @@ func resourceTencentCloudClsAlarmNoticeUpdate(d *schema.ResourceData, meta inter
397
498
398
499
if v , ok := d .GetOk ("notice_receivers" ); ok {
399
500
for _ , item := range v .([]interface {}) {
400
- noticeReceiver := cls.NoticeReceiver {}
401
501
dMap := item .(map [string ]interface {})
502
+ noticeReceiver := cls.NoticeReceiver {}
402
503
if v , ok := dMap ["receiver_type" ]; ok {
403
504
noticeReceiver .ReceiverType = helper .String (v .(string ))
404
505
}
@@ -416,31 +517,57 @@ func resourceTencentCloudClsAlarmNoticeUpdate(d *schema.ResourceData, meta inter
416
517
noticeReceiver .ReceiverChannels = append (noticeReceiver .ReceiverChannels , & receiverChannels )
417
518
}
418
519
}
419
- if v , ok := dMap ["start_time" ] ; ok {
420
- noticeReceiver .StartTime = helper .String (v .( string ) )
520
+ if v , ok := dMap ["notice_content_id" ].( string ) ; ok && v != "" {
521
+ noticeReceiver .NoticeContentId = helper .String (v )
421
522
}
422
- if v , ok := dMap ["end_time" ] ; ok {
423
- noticeReceiver .EndTime = helper .String (v .( string ) )
523
+ if v , ok := dMap ["start_time" ].( string ) ; ok && v != "" {
524
+ noticeReceiver .StartTime = helper .String (v )
424
525
}
425
- if v , ok := dMap ["index" ]; ok {
426
- noticeReceiver .Index = helper .IntInt64 (v .(int ))
526
+ if v , ok := dMap ["end_time" ].(string ); ok && v != "" {
527
+ noticeReceiver .EndTime = helper .String (v )
528
+ }
529
+ if v , ok := dMap ["index" ].(int ); ok && v != 0 {
530
+ noticeReceiver .Index = helper .IntInt64 (v )
427
531
}
428
532
request .NoticeReceivers = append (request .NoticeReceivers , & noticeReceiver )
429
533
}
430
534
}
431
535
432
536
if v , ok := d .GetOk ("web_callbacks" ); ok {
433
537
for _ , item := range v .([]interface {}) {
434
- webCallback := cls.WebCallback {}
435
538
dMap := item .(map [string ]interface {})
539
+ webCallback := cls.WebCallback {}
540
+ if v , ok := dMap ["callback_type" ]; ok {
541
+ webCallback .CallbackType = helper .String (v .(string ))
542
+ }
436
543
if v , ok := dMap ["url" ]; ok {
437
544
webCallback .Url = helper .String (v .(string ))
438
545
}
439
- if v , ok := dMap ["callback_type" ]; ok {
440
- webCallback .CallbackType = helper .String (v .(string ))
546
+ if v , ok := dMap ["web_callback_id" ].(string ); ok && v != "" {
547
+ webCallback .WebCallbackId = helper .String (v )
548
+ }
549
+ if v , ok := dMap ["method" ].(string ); ok && v != "" {
550
+ webCallback .Method = helper .String (v )
551
+ }
552
+ if v , ok := dMap ["notice_content_id" ].(string ); ok && v != "" {
553
+ webCallback .NoticeContentId = helper .String (v )
441
554
}
442
- if v , ok := dMap ["method" ]; ok {
443
- webCallback .Method = helper .String (v .(string ))
555
+ if v , ok := dMap ["remind_type" ]; ok {
556
+ webCallback .RemindType = helper .IntUint64 (v .(int ))
557
+ }
558
+ if v , ok := dMap ["mobiles" ]; ok {
559
+ mobilesSet := v .(* schema.Set ).List ()
560
+ for i := range mobilesSet {
561
+ mobile := mobilesSet [i ].(string )
562
+ webCallback .Mobiles = append (webCallback .Mobiles , & mobile )
563
+ }
564
+ }
565
+ if v , ok := dMap ["user_ids" ]; ok {
566
+ userIdsSet := v .(* schema.Set ).List ()
567
+ for i := range userIdsSet {
568
+ userId := userIdsSet [i ].(string )
569
+ webCallback .UserIds = append (webCallback .UserIds , & userId )
570
+ }
444
571
}
445
572
if v , ok := dMap ["headers" ]; ok {
446
573
headersSet := v .(* schema.Set ).List ()
@@ -452,8 +579,8 @@ func resourceTencentCloudClsAlarmNoticeUpdate(d *schema.ResourceData, meta inter
452
579
if v , ok := dMap ["body" ]; ok {
453
580
webCallback .Body = helper .String (v .(string ))
454
581
}
455
- if v , ok := dMap ["index" ]; ok {
456
- webCallback .Index = helper .IntInt64 (v .( int ) )
582
+ if v , ok := dMap ["index" ].( int ) ; ok && v != 0 {
583
+ webCallback .Index = helper .IntInt64 (v )
457
584
}
458
585
request .WebCallbacks = append (request .WebCallbacks , & webCallback )
459
586
}
0 commit comments