Skip to content

Commit d56d786

Browse files
tongyimingmikatong
andauthored
add gaap datasource (#2238)
* add gaap datasource * add changelog * update --------- Co-authored-by: mikatong <mikatong@tencent.com>
1 parent 6af2531 commit d56d786

File tree

34 files changed

+3296
-0
lines changed

34 files changed

+3296
-0
lines changed

.changelog/2238.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
```release-note:new-data-source
2+
tencentcloud_gaap_rule_real_servers
3+
```
4+
5+
```release-note:new-data-source
6+
tencentcloud_gaap_resources_by_tag
7+
```
8+
9+
```release-note:new-data-source
10+
tencentcloud_gaap_region_and_price
11+
```
12+
13+
```release-note:new-data-source
14+
tencentcloud_gaap_proxy_and_statistics_listeners
15+
```
16+
17+
```release-note:new-data-source
18+
tencentcloud_gaap_proxies_status
19+
```
20+
21+
```release-note:new-data-source
22+
tencentcloud_gaap_listener_statistics
23+
```
24+
25+
```release-note:new-data-source
26+
tencentcloud_gaap_listener_real_servers
27+
```
28+
29+
```release-note:new-data-source
30+
tencentcloud_gaap_group_and_statistics_proxy
31+
```
32+
33+
```release-note:new-data-source
34+
tencentcloud_gaap_domain_error_page_infos
35+
```
36+
37+
```release-note:new-data-source
38+
tencentcloud_gaap_check_proxy_create
39+
```
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
Use this data source to query detailed information of gaap check proxy create
3+
4+
Example Usage
5+
6+
```hcl
7+
data "tencentcloud_gaap_check_proxy_create" "check_proxy_create" {
8+
access_region = "Guangzhou"
9+
real_server_region = "Beijing"
10+
bandwidth = 10
11+
concurrent = 2
12+
ip_address_version = "IPv4"
13+
network_type = "normal"
14+
package_type = "Thunder"
15+
http3_supported = 0
16+
}
17+
```
18+
*/
19+
package tencentcloud
20+
21+
import (
22+
"context"
23+
24+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
25+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
26+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
27+
)
28+
29+
func dataSourceTencentCloudGaapCheckProxyCreate() *schema.Resource {
30+
return &schema.Resource{
31+
Read: dataSourceTencentCloudGaapCheckProxyCreateRead,
32+
Schema: map[string]*schema.Schema{
33+
"access_region": {
34+
Required: true,
35+
Type: schema.TypeString,
36+
Description: "The access (acceleration) area of the proxy. The value can be obtained through the interface DescribeAccessRegionsByDestRegion.",
37+
},
38+
39+
"real_server_region": {
40+
Required: true,
41+
Type: schema.TypeString,
42+
Description: "The origin area of the proxy. The value can be obtained through the interface DescribeDestRegions.",
43+
},
44+
45+
"bandwidth": {
46+
Required: true,
47+
Type: schema.TypeInt,
48+
Description: "The upper limit of proxy bandwidth, in Mbps.",
49+
},
50+
51+
"concurrent": {
52+
Required: true,
53+
Type: schema.TypeInt,
54+
Description: "The upper limit of chanproxynel concurrency, representing the number of simultaneous online connections, in tens of thousands.",
55+
},
56+
57+
"group_id": {
58+
Optional: true,
59+
Type: schema.TypeString,
60+
Description: "If creating a proxy under a proxy group, you need to fill in the ID of the proxy group.",
61+
},
62+
63+
"ip_address_version": {
64+
Optional: true,
65+
Type: schema.TypeString,
66+
Description: "IP version, can be taken as IPv4 or IPv6, with a default value of IPv4.",
67+
},
68+
69+
"network_type": {
70+
Optional: true,
71+
Type: schema.TypeString,
72+
Description: "Network type, can take values &amp;#39;normal&amp;#39;, &amp;#39;cn2&amp;#39;, default value normal.",
73+
},
74+
75+
"package_type": {
76+
Optional: true,
77+
Type: schema.TypeString,
78+
Description: "Channel package type. Thunder represents the standard proxy group, Accelerator represents the game accelerator proxy, and CrossBorder represents the cross-border proxy.",
79+
},
80+
81+
"check_flag": {
82+
Computed: true,
83+
Type: schema.TypeInt,
84+
Description: "Query whether the proxy with the given configuration can be created, 1 can be created, 0 cannot be created.",
85+
},
86+
87+
"result_output_file": {
88+
Type: schema.TypeString,
89+
Optional: true,
90+
Description: "Used to save results.",
91+
},
92+
},
93+
}
94+
}
95+
96+
func dataSourceTencentCloudGaapCheckProxyCreateRead(d *schema.ResourceData, meta interface{}) error {
97+
defer logElapsed("data_source.tencentcloud_gaap_check_proxy_create.read")()
98+
defer inconsistentCheck(d, meta)()
99+
100+
logId := getLogId(contextNil)
101+
102+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
103+
104+
paramMap := make(map[string]interface{})
105+
if v, ok := d.GetOk("access_region"); ok {
106+
paramMap["AccessRegion"] = helper.String(v.(string))
107+
}
108+
109+
if v, ok := d.GetOk("real_server_region"); ok {
110+
paramMap["RealServerRegion"] = helper.String(v.(string))
111+
}
112+
113+
if v, _ := d.GetOk("bandwidth"); v != nil {
114+
paramMap["Bandwidth"] = helper.IntUint64(v.(int))
115+
}
116+
117+
if v, _ := d.GetOk("concurrent"); v != nil {
118+
paramMap["Concurrent"] = helper.IntUint64(v.(int))
119+
}
120+
121+
if v, ok := d.GetOk("group_id"); ok {
122+
paramMap["GroupId"] = helper.String(v.(string))
123+
}
124+
125+
if v, ok := d.GetOk("ip_address_version"); ok {
126+
paramMap["IPAddressVersion"] = helper.String(v.(string))
127+
}
128+
129+
if v, ok := d.GetOk("network_type"); ok {
130+
paramMap["NetworkType"] = helper.String(v.(string))
131+
}
132+
133+
if v, ok := d.GetOk("package_type"); ok {
134+
paramMap["PackageType"] = helper.String(v.(string))
135+
}
136+
137+
service := GaapService{client: meta.(*TencentCloudClient).apiV3Conn}
138+
139+
var checkFlag *uint64
140+
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
141+
result, e := service.DescribeGaapCheckProxyCreate(ctx, paramMap)
142+
if e != nil {
143+
return retryError(e)
144+
}
145+
checkFlag = result
146+
return nil
147+
})
148+
if err != nil {
149+
return err
150+
}
151+
152+
result := map[string]interface{}{}
153+
154+
if checkFlag != nil {
155+
_ = d.Set("check_flag", *checkFlag)
156+
result["check_flag"] = *checkFlag
157+
}
158+
159+
d.SetId(helper.BuildToken())
160+
output, ok := d.GetOk("result_output_file")
161+
if ok && output.(string) != "" {
162+
if e := writeToFile(output.(string), result); e != nil {
163+
return e
164+
}
165+
}
166+
return nil
167+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package tencentcloud
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
)
8+
9+
func TestAccTencentCloudGaapCheckProxyCreateDataSource_basic(t *testing.T) {
10+
t.Parallel()
11+
resource.Test(t, resource.TestCase{
12+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
13+
Providers: testAccProviders,
14+
Steps: []resource.TestStep{
15+
{
16+
Config: testAccGaapCheckProxyCreateDataSource,
17+
Check: resource.ComposeTestCheckFunc(
18+
testAccCheckTencentCloudDataSourceID("data.tencentcloud_gaap_check_proxy_create.check_proxy_create"),
19+
resource.TestCheckResourceAttr("data.tencentcloud_gaap_check_proxy_create.check_proxy_create", "check_flag", "1"),
20+
),
21+
},
22+
},
23+
})
24+
}
25+
26+
const testAccGaapCheckProxyCreateDataSource = `
27+
data "tencentcloud_gaap_check_proxy_create" "check_proxy_create" {
28+
access_region = "Guangzhou"
29+
real_server_region = "Beijing"
30+
bandwidth = 10
31+
concurrent = 2
32+
ip_address_version = "IPv4"
33+
network_type = "normal"
34+
package_type = "Thunder"
35+
}
36+
`

0 commit comments

Comments
 (0)