@@ -91,20 +91,23 @@ func ResourceTencentCloudClsTopic() *schema.Resource {
91
91
"extends" : {
92
92
Type : schema .TypeList ,
93
93
Optional : true ,
94
+ Computed : true ,
94
95
MaxItems : 1 ,
95
96
Description : "Log Subject Extension Information." ,
96
97
Elem : & schema.Resource {
97
98
Schema : map [string ]* schema.Schema {
98
99
"anonymous_access" : {
99
- Type : schema .TypeString ,
100
+ Type : schema .TypeList ,
100
101
Optional : true ,
102
+ MaxItems : 1 ,
101
103
Description : "Log topic authentication free configuration information." ,
102
104
Elem : & schema.Resource {
103
105
Schema : map [string ]* schema.Schema {
104
106
"operations" : {
105
107
Type : schema .TypeList ,
106
108
Optional : true ,
107
109
Description : "Operation list, supporting trackLog (JS/HTTP upload log) and realtimeProducer (kafka protocol upload log)." ,
110
+ Elem : & schema.Schema {Type : schema .TypeString },
108
111
},
109
112
"conditions" : {
110
113
Type : schema .TypeList ,
@@ -202,22 +205,23 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
202
205
request .IsWebTracking = helper .Bool (v .(bool ))
203
206
}
204
207
205
- if v , ok := d .GetOk ("extends" ); ok {
206
- topicExtendInfoList := make ([]* cls.TopicExtendInfo , 0 )
207
- for _ , item := range v .([]interface {}) {
208
- topicExtendInfo := cls.TopicExtendInfo {}
209
- tmpMap := item .(map [string ]interface {})
208
+ if dMap , ok := helper .InterfacesHeadMap (d , "extends" ); ok {
209
+ topicExtendInfo := cls.TopicExtendInfo {}
210
+ if anonymousAccessMap , ok := helper .InterfaceToMap (dMap , "anonymous_access" ); ok {
210
211
anonymousInfo := cls.AnonymousInfo {}
211
- if v , ok := tmpMap ["operations" ]; ok {
212
- valuesSet := v .(* schema.Set ).List ()
213
- anonymousInfo .Operations = helper .InterfacesStringsPoint (valuesSet )
212
+ if v , ok := anonymousAccessMap ["operations" ]; ok {
213
+ tmpList := make ([]* string , 0 )
214
+ for _ , operation := range v .([]interface {}) {
215
+ tmpList = append (tmpList , helper .String (operation .(string )))
216
+ }
217
+
218
+ anonymousInfo .Operations = tmpList
214
219
}
215
220
216
- if v , ok := tmpMap ["conditions" ]; ok {
217
- conditionInfoList := make ([]* cls.ConditionInfo , 0 )
221
+ if v , ok := anonymousAccessMap ["conditions" ]; ok {
218
222
for _ , condition := range v .([]interface {}) {
219
- conditionInfo := cls.ConditionInfo {}
220
223
conditionMap := condition .(map [string ]interface {})
224
+ conditionInfo := cls.ConditionInfo {}
221
225
if v , ok := conditionMap ["attributes" ]; ok {
222
226
conditionInfo .Attributes = helper .String (v .(string ))
223
227
}
@@ -229,16 +233,15 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
229
233
if v , ok := conditionMap ["condition_value" ]; ok {
230
234
conditionInfo .ConditionValue = helper .String (v .(string ))
231
235
}
232
- }
233
236
234
- anonymousInfo .Conditions = conditionInfoList
237
+ anonymousInfo .Conditions = append (anonymousInfo .Conditions , & conditionInfo )
238
+ }
235
239
}
236
240
237
241
topicExtendInfo .AnonymousAccess = & anonymousInfo
238
- topicExtendInfoList = append (topicExtendInfoList , & topicExtendInfo )
239
242
}
240
243
241
- request .Extends = topicExtendInfoList [ 0 ]
244
+ request .Extends = & topicExtendInfo
242
245
}
243
246
244
247
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
@@ -308,6 +311,47 @@ func resourceTencentCloudClsTopicRead(d *schema.ResourceData, meta interface{})
308
311
_ = d .Set ("describes" , topic .Describes )
309
312
_ = d .Set ("is_web_tracking" , topic .IsWebTracking )
310
313
314
+ if topic .Extends != nil {
315
+ extendMap := map [string ]interface {}{}
316
+ if topic .Extends .AnonymousAccess != nil {
317
+ anonymousAccessMap := map [string ]interface {}{}
318
+ if topic .Extends .AnonymousAccess .Operations != nil {
319
+ operationList := make ([]string , 0 , len (topic .Extends .AnonymousAccess .Operations ))
320
+ for _ , v := range topic .Extends .AnonymousAccess .Operations {
321
+ operationList = append (operationList , * v )
322
+ }
323
+
324
+ anonymousAccessMap ["operations" ] = operationList
325
+ }
326
+
327
+ if topic .Extends .AnonymousAccess .Conditions != nil {
328
+ conditionList := []interface {}{}
329
+ for _ , v := range topic .Extends .AnonymousAccess .Conditions {
330
+ conditionMap := map [string ]interface {}{}
331
+ if v .Attributes != nil {
332
+ conditionMap ["attributes" ] = * v .Attributes
333
+ }
334
+
335
+ if v .Rule != nil {
336
+ conditionMap ["rule" ] = * v .Rule
337
+ }
338
+
339
+ if v .ConditionValue != nil {
340
+ conditionMap ["condition_value" ] = * v .ConditionValue
341
+ }
342
+
343
+ conditionList = append (conditionList , conditionMap )
344
+ }
345
+
346
+ anonymousAccessMap ["conditions" ] = conditionList
347
+ }
348
+
349
+ extendMap ["anonymous_access" ] = []interface {}{anonymousAccessMap }
350
+ }
351
+
352
+ _ = d .Set ("extends" , []interface {}{extendMap })
353
+ }
354
+
311
355
return nil
312
356
}
313
357
@@ -367,6 +411,53 @@ func resourceTencentCloudClsTopicUpdate(d *schema.ResourceData, meta interface{}
367
411
request .Describes = helper .String (d .Get ("describes" ).(string ))
368
412
}
369
413
414
+ if d .HasChange ("is_web_tracking" ) {
415
+ if v , ok := d .GetOkExists ("is_web_tracking" ); ok {
416
+ request .IsWebTracking = helper .Bool (v .(bool ))
417
+ }
418
+ }
419
+
420
+ if d .HasChange ("extends" ) {
421
+ if dMap , ok := helper .InterfacesHeadMap (d , "extends" ); ok {
422
+ topicExtendInfo := cls.TopicExtendInfo {}
423
+ if anonymousAccessMap , ok := helper .InterfaceToMap (dMap , "anonymous_access" ); ok {
424
+ anonymousInfo := cls.AnonymousInfo {}
425
+ if v , ok := anonymousAccessMap ["operations" ]; ok {
426
+ tmpList := make ([]* string , 0 )
427
+ for _ , operation := range v .([]interface {}) {
428
+ tmpList = append (tmpList , helper .String (operation .(string )))
429
+ }
430
+
431
+ anonymousInfo .Operations = tmpList
432
+ }
433
+
434
+ if v , ok := anonymousAccessMap ["conditions" ]; ok {
435
+ for _ , condition := range v .([]interface {}) {
436
+ conditionMap := condition .(map [string ]interface {})
437
+ conditionInfo := cls.ConditionInfo {}
438
+ if v , ok := conditionMap ["attributes" ]; ok {
439
+ conditionInfo .Attributes = helper .String (v .(string ))
440
+ }
441
+
442
+ if v , ok := conditionMap ["rule" ]; ok {
443
+ conditionInfo .Rule = helper .IntUint64 (v .(int ))
444
+ }
445
+
446
+ if v , ok := conditionMap ["condition_value" ]; ok {
447
+ conditionInfo .ConditionValue = helper .String (v .(string ))
448
+ }
449
+
450
+ anonymousInfo .Conditions = append (anonymousInfo .Conditions , & conditionInfo )
451
+ }
452
+ }
453
+
454
+ topicExtendInfo .AnonymousAccess = & anonymousInfo
455
+ }
456
+
457
+ request .Extends = & topicExtendInfo
458
+ }
459
+ }
460
+
370
461
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
371
462
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClsClient ().ModifyTopic (request )
372
463
if e != nil {
0 commit comments