Skip to content

Commit 527dd7c

Browse files
committed
add
1 parent 53503d3 commit 527dd7c

File tree

8 files changed

+302
-32
lines changed

8 files changed

+302
-32
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ require (
4545
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.748
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
48-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.950
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.950
48+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.961
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.961
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.860 h1:IU20AhN
862862
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.860/go.mod h1:RP3NkBvKio1dFmCNKozHX9qmef57sUCfsTcE0FnCvjk=
863863
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.950 h1:Kn+PdQVL2rolp8sy7PGNnocG37omPxDAUSPnVNmt+m4=
864864
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.950/go.mod h1:KH1QFeKGUpNF6pon3jyKM7PkqbLhJkJr1liAFPVjcjo=
865+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.961 h1:0Ni0khQ8HyCOtXMvJeJRifV70P41y6Jgq/wEnpPEXIo=
866+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.961/go.mod h1:5v895o1RfKDh2kXgyQRuVOp2uTKERPQAQOe9u1mdVbM=
865867
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.414/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
866868
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.486/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
867869
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.524/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
@@ -938,6 +940,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.932 h1:MB1+
938940
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.932/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
939941
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.950 h1:gsBG5scMDYykLzPSj9aXCTxVjWE5lt+y6VwNAROf7Fw=
940942
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.950/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
943+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.961 h1:UqinjIsO+Y48BQYSxrD6aHQe8SD+Wsbvj+jU9V9VvWM=
944+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.961/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
941945
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
942946
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY=
943947
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=

tencentcloud/services/cls/resource_tc_cls_topic.go

Lines changed: 107 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,23 @@ func ResourceTencentCloudClsTopic() *schema.Resource {
9191
"extends": {
9292
Type: schema.TypeList,
9393
Optional: true,
94+
Computed: true,
9495
MaxItems: 1,
9596
Description: "Log Subject Extension Information.",
9697
Elem: &schema.Resource{
9798
Schema: map[string]*schema.Schema{
9899
"anonymous_access": {
99-
Type: schema.TypeString,
100+
Type: schema.TypeList,
100101
Optional: true,
102+
MaxItems: 1,
101103
Description: "Log topic authentication free configuration information.",
102104
Elem: &schema.Resource{
103105
Schema: map[string]*schema.Schema{
104106
"operations": {
105107
Type: schema.TypeList,
106108
Optional: true,
107109
Description: "Operation list, supporting trackLog (JS/HTTP upload log) and realtimeProducer (kafka protocol upload log).",
110+
Elem: &schema.Schema{Type: schema.TypeString},
108111
},
109112
"conditions": {
110113
Type: schema.TypeList,
@@ -202,22 +205,23 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
202205
request.IsWebTracking = helper.Bool(v.(bool))
203206
}
204207

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 {
210211
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
214219
}
215220

216-
if v, ok := tmpMap["conditions"]; ok {
217-
conditionInfoList := make([]*cls.ConditionInfo, 0)
221+
if v, ok := anonymousAccessMap["conditions"]; ok {
218222
for _, condition := range v.([]interface{}) {
219-
conditionInfo := cls.ConditionInfo{}
220223
conditionMap := condition.(map[string]interface{})
224+
conditionInfo := cls.ConditionInfo{}
221225
if v, ok := conditionMap["attributes"]; ok {
222226
conditionInfo.Attributes = helper.String(v.(string))
223227
}
@@ -229,16 +233,15 @@ func resourceTencentCloudClsTopicCreate(d *schema.ResourceData, meta interface{}
229233
if v, ok := conditionMap["condition_value"]; ok {
230234
conditionInfo.ConditionValue = helper.String(v.(string))
231235
}
232-
}
233236

234-
anonymousInfo.Conditions = conditionInfoList
237+
anonymousInfo.Conditions = append(anonymousInfo.Conditions, &conditionInfo)
238+
}
235239
}
236240

237241
topicExtendInfo.AnonymousAccess = &anonymousInfo
238-
topicExtendInfoList = append(topicExtendInfoList, &topicExtendInfo)
239242
}
240243

241-
request.Extends = topicExtendInfoList[0]
244+
request.Extends = &topicExtendInfo
242245
}
243246

244247
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
@@ -308,6 +311,47 @@ func resourceTencentCloudClsTopicRead(d *schema.ResourceData, meta interface{})
308311
_ = d.Set("describes", topic.Describes)
309312
_ = d.Set("is_web_tracking", topic.IsWebTracking)
310313

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+
311355
return nil
312356
}
313357

@@ -367,6 +411,53 @@ func resourceTencentCloudClsTopicUpdate(d *schema.ResourceData, meta interface{}
367411
request.Describes = helper.String(d.Get("describes").(string))
368412
}
369413

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+
370461
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
371462
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClsClient().ModifyTopic(request)
372463
if e != nil {

tencentcloud/services/cls/resource_tc_cls_topic.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,39 @@ Provides a resource to create a cls topic.
22

33
Example Usage
44

5+
Create a standard cls topic
6+
7+
```hcl
8+
resource "tencentcloud_cls_logset" "example" {
9+
logset_name = "tf_example"
10+
tags = {
11+
tagKey = "tagValue"
12+
}
13+
}
14+
15+
resource "tencentcloud_cls_topic" "example" {
16+
topic_name = "tf_example"
17+
logset_id = tencentcloud_cls_logset.example.id
18+
auto_split = false
19+
max_split_partitions = 20
20+
partition_count = 1
21+
period = 30
22+
storage_type = "hot"
23+
describes = "Test Demo."
24+
hot_period = 10
25+
tags = {
26+
tagKey = "tagValue"
27+
}
28+
}
29+
```
30+
31+
Create a cls topic with web tracking
32+
533
```hcl
634
resource "tencentcloud_cls_logset" "example" {
735
logset_name = "tf_example"
8-
tags = {
9-
"demo" = "test"
36+
tags = {
37+
tagKey = "tagValue"
1038
}
1139
}
1240
@@ -20,8 +48,8 @@ resource "tencentcloud_cls_topic" "example" {
2048
storage_type = "hot"
2149
describes = "Test Demo."
2250
hot_period = 10
23-
tags = {
24-
"test" = "test",
51+
tags = {
52+
tagKey = "tagValue"
2553
}
2654
}
2755
```

0 commit comments

Comments
 (0)