Skip to content

Commit d75a297

Browse files
tongyimingmikatong
andauthored
Feat/gaap proxy net type (#1783)
* gaap proxy support param network_type * update gaap proxy doc * update unit test * update * add changelog * update --------- Co-authored-by: mikatong <mikatong@tencent.com>
1 parent 825122c commit d75a297

File tree

7 files changed

+34
-3
lines changed

7 files changed

+34
-3
lines changed

.changelog/1783.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_gaap_proxy: support param network_type
3+
```

tencentcloud/extension_gaap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const (
3535

3636
GAAP_SERVER_NAME_INDICATION_SWITCH_ON = "ON"
3737
GAAP_SERVER_NAME_INDICATION_SWITCH_OFF = "OFF"
38+
39+
NETWORK_TYPE_NORMAL = "normal"
40+
NETWORK_TYPE_CN2 = "cn2"
41+
NETWORK_TYPE_TRIPLE = "triple"
3842
)
3943

4044
var (
@@ -53,4 +57,6 @@ var (
5357
3: "REALSERVER",
5458
4: "PROXY",
5559
}
60+
61+
PROXY_NETWORK_TYPE = []string{NETWORK_TYPE_NORMAL, NETWORK_TYPE_CN2, NETWORK_TYPE_TRIPLE}
5662
)

tencentcloud/resource_tc_gaap_domain_error_page_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func TestAccTencentCloudGaapDomainErrorPage_full(t *testing.T) {
154154
resource.TestCheckTypeSetElemAttr("tencentcloud_gaap_domain_error_page.foo", "error_codes.*", "406"),
155155
resource.TestCheckTypeSetElemAttr("tencentcloud_gaap_domain_error_page.foo", "error_codes.*", "504"),
156156
resource.TestCheckResourceAttr("tencentcloud_gaap_domain_error_page.foo", "body", "bad request"),
157-
resource.TestCheckResourceAttr("tencentcloud_gaap_domain_error_page.foo", "clear_headers.*", "Content-Length"),
158-
resource.TestCheckResourceAttr("tencentcloud_gaap_domain_error_page.foo", "clear_headers.*", "X-TEST"),
157+
resource.TestCheckTypeSetElemAttr("tencentcloud_gaap_domain_error_page.foo", "clear_headers.*", "Content-Length"),
158+
resource.TestCheckTypeSetElemAttr("tencentcloud_gaap_domain_error_page.foo", "clear_headers.*", "X-TEST"),
159159
resource.TestCheckResourceAttr("tencentcloud_gaap_domain_error_page.foo", "set_headers.X-TEST", "test"),
160160
),
161161
},

tencentcloud/resource_tc_gaap_proxy.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ func resourceTencentCloudGaapProxy() *schema.Resource {
9898
Optional: true,
9999
Description: "Tags of the GAAP proxy. Tags that do not exist are not created automatically.",
100100
},
101+
"network_type": {
102+
Type: schema.TypeString,
103+
Optional: true,
104+
Computed: true,
105+
ForceNew: true,
106+
ValidateFunc: validateAllowedStringValue(PROXY_NETWORK_TYPE),
107+
Description: "Network type. `normal`: regular BGP, `cn2`: boutique BGP, `triple`: triple play.",
108+
},
101109

102110
// computed
103111
"create_time": {
@@ -148,6 +156,7 @@ func resourceTencentCloudGaapProxyCreate(d *schema.ResourceData, m interface{})
148156
logId := getLogId(contextNil)
149157
ctx := context.WithValue(context.TODO(), logIdKey, logId)
150158

159+
params := make(map[string]interface{})
151160
name := d.Get("name").(string)
152161
projectId := d.Get("project_id").(int)
153162
bandwidth := d.Get("bandwidth").(int)
@@ -157,9 +166,13 @@ func resourceTencentCloudGaapProxyCreate(d *schema.ResourceData, m interface{})
157166
enable := d.Get("enable").(bool)
158167
tags := helper.GetTags(d, "tags")
159168

169+
if v, ok := d.GetOk("network_type"); ok {
170+
params["network_type"] = v.(string)
171+
}
172+
160173
service := GaapService{client: m.(*TencentCloudClient).apiV3Conn}
161174

162-
id, err := service.CreateProxy(ctx, name, accessRegion, realserverRegion, bandwidth, concurrent, projectId, tags)
175+
id, err := service.CreateProxy(ctx, name, accessRegion, realserverRegion, bandwidth, concurrent, projectId, tags, params)
163176
if err != nil {
164177
return err
165178
}
@@ -285,6 +298,9 @@ func resourceTencentCloudGaapProxyRead(d *schema.ResourceData, m interface{}) er
285298
}
286299
_ = d.Set("forward_ip", proxy.ForwardIP)
287300

301+
if proxy.NetworkType != nil {
302+
_ = d.Set("network_type", proxy.NetworkType)
303+
}
288304
return nil
289305
}
290306

tencentcloud/resource_tc_gaap_proxy_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ resource tencentcloud_gaap_proxy "foo" {
182182
concurrent = 2
183183
access_region = "Guangzhou"
184184
realserver_region = "Beijing"
185+
network_type = "normal"
185186
}
186187
`
187188

tencentcloud/service_tencentcloud_gaap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ func (me *GaapService) CreateProxy(
313313
name, accessRegion, realserverRegion string,
314314
bandwidth, concurrent, projectId int,
315315
tags map[string]string,
316+
params map[string]interface{},
316317
) (id string, err error) {
317318
logId := getLogId(ctx)
318319
client := me.client.UseGaapClient()
@@ -330,6 +331,9 @@ func (me *GaapService) CreateProxy(
330331
TagValue: helper.String(v),
331332
})
332333
}
334+
if v, ok := params["network_type"]; ok {
335+
createRequest.NetworkType = helper.String(v.(string))
336+
}
333337

334338
if err := resource.Retry(2*writeRetryTimeout, func() *resource.RetryError {
335339
ratelimit.Check(createRequest.GetAction())

website/docs/r/gaap_proxy.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following arguments are supported:
3737
* `name` - (Required, String) Name of the GAAP proxy, the maximum length is 30.
3838
* `realserver_region` - (Required, String, ForceNew) Region of the GAAP realserver. Valid value: `NorthChina`, `EastChina`, `SouthChina`, `SouthwestChina`, `Hongkong`, `SL_TAIWAN`, `SoutheastAsia`, `Korea`, `SL_India`, `SL_Australia`, `Europe`, `SL_UK`, `SL_SouthAmerica`, `NorthAmerica`, `SL_MiddleUSA`, `Canada`, `SL_VIET`, `WestIndia`, `Thailand`, `Virginia`, `Russia`, `Japan` and `SL_Indonesia`.
3939
* `enable` - (Optional, Bool) Indicates whether GAAP proxy is enabled, default value is `true`.
40+
* `network_type` - (Optional, String, ForceNew) Network type. `normal`: regular BGP, `cn2`: boutique BGP, `triple`: triple play.
4041
* `project_id` - (Optional, Int) ID of the project within the GAAP proxy, `0` means is default project.
4142
* `tags` - (Optional, Map) Tags of the GAAP proxy. Tags that do not exist are not created automatically.
4243

0 commit comments

Comments
 (0)