@@ -82,6 +82,63 @@ func ResourceTencentCloudClsTopic() *schema.Resource {
82
82
Optional : true ,
83
83
Description : "Log Topic Description." ,
84
84
},
85
+ "is_web_tracking" : {
86
+ Type : schema .TypeBool ,
87
+ Optional : true ,
88
+ Computed : true ,
89
+ Description : "No authentication switch. False: closed; True: Enable. The default is false. After activation, anonymous access to the log topic will be supported for specified operations." ,
90
+ },
91
+ "extends" : {
92
+ Type : schema .TypeList ,
93
+ Optional : true ,
94
+ Computed : true ,
95
+ MaxItems : 1 ,
96
+ Description : "Log Subject Extension Information." ,
97
+ Elem : & schema.Resource {
98
+ Schema : map [string ]* schema.Schema {
99
+ "anonymous_access" : {
100
+ Type : schema .TypeList ,
101
+ Optional : true ,
102
+ MaxItems : 1 ,
103
+ Description : "Log topic authentication free configuration information." ,
104
+ Elem : & schema.Resource {
105
+ Schema : map [string ]* schema.Schema {
106
+ "operations" : {
107
+ Type : schema .TypeList ,
108
+ Optional : true ,
109
+ Description : "Operation list, supporting trackLog (JS/HTTP upload log) and realtimeProducer (kafka protocol upload log)." ,
110
+ Elem : & schema.Schema {Type : schema .TypeString },
111
+ },
112
+ "conditions" : {
113
+ Type : schema .TypeList ,
114
+ Optional : true ,
115
+ Description : "Operation list, supporting trackLog (JS/HTTP upload log) and realtimeProducer (kafka protocol upload log)." ,
116
+ Elem : & schema.Resource {
117
+ Schema : map [string ]* schema.Schema {
118
+ "attributes" : {
119
+ Type : schema .TypeString ,
120
+ Optional : true ,
121
+ Description : "Condition attribute, currently only VpcID is supported." ,
122
+ },
123
+ "rule" : {
124
+ Type : schema .TypeInt ,
125
+ Optional : true ,
126
+ Description : "Conditional rule, 1: equal, 2: not equal." ,
127
+ },
128
+ "condition_value" : {
129
+ Type : schema .TypeString ,
130
+ Optional : true ,
131
+ Description : "The value of the corresponding conditional attribute." ,
132
+ },
133
+ },
134
+ },
135
+ },
136
+ },
137
+ },
138
+ },
139
+ },
140
+ },
141
+ },
85
142
},
86
143
}
87
144
}
@@ -144,6 +201,49 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
144
201
request .Describes = helper .String ("" )
145
202
}
146
203
204
+ if v , ok := d .GetOkExists ("is_web_tracking" ); ok {
205
+ request .IsWebTracking = helper .Bool (v .(bool ))
206
+ }
207
+
208
+ if dMap , ok := helper .InterfacesHeadMap (d , "extends" ); ok {
209
+ topicExtendInfo := cls.TopicExtendInfo {}
210
+ if anonymousAccessMap , ok := helper .InterfaceToMap (dMap , "anonymous_access" ); ok {
211
+ anonymousInfo := cls.AnonymousInfo {}
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
219
+ }
220
+
221
+ if v , ok := anonymousAccessMap ["conditions" ]; ok {
222
+ for _ , condition := range v .([]interface {}) {
223
+ conditionMap := condition .(map [string ]interface {})
224
+ conditionInfo := cls.ConditionInfo {}
225
+ if v , ok := conditionMap ["attributes" ]; ok {
226
+ conditionInfo .Attributes = helper .String (v .(string ))
227
+ }
228
+
229
+ if v , ok := conditionMap ["rule" ]; ok {
230
+ conditionInfo .Rule = helper .IntUint64 (v .(int ))
231
+ }
232
+
233
+ if v , ok := conditionMap ["condition_value" ]; ok {
234
+ conditionInfo .ConditionValue = helper .String (v .(string ))
235
+ }
236
+
237
+ anonymousInfo .Conditions = append (anonymousInfo .Conditions , & conditionInfo )
238
+ }
239
+ }
240
+
241
+ topicExtendInfo .AnonymousAccess = & anonymousInfo
242
+ }
243
+
244
+ request .Extends = & topicExtendInfo
245
+ }
246
+
147
247
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
148
248
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClsClient ().CreateTopic (request )
149
249
if e != nil {
@@ -209,6 +309,48 @@ func resourceTencentCloudClsTopicRead(d *schema.ResourceData, meta interface{})
209
309
_ = d .Set ("period" , topic .Period )
210
310
_ = d .Set ("hot_period" , topic .HotPeriod )
211
311
_ = d .Set ("describes" , topic .Describes )
312
+ _ = d .Set ("is_web_tracking" , topic .IsWebTracking )
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
+ }
212
354
213
355
return nil
214
356
}
@@ -269,6 +411,53 @@ func resourceTencentCloudClsTopicUpdate(d *schema.ResourceData, meta interface{}
269
411
request .Describes = helper .String (d .Get ("describes" ).(string ))
270
412
}
271
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
+
272
461
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
273
462
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClsClient ().ModifyTopic (request )
274
463
if e != nil {
0 commit comments