Skip to content

Commit

Permalink
Feat/support ccn query (#2507)
Browse files Browse the repository at this point in the history
* feat: query limit

* feat: query limit

* feat: query limit

* feat: test
  • Loading branch information
WeiMengXS authored Jan 29, 2024
1 parent b5b4f29 commit 57cf580
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .changelog/2507.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
resource/tencentcloud_ccn_attachment: support tke cluster addon modify
```

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ resource tencentcloud_ccn main {
name = "ci-temp-test-ccn"
description = "ci-temp-test-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
data tencentcloud_ccn_instances id_instances {
Expand Down
4 changes: 4 additions & 0 deletions tencentcloud/services/ccn/resource_tc_ccn_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ resource tencentcloud_ccn main {
name = "ci-temp-test-ccn"
description = "ci-temp-test-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
resource tencentcloud_ccn_attachment attachment {
Expand Down Expand Up @@ -155,6 +157,8 @@ resource tencentcloud_ccn vpngw_ccn_main {
name = "ci-temp-test-vpngw-ccn"
description = "ci-temp-test-vpngw-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
resource tencentcloud_ccn_attachment vpngw_ccn_attachment {
Expand Down
34 changes: 30 additions & 4 deletions tencentcloud/services/ccn/service_tencentcloud_ccn.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,37 @@ func (me *VpcService) DescribeCcnAttachedInstance(ctx context.Context, ccnId,
func (me *VpcService) DescribeCcnAttachedInstances(ctx context.Context, ccnId string) (infos []CcnAttachedInstanceInfo, errRet error) {

logId := tccommon.GetLogId(ctx)
request := vpc.NewDescribeCcnAttachedInstancesRequest()
var (
request = vpc.NewDescribeCcnAttachedInstancesRequest()
response = vpc.NewDescribeCcnAttachedInstancesResponse()
result []*vpc.CcnAttachedInstance
err error
limit uint64 = 20
offset uint64 = 0
)

request.CcnId = &ccnId

ratelimit.Check(request.GetAction())
response, err := me.client.UseVpcClient().DescribeCcnAttachedInstances(request)

for {
request.Limit = &limit
request.Offset = &offset
response, err = me.client.UseVpcClient().DescribeCcnAttachedInstances(request)
if err != nil {
errRet = err
return
}

if response == nil || len(response.Response.InstanceSet) < 1 {
break
}
result = append(result, response.Response.InstanceSet...)
if len(response.Response.InstanceSet) < int(limit) {
break
}
offset += limit
}
defer func() {
if errRet != nil {
responseStr := ""
Expand All @@ -420,9 +446,9 @@ func (me *VpcService) DescribeCcnAttachedInstances(ctx context.Context, ccnId st
request.ToJsonString(),
response.ToJsonString())

infos = make([]CcnAttachedInstanceInfo, 0, len(response.Response.InstanceSet))
infos = make([]CcnAttachedInstanceInfo, 0, len(result))

for _, item := range response.Response.InstanceSet {
for _, item := range result {

var info CcnAttachedInstanceInfo

Expand Down

0 comments on commit 57cf580

Please sign in to comment.