Skip to content

Commit ab13014

Browse files
authored
fix(dcg): [136863499] tencentcloud_dc_gateway_ccn_routes add new params (#3178)
* add * add
1 parent 3d8a243 commit ab13014

File tree

5 files changed

+67
-7
lines changed

5 files changed

+67
-7
lines changed

.changelog/3178.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_dc_gateway_ccn_routes: add new params
3+
```

tencentcloud/services/dcg/data_source_tc_dc_gateway_ccn_routes.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ func DataSourceTencentCloudDcGatewayCCNRoutes() *schema.Resource {
1818
Required: true,
1919
Description: "ID of the DCG to be queried.",
2020
},
21+
"ccn_route_type": {
22+
Type: schema.TypeString,
23+
Optional: true,
24+
Description: "Cloud networking routing learning type, optional values: BGP - Automatic Learning; STATIC - User configured. Default is STATIC.",
25+
},
26+
"address_type": {
27+
Type: schema.TypeString,
28+
Optional: true,
29+
Description: "Address type, supports: IPv4, IPv6. Default is IPv4.",
30+
},
2131
"result_output_file": {
2232
Type: schema.TypeString,
2333
Optional: true,
@@ -69,10 +79,24 @@ func dataSourceTencentCloudDcGatewayCCNRoutesRead(d *schema.ResourceData, meta i
6979
service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
7080

7181
var (
72-
id = d.Get("dcg_id").(string)
82+
id string
83+
ccnRouteType string
84+
addressType string
7385
)
7486

75-
var infos, err = service.DescribeDirectConnectGatewayCcnRoutes(ctx, id)
87+
if v, ok := d.GetOk("dcg_id"); ok {
88+
id = v.(string)
89+
}
90+
91+
if v, ok := d.GetOk("ccn_route_type"); ok {
92+
ccnRouteType = v.(string)
93+
}
94+
95+
if v, ok := d.GetOk("address_type"); ok {
96+
addressType = v.(string)
97+
}
98+
99+
var infos, err = service.DescribeDirectConnectGatewayCcnRoutes(ctx, id, ccnRouteType, addressType)
76100
if err != nil {
77101
return err
78102
}

tencentcloud/services/dcg/data_source_tc_dc_gateway_ccn_routes.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Use this data source to query detailed information of direct connect gateway rou
22

33
Example Usage
44

5+
Complete example
6+
57
```hcl
68
resource "tencentcloud_ccn" "main" {
79
name = "ci-temp-test-ccn"
@@ -26,8 +28,18 @@ resource "tencentcloud_dc_gateway_ccn_route" "route2" {
2628
cidr_block = "192.1.1.0/32"
2729
}
2830
29-
#You need to sleep for a few seconds because there is a cache on the server
31+
# You need to sleep for a few seconds because there is a cache on the server
3032
data "tencentcloud_dc_gateway_ccn_routes" "test" {
3133
dcg_id = tencentcloud_dc_gateway.ccn_main.id
3234
}
35+
```
36+
37+
Query routes by filters
38+
39+
```hcl
40+
data "tencentcloud_dc_gateway_ccn_routes" "test" {
41+
dcg_id = tencentcloud_dc_gateway.ccn_main.id
42+
ccn_route_type = "STATIC"
43+
address_type = "IPv4"
44+
}
3345
```

tencentcloud/services/dcg/service_tencentcloud_dcg.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ getMoreData:
182182

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

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

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

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

233233
}
234234

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

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

248248
request.DirectConnectGatewayId = &dcgId
249+
if ccnRouteType != "" {
250+
request.CcnRouteType = &ccnRouteType
251+
}
252+
253+
if addressType != "" {
254+
request.AddressType = &addressType
255+
}
249256

250257
infos = make([]DcgRouteInfo, 0, 100)
251258
var offset uint64 = 0

website/docs/d/dc_gateway_ccn_routes.html.markdown

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Use this data source to query detailed information of direct connect gateway rou
1313

1414
## Example Usage
1515

16+
### Complete example
17+
1618
```hcl
1719
resource "tencentcloud_ccn" "main" {
1820
name = "ci-temp-test-ccn"
@@ -37,17 +39,29 @@ resource "tencentcloud_dc_gateway_ccn_route" "route2" {
3739
cidr_block = "192.1.1.0/32"
3840
}
3941
40-
#You need to sleep for a few seconds because there is a cache on the server
42+
# You need to sleep for a few seconds because there is a cache on the server
4143
data "tencentcloud_dc_gateway_ccn_routes" "test" {
4244
dcg_id = tencentcloud_dc_gateway.ccn_main.id
4345
}
4446
```
4547

48+
### Query routes by filters
49+
50+
```hcl
51+
data "tencentcloud_dc_gateway_ccn_routes" "test" {
52+
dcg_id = tencentcloud_dc_gateway.ccn_main.id
53+
ccn_route_type = "STATIC"
54+
address_type = "IPv4"
55+
}
56+
```
57+
4658
## Argument Reference
4759

4860
The following arguments are supported:
4961

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

5367
## Attributes Reference

0 commit comments

Comments
 (0)