Skip to content

fix(dcg): [136863499] tencentcloud_dc_gateway_ccn_routes add new params #3178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3178.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_dc_gateway_ccn_routes: add new params
```
28 changes: 26 additions & 2 deletions tencentcloud/services/dcg/data_source_tc_dc_gateway_ccn_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ func DataSourceTencentCloudDcGatewayCCNRoutes() *schema.Resource {
Required: true,
Description: "ID of the DCG to be queried.",
},
"ccn_route_type": {
Type: schema.TypeString,
Optional: true,
Description: "Cloud networking routing learning type, optional values: BGP - Automatic Learning; STATIC - User configured. Default is STATIC.",
},
"address_type": {
Type: schema.TypeString,
Optional: true,
Description: "Address type, supports: IPv4, IPv6. Default is IPv4.",
},
"result_output_file": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -69,10 +79,24 @@ func dataSourceTencentCloudDcGatewayCCNRoutesRead(d *schema.ResourceData, meta i
service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}

var (
id = d.Get("dcg_id").(string)
id string
ccnRouteType string
addressType string
)

var infos, err = service.DescribeDirectConnectGatewayCcnRoutes(ctx, id)
if v, ok := d.GetOk("dcg_id"); ok {
id = v.(string)
}

if v, ok := d.GetOk("ccn_route_type"); ok {
ccnRouteType = v.(string)
}

if v, ok := d.GetOk("address_type"); ok {
addressType = v.(string)
}

var infos, err = service.DescribeDirectConnectGatewayCcnRoutes(ctx, id, ccnRouteType, addressType)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Use this data source to query detailed information of direct connect gateway rou

Example Usage

Complete example

```hcl
resource "tencentcloud_ccn" "main" {
name = "ci-temp-test-ccn"
Expand All @@ -26,8 +28,18 @@ resource "tencentcloud_dc_gateway_ccn_route" "route2" {
cidr_block = "192.1.1.0/32"
}

#You need to sleep for a few seconds because there is a cache on the server
# You need to sleep for a few seconds because there is a cache on the server
data "tencentcloud_dc_gateway_ccn_routes" "test" {
dcg_id = tencentcloud_dc_gateway.ccn_main.id
}
```

Query routes by filters

```hcl
data "tencentcloud_dc_gateway_ccn_routes" "test" {
dcg_id = tencentcloud_dc_gateway.ccn_main.id
ccn_route_type = "STATIC"
address_type = "IPv4"
}
```
13 changes: 10 additions & 3 deletions tencentcloud/services/dcg/service_tencentcloud_dcg.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ getMoreData:

func (me *VpcService) GetCcnRouteId(ctx context.Context, dcgId, cidr string, asPaths []string) (routeId string, has int, errRet error) {

infos, err := me.DescribeDirectConnectGatewayCcnRoutes(ctx, dcgId)
infos, err := me.DescribeDirectConnectGatewayCcnRoutes(ctx, dcgId, "", "")
if err != nil {
errRet = err
return
Expand All @@ -208,7 +208,7 @@ func (me *VpcService) GetCcnRouteId(ctx context.Context, dcgId, cidr string, asP

func (me *VpcService) DescribeDirectConnectGatewayCcnRoute(ctx context.Context, dcgId, routeId string) (infoRet DcgRouteInfo, has int, errRet error) {

infos, err := me.DescribeDirectConnectGatewayCcnRoutes(ctx, dcgId)
infos, err := me.DescribeDirectConnectGatewayCcnRoutes(ctx, dcgId, "", "")
if err != nil {
errRet = err
return
Expand All @@ -232,7 +232,7 @@ func (me *VpcService) DescribeDirectConnectGatewayCcnRoute(ctx context.Context,

}

func (me *VpcService) DescribeDirectConnectGatewayCcnRoutes(ctx context.Context, dcgId string) (infos []DcgRouteInfo, errRet error) {
func (me *VpcService) DescribeDirectConnectGatewayCcnRoutes(ctx context.Context, dcgId, ccnRouteType, addressType string) (infos []DcgRouteInfo, errRet error) {
logId := tccommon.GetLogId(ctx)
request := vpc.NewDescribeDirectConnectGatewayCcnRoutesRequest()

Expand All @@ -246,6 +246,13 @@ func (me *VpcService) DescribeDirectConnectGatewayCcnRoutes(ctx context.Context,
}()

request.DirectConnectGatewayId = &dcgId
if ccnRouteType != "" {
request.CcnRouteType = &ccnRouteType
}

if addressType != "" {
request.AddressType = &addressType
}

infos = make([]DcgRouteInfo, 0, 100)
var offset uint64 = 0
Expand Down
16 changes: 15 additions & 1 deletion website/docs/d/dc_gateway_ccn_routes.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Use this data source to query detailed information of direct connect gateway rou

## Example Usage

### Complete example

```hcl
resource "tencentcloud_ccn" "main" {
name = "ci-temp-test-ccn"
Expand All @@ -37,17 +39,29 @@ resource "tencentcloud_dc_gateway_ccn_route" "route2" {
cidr_block = "192.1.1.0/32"
}

#You need to sleep for a few seconds because there is a cache on the server
# You need to sleep for a few seconds because there is a cache on the server
data "tencentcloud_dc_gateway_ccn_routes" "test" {
dcg_id = tencentcloud_dc_gateway.ccn_main.id
}
```

### Query routes by filters

```hcl
data "tencentcloud_dc_gateway_ccn_routes" "test" {
dcg_id = tencentcloud_dc_gateway.ccn_main.id
ccn_route_type = "STATIC"
address_type = "IPv4"
}
```

## Argument Reference

The following arguments are supported:

* `dcg_id` - (Required, String) ID of the DCG to be queried.
* `address_type` - (Optional, String) Address type, supports: IPv4, IPv6. Default is IPv4.
* `ccn_route_type` - (Optional, String) Cloud networking routing learning type, optional values: BGP - Automatic Learning; STATIC - User configured. Default is STATIC.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference
Expand Down
Loading