Skip to content

Commit 4325051

Browse files
committed
feat/iacExtInfo2
1 parent 3306bf5 commit 4325051

17 files changed

+200
-57
lines changed

tencentcloud/connectivity/client.go

Lines changed: 96 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,20 @@ func (me *TencentCloudClient) UseTencentCosClient(bucket string) *cos.Client {
295295
}
296296

297297
// UseMysqlClient returns mysql(cdb) client for service
298-
func (me *TencentCloudClient) UseMysqlClient() *cdb.Client {
298+
func (me *TencentCloudClient) UseMysqlClient(specArgs ...IacExtInfo) *cdb.Client {
299299
if me.mysqlConn != nil {
300300
return me.mysqlConn
301301
}
302302

303303
cpf := me.NewClientProfile(300)
304304
me.mysqlConn, _ = cdb.NewClient(me.Credential, me.Region, cpf)
305-
me.mysqlConn.WithHttpTransport(&LogRoundTripper{})
305+
if len(specArgs) != 0 {
306+
me.mysqlConn.WithHttpTransport(&LogRoundTripper{
307+
InstanceId: specArgs[0].InstanceId,
308+
})
309+
} else {
310+
me.mysqlConn.WithHttpTransport(&LogRoundTripper{})
311+
}
306312

307313
return me.mysqlConn
308314
}
@@ -495,15 +501,20 @@ func (me *TencentCloudClient) UseTdmqClient(specArgs ...IacExtInfo) *tdmq.Client
495501
}
496502

497503
// UseGaapClient returns gaap client for service
498-
func (me *TencentCloudClient) UseGaapClient() *gaap.Client {
504+
func (me *TencentCloudClient) UseGaapClient(specArgs ...IacExtInfo) *gaap.Client {
499505
if me.gaapConn != nil {
500506
return me.gaapConn
501507
}
502508

503509
cpf := me.NewClientProfile(300)
504510
me.gaapConn, _ = gaap.NewClient(me.Credential, me.Region, cpf)
505-
me.gaapConn.WithHttpTransport(&LogRoundTripper{})
506-
511+
if len(specArgs) != 0 {
512+
me.gaapConn.WithHttpTransport(&LogRoundTripper{
513+
InstanceId: specArgs[0].InstanceId,
514+
})
515+
} else {
516+
me.gaapConn.WithHttpTransport(&LogRoundTripper{})
517+
}
507518
return me.gaapConn
508519
}
509520

@@ -608,14 +619,20 @@ func (me *TencentCloudClient) UseDayuClient() *dayu.Client {
608619
}
609620

610621
// UseCdnClient returns cdn client for service
611-
func (me *TencentCloudClient) UseCdnClient() *cdn.Client {
622+
func (me *TencentCloudClient) UseCdnClient(specArgs ...IacExtInfo) *cdn.Client {
612623
if me.cdnConn != nil {
613624
return me.cdnConn
614625
}
615626

616627
cpf := me.NewClientProfile(300)
617628
me.cdnConn, _ = cdn.NewClient(me.Credential, me.Region, cpf)
618-
me.cdnConn.WithHttpTransport(&LogRoundTripper{})
629+
if len(specArgs) != 0 {
630+
me.cdnConn.WithHttpTransport(&LogRoundTripper{
631+
InstanceId: specArgs[0].InstanceId,
632+
})
633+
} else {
634+
me.cdnConn.WithHttpTransport(&LogRoundTripper{})
635+
}
619636

620637
return me.cdnConn
621638
}
@@ -634,15 +651,21 @@ func (me *TencentCloudClient) UseMonitorClient() *monitor.Client {
634651
}
635652

636653
// UseEsClient returns es client for service
637-
func (me *TencentCloudClient) UseEsClient() *es.Client {
654+
func (me *TencentCloudClient) UseEsClient(specArgs ...IacExtInfo) *es.Client {
638655
if me.esConn != nil {
639656
return me.esConn
640657
}
641658

642659
cpf := me.NewClientProfile(300)
643660
cpf.Language = "zh-CN"
644661
me.esConn, _ = es.NewClient(me.Credential, me.Region, cpf)
645-
me.esConn.WithHttpTransport(&LogRoundTripper{})
662+
if len(specArgs) != 0 {
663+
me.esConn.WithHttpTransport(&LogRoundTripper{
664+
InstanceId: specArgs[0].InstanceId,
665+
})
666+
} else {
667+
me.esConn.WithHttpTransport(&LogRoundTripper{})
668+
}
646669

647670
return me.esConn
648671
}
@@ -839,25 +862,37 @@ func (me *TencentCloudClient) UseEmrClient() *emr.Client {
839862
}
840863

841864
// UseClsClient return CLS client for service
842-
func (me *TencentCloudClient) UseClsClient() *cls.Client {
865+
func (me *TencentCloudClient) UseClsClient(specArgs ...IacExtInfo) *cls.Client {
843866
if me.clsConn != nil {
844867
return me.clsConn
845868
}
846869
cpf := me.NewClientProfile(300)
847870
me.clsConn, _ = cls.NewClient(me.Credential, me.Region, cpf)
848-
me.clsConn.WithHttpTransport(&LogRoundTripper{})
871+
if len(specArgs) != 0 {
872+
me.clsConn.WithHttpTransport(&LogRoundTripper{
873+
InstanceId: specArgs[0].InstanceId,
874+
})
875+
} else {
876+
me.clsConn.WithHttpTransport(&LogRoundTripper{})
877+
}
849878

850879
return me.clsConn
851880
}
852881

853882
// UseLighthouseClient return Lighthouse client for service
854-
func (me *TencentCloudClient) UseLighthouseClient() *lighthouse.Client {
883+
func (me *TencentCloudClient) UseLighthouseClient(specArgs ...IacExtInfo) *lighthouse.Client {
855884
if me.lighthouseConn != nil {
856885
return me.lighthouseConn
857886
}
858887
cpf := me.NewClientProfile(300)
859888
me.lighthouseConn, _ = lighthouse.NewClient(me.Credential, me.Region, cpf)
860-
me.lighthouseConn.WithHttpTransport(&LogRoundTripper{})
889+
if len(specArgs) != 0 {
890+
me.lighthouseConn.WithHttpTransport(&LogRoundTripper{
891+
InstanceId: specArgs[0].InstanceId,
892+
})
893+
} else {
894+
me.lighthouseConn.WithHttpTransport(&LogRoundTripper{})
895+
}
861896

862897
return me.lighthouseConn
863898
}
@@ -875,13 +910,19 @@ func (me *TencentCloudClient) UseDnsPodClient() *dnspod.Client {
875910
}
876911

877912
// UsePrivateDnsClient return PrivateDns client for service
878-
func (me *TencentCloudClient) UsePrivateDnsClient() *privatedns.Client {
913+
func (me *TencentCloudClient) UsePrivateDnsClient(specArgs ...IacExtInfo) *privatedns.Client {
879914
if me.privateDnsConn != nil {
880915
return me.privateDnsConn
881916
}
882917
cpf := me.NewClientProfile(300)
883918
me.privateDnsConn, _ = privatedns.NewClient(me.Credential, me.Region, cpf)
884-
me.privateDnsConn.WithHttpTransport(&LogRoundTripper{})
919+
if len(specArgs) != 0 {
920+
me.privateDnsConn.WithHttpTransport(&LogRoundTripper{
921+
InstanceId: specArgs[0].InstanceId,
922+
})
923+
} else {
924+
me.privateDnsConn.WithHttpTransport(&LogRoundTripper{})
925+
}
885926

886927
return me.privateDnsConn
887928
}
@@ -925,14 +966,20 @@ func (me *TencentCloudClient) UseTemClient() *tem.Client {
925966
}
926967

927968
// UseTeoClient returns teo client for service
928-
func (me *TencentCloudClient) UseTeoClient() *teo.Client {
969+
func (me *TencentCloudClient) UseTeoClient(specArgs ...IacExtInfo) *teo.Client {
929970
if me.teoConn != nil {
930971
return me.teoConn
931972
}
932973

933974
cpf := me.NewClientProfile(300)
934975
me.teoConn, _ = teo.NewClient(me.Credential, me.Region, cpf)
935-
me.teoConn.WithHttpTransport(&LogRoundTripper{})
976+
if len(specArgs) != 0 {
977+
me.teoConn.WithHttpTransport(&LogRoundTripper{
978+
InstanceId: specArgs[0].InstanceId,
979+
})
980+
} else {
981+
me.teoConn.WithHttpTransport(&LogRoundTripper{})
982+
}
936983

937984
return me.teoConn
938985
}
@@ -1016,14 +1063,20 @@ func (me *TencentCloudClient) UseCatClient() *cat.Client {
10161063
}
10171064

10181065
// UseMariadbClient returns mariadb client for service
1019-
func (me *TencentCloudClient) UseMariadbClient() *mariadb.Client {
1066+
func (me *TencentCloudClient) UseMariadbClient(specArgs ...IacExtInfo) *mariadb.Client {
10201067
if me.mariadbConn != nil {
10211068
return me.mariadbConn
10221069
}
10231070

10241071
cpf := me.NewClientProfile(300)
10251072
me.mariadbConn, _ = mariadb.NewClient(me.Credential, me.Region, cpf)
1026-
me.mariadbConn.WithHttpTransport(&LogRoundTripper{})
1073+
if len(specArgs) != 0 {
1074+
me.mariadbConn.WithHttpTransport(&LogRoundTripper{
1075+
InstanceId: specArgs[0].InstanceId,
1076+
})
1077+
} else {
1078+
me.mariadbConn.WithHttpTransport(&LogRoundTripper{})
1079+
}
10271080

10281081
return me.mariadbConn
10291082
}
@@ -1068,15 +1121,20 @@ func (me *TencentCloudClient) UseOrganizationClient() *organization.Client {
10681121
}
10691122

10701123
// UseTdcpgClient returns tdcpg client for service
1071-
func (me *TencentCloudClient) UseTdcpgClient() *tdcpg.Client {
1124+
func (me *TencentCloudClient) UseTdcpgClient(specArgs ...IacExtInfo) *tdcpg.Client {
10721125
if me.tdcpgConn != nil {
10731126
return me.tdcpgConn
10741127
}
10751128

10761129
cpf := me.NewClientProfile(300)
10771130
me.tdcpgConn, _ = tdcpg.NewClient(me.Credential, me.Region, cpf)
1078-
me.tdcpgConn.WithHttpTransport(&LogRoundTripper{})
1079-
1131+
if len(specArgs) != 0 {
1132+
me.tdcpgConn.WithHttpTransport(&LogRoundTripper{
1133+
InstanceId: specArgs[0].InstanceId,
1134+
})
1135+
} else {
1136+
me.tdcpgConn.WithHttpTransport(&LogRoundTripper{})
1137+
}
10801138
return me.tdcpgConn
10811139
}
10821140

@@ -1365,28 +1423,40 @@ func (me *TencentCloudClient) UseWedataClient() *wedata.Client {
13651423
return me.wedataConn
13661424
}
13671425

1368-
func (me *TencentCloudClient) UseWafClient() *waf.Client {
1426+
func (me *TencentCloudClient) UseWafClient(specArgs ...IacExtInfo) *waf.Client {
13691427
if me.wafConn != nil {
13701428
return me.wafConn
13711429
}
13721430

13731431
cpf := me.NewClientProfile(300)
13741432
cpf.Language = "zh-CN"
13751433
me.wafConn, _ = waf.NewClient(me.Credential, me.Region, cpf)
1376-
me.wafConn.WithHttpTransport(&LogRoundTripper{})
1434+
if len(specArgs) != 0 {
1435+
me.wafConn.WithHttpTransport(&LogRoundTripper{
1436+
InstanceId: specArgs[0].InstanceId,
1437+
})
1438+
} else {
1439+
me.wafConn.WithHttpTransport(&LogRoundTripper{})
1440+
}
13771441

13781442
return me.wafConn
13791443
}
13801444

1381-
func (me *TencentCloudClient) UseCfwClient() *cfw.Client {
1445+
func (me *TencentCloudClient) UseCfwClient(specArgs ...IacExtInfo) *cfw.Client {
13821446
if me.cfwConn != nil {
13831447
return me.cfwConn
13841448
}
13851449

13861450
cpf := me.NewClientProfile(300)
13871451
cpf.Language = "zh-CN"
13881452
me.cfwConn, _ = cfw.NewClient(me.Credential, me.Region, cpf)
1389-
me.cfwConn.WithHttpTransport(&LogRoundTripper{})
1453+
if len(specArgs) != 0 {
1454+
me.cfwConn.WithHttpTransport(&LogRoundTripper{
1455+
InstanceId: specArgs[0].InstanceId,
1456+
})
1457+
} else {
1458+
me.cfwConn.WithHttpTransport(&LogRoundTripper{})
1459+
}
13901460

13911461
return me.cfwConn
13921462
}

tencentcloud/connectivity/transport.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ func (me *LogRoundTripper) RoundTrip(request *http.Request) (response *http.Resp
6161
}
6262

6363
request.Header.Set("X-TC-RequestClient", iacExtInfoStr)
64+
65+
fmt.Println(1111111111)
66+
fmt.Println(1111111111)
67+
fmt.Println(1111111111)
68+
fmt.Println(request.Header.Get("X-TC-RequestClient"))
69+
fmt.Println(1111111111)
70+
fmt.Println(1111111111)
71+
fmt.Println(1111111111)
72+
6473
inBytes = []byte(fmt.Sprintf("%s, request: ", request.Header[headName]))
6574
requestBody, errRet := ioutil.ReadAll(bodyReader)
6675
if errRet != nil {

tencentcloud/services/cdb/service_tencentcloud_mysql.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,9 @@ func (me *MysqlService) _innerDescribeDBInstanceById(ctx context.Context, mysqlI
810810
}
811811
}()
812812
ratelimit.Check(request.GetAction())
813-
response, err := me.client.UseMysqlClient().DescribeDBInstances(request)
813+
var specArgs connectivity.IacExtInfo
814+
specArgs.InstanceId = mysqlId
815+
response, err := me.client.UseMysqlClient(specArgs).DescribeDBInstances(request)
814816
if err != nil {
815817
errRet = err
816818
return

tencentcloud/services/cdn/service_tencentcloud_cdn.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func (me *CdnService) DescribeDomainsConfigByDomain(ctx context.Context, domain
4141
request.Filters = append(request.Filters, filter)
4242

4343
ratelimit.Check(request.GetAction())
44-
response, err := me.client.UseCdnClient().DescribeDomainsConfig(request)
44+
var specArgs connectivity.IacExtInfo
45+
specArgs.InstanceId = domain
46+
response, err := me.client.UseCdnClient(specArgs).DescribeDomainsConfig(request)
4547
if err != nil {
4648
if sdkErr, ok := err.(*errors.TencentCloudSDKError); ok {
4749
if sdkErr.Code == CDN_HOST_NOT_FOUND {

tencentcloud/services/cfw/service_tencentcloud_cfw.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ func (me *CfwService) DescribeCfwNatInstanceById(ctx context.Context, natinsId s
245245
}()
246246

247247
ratelimit.Check(request.GetAction())
248-
249-
response, err := me.client.UseCfwClient().DescribeNatFwInstancesInfo(request)
248+
var specArgs connectivity.IacExtInfo
249+
specArgs.InstanceId = natinsId
250+
response, err := me.client.UseCfwClient(specArgs).DescribeNatFwInstancesInfo(request)
250251
if err != nil {
251252
errRet = err
252253
return
@@ -442,8 +443,10 @@ func (me *CfwService) DescribeCfwVpcInstanceById(ctx context.Context, fwGroupId
442443
}()
443444

444445
ratelimit.Check(request.GetAction())
446+
var specArgs connectivity.IacExtInfo
447+
specArgs.InstanceId = fwGroupId
445448

446-
response, err := me.client.UseCfwClient().DescribeFwGroupInstanceInfo(request)
449+
response, err := me.client.UseCfwClient(specArgs).DescribeFwGroupInstanceInfo(request)
447450
if err != nil {
448451
errRet = err
449452
return

tencentcloud/services/cls/service_tencentcloud_cls.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ func (me *ClsService) DescribeClsLogset(ctx context.Context, logsetId string) (l
5353
request.Offset = &offset
5454
request.Limit = &pageSize
5555
ratelimit.Check(request.GetAction())
56-
response, err := me.client.UseClsClient().DescribeLogsets(request)
56+
var specArgs connectivity.IacExtInfo
57+
specArgs.InstanceId = logsetId
58+
response, err := me.client.UseClsClient(specArgs).DescribeLogsets(request)
5759
if err != nil {
5860
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
5961
logId, request.GetAction(), request.ToJsonString(), err.Error())
@@ -240,7 +242,9 @@ func (me *ClsService) DescribeClsTopicById(ctx context.Context, topicId string)
240242
request.Offset = &offset
241243
request.Limit = &pageSize
242244
ratelimit.Check(request.GetAction())
243-
response, err := me.client.UseClsClient().DescribeTopics(request)
245+
var specArgs connectivity.IacExtInfo
246+
specArgs.InstanceId = topicId
247+
response, err := me.client.UseClsClient(specArgs).DescribeTopics(request)
244248
if err != nil {
245249
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
246250
logId, request.GetAction(), request.ToJsonString(), err.Error())

tencentcloud/services/es/service_tencentcloud_elasticsearch.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ func (me *ElasticsearchService) DescribeInstanceById(ctx context.Context, instan
3030
request.InstanceIds = []*string{&instanceId}
3131

3232
ratelimit.Check(request.GetAction())
33-
response, err := me.client.UseEsClient().DescribeInstances(request)
33+
var specArgs connectivity.IacExtInfo
34+
specArgs.InstanceId = instanceId
35+
response, err := me.client.UseEsClient(specArgs).DescribeInstances(request)
3436
if err != nil {
3537
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
3638
logId, request.GetAction(), request.ToJsonString(), err.Error())

tencentcloud/services/gaap/service_tencentcloud_gaap.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ func (me *GaapService) DescribeProxies(
587587
logId := tccommon.GetLogId(ctx)
588588

589589
request := gaap.NewDescribeProxiesRequest()
590+
response := gaap.NewDescribeProxiesResponse()
590591
if len(ids) > 0 {
591592
request.ProxyIds = common.StringPtrs(ids)
592593
}
@@ -625,8 +626,15 @@ func (me *GaapService) DescribeProxies(
625626

626627
if err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
627628
ratelimit.Check(request.GetAction())
629+
if len(ids) > 0 {
630+
var specArgs connectivity.IacExtInfo
631+
tmpIds := strings.Join(ids, tccommon.FILED_SP)
632+
specArgs.InstanceId = tmpIds
633+
response, err = me.client.UseGaapClient(specArgs).DescribeProxies(request)
634+
} else {
635+
response, err = me.client.UseGaapClient().DescribeProxies(request)
636+
}
628637

629-
response, err := me.client.UseGaapClient().DescribeProxies(request)
630638
if err != nil {
631639
count = 0
632640

0 commit comments

Comments
 (0)