Skip to content

fix(gaap): [119537895] update gaap #2927

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
Nov 1, 2024
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
23 changes: 23 additions & 0 deletions .changelog/2927.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```release-note:enhancement
resource/tencentcloud_gaap_http_domain: add params `group_id` and `is_default_server`
```

```release-note:enhancement
resource/tencentcloud_gaap_layer7_listener: add params `group_id`, `tls_support_versions` and `tls_ciphers`
```

```release-note:enhancement
datasource/tencentcloud_gaap_http_domains: add param `is_default_server`
```

```release-note:enhancement
datasource/tencentcloud_gaap_layer7_listeners: add params `group_id`, `tls_support_versions` and `tls_ciphers`
```

```release-note:enhancement
datasource/tencentcloud_gaap_proxy_detail: add param `is_support_tls_choice`
```

```release-note:enhancement
datasource/tencentcloud_gaap_proxy_statistics: update `metric_names`
```
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ func DataSourceTencentCloudGaapHttpDomains() *schema.Resource {
Computed: true,
Description: "ID of the SSL certificate.",
},
"is_default_server": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether to use as the default domain name.",
},
},
},
},
Expand Down Expand Up @@ -191,6 +196,7 @@ func dataSourceTencentCloudGaapHttpDomainsRead(d *schema.ResourceData, m interfa
"realserver_certificate_id": realserverCertificateId,
"realserver_certificate_ids": realserverCertificateIds,
"realserver_certificate_domain": dr.RealServerCertificateDomain,
"is_default_server": dr.IsDefaultServer,
}

domains = append(domains, m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestAccDataSourceTencentCloudGaapHttpDomains_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) },
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Expand All @@ -28,6 +28,7 @@ func TestAccDataSourceTencentCloudGaapHttpDomains_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.tencentcloud_gaap_http_domains.foo", "domains.0.realserver_certificate_ids.#"),
resource.TestCheckResourceAttrSet("data.tencentcloud_gaap_http_domains.foo", "domains.0.basic_auth"),
resource.TestCheckResourceAttrSet("data.tencentcloud_gaap_http_domains.foo", "domains.0.gaap_auth"),
resource.TestCheckResourceAttrSet("data.tencentcloud_gaap_http_domains.foo", "domains.0.is_default_server"),
),
},
},
Expand Down
54 changes: 45 additions & 9 deletions tencentcloud/services/gaap/data_source_tc_gaap_layer7_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func DataSourceTencentCloudGaapLayer7Listeners() *schema.Resource {
Optional: true,
Description: "ID of the GAAP proxy to be queried.",
},
"group_id": {
Type: schema.TypeString,
Optional: true,
Description: "Group id.",
},
"listener_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -119,6 +124,18 @@ func DataSourceTencentCloudGaapLayer7Listeners() *schema.Resource {
Computed: true,
Description: "Creation time of the layer7 listener.",
},
"tls_support_versions": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Description: "TLS version, optional TLSv1, TLSv1.1, TLSv1.2, TLSv1.3.",
},
"tls_ciphers": {
Type: schema.TypeString,
Computed: true,
Description: "Password Suite, optional GAAP_TLS_CIPHERS_STRICT, GAAP_TLS_CIPHERS_GENERAL, GAAP_TLS_CIPHERS_WIDE(default).",
},
},
},
},
Expand All @@ -135,6 +152,7 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int

var (
proxyId *string
groupId *string
listenerId *string
name *string
port *int
Expand All @@ -145,12 +163,15 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int
if raw, ok := d.GetOk("proxy_id"); ok {
proxyId = helper.String(raw.(string))
}
if raw, ok := d.GetOk("group_id"); ok {
groupId = helper.String(raw.(string))
}
if raw, ok := d.GetOk("listener_id"); ok {
listenerId = helper.String(raw.(string))
}

if proxyId == nil && listenerId == nil {
return errors.New("proxy_id or listener_id must be set")
if proxyId == nil && groupId == nil && listenerId == nil {
return errors.New("One of proxy_id, group_id or listener_id must be set")
}

if raw, ok := d.GetOk("listener_name"); ok {
Expand All @@ -164,7 +185,7 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int

switch protocol {
case "HTTP":
httpListeners, err := service.DescribeHTTPListeners(ctx, proxyId, listenerId, name, port)
httpListeners, err := service.DescribeHTTPListeners(ctx, proxyId, groupId, listenerId, name, port)
if err != nil {
return err
}
Expand All @@ -190,20 +211,28 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int
}

ids = append(ids, *ls.ListenerId)

listeners = append(listeners, map[string]interface{}{
m := map[string]interface{}{
"protocol": "HTTP",
"id": *ls.ListenerId,
"proxy_id": *ls.ProxyId,
"name": *ls.ListenerName,
"port": *ls.Port,
"status": *ls.ListenerStatus,
"create_time": helper.FormatUnixTime(*ls.CreateTime),
})
}

if ls.ProxyId != nil {
m["proxy_id"] = *ls.ProxyId
}
if ls.GroupId != nil {
m["group_id"] = *ls.GroupId
}

listeners = append(listeners, m)

}

case "HTTPS":
httpsListeners, err := service.DescribeHTTPSListeners(ctx, proxyId, listenerId, name, port)
httpsListeners, err := service.DescribeHTTPSListeners(ctx, proxyId, groupId, listenerId, name, port)
if err != nil {
return err
}
Expand Down Expand Up @@ -255,7 +284,6 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int
"protocol": "HTTPS",
"id": ls.ListenerId,
"name": ls.ListenerName,
"proxy_id": ls.ProxyId,
"port": ls.Port,
"status": ls.ListenerStatus,
"certificate_id": ls.CertificateId,
Expand All @@ -264,6 +292,14 @@ func dataSourceTencentCloudGaapLayer7ListenersRead(d *schema.ResourceData, m int
"create_time": helper.FormatUnixTime(*ls.CreateTime),
"client_certificate_id": clientCertificateId,
"client_certificate_ids": polyClientCertificateIds,
"tls_ciphers": ls.TLSCiphers,
"tls_support_versions": helper.PStrings(ls.TLSSupportVersion),
}
if ls.ProxyId != nil {
m["proxy_id"] = *ls.ProxyId
}
if ls.GroupId != nil {
m["group_id"] = *ls.GroupId
}

listeners = append(listeners, m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func DataSourceTencentCloudGaapProxyDetail() *schema.Resource {
Computed: true,
Description: "Property bitmap, where each bit represents a property, where:0 indicates that the feature is not supported;1, indicates support for this feature.The meaning of the feature bitmap is as follows (from right to left):The first bit supports 4-layer acceleration;The second bit supports 7-layer acceleration;The third bit supports Http3 access;The fourth bit supports IPv6;The fifth bit supports high-quality BGP access;The 6th bit supports three network access;The 7th bit supports QoS acceleration in the access segment.Note: This field may return null, indicating that a valid value cannot be obtained.Note: This field may return null, indicating that a valid value cannot be obtained.",
},
"is_support_tls_choice": {
Type: schema.TypeInt,
Computed: true,
Description: "Whether to allow TLS configuration.0-no support, 1-expressed support.",
},
},
},
},
Expand Down Expand Up @@ -629,6 +634,9 @@ func dataSourceTencentCloudGaapProxyDetailRead(d *schema.ResourceData, meta inte
if proxyDetail.FeatureBitmap != nil {
proxyInfoMap["feature_bitmap"] = proxyDetail.FeatureBitmap
}
if proxyDetail.IsSupportTLSChoice != nil {
proxyInfoMap["is_support_tls_choice"] = proxyDetail.IsSupportTLSChoice
}

_ = d.Set("proxy_detail", []interface{}{proxyInfoMap})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func DataSourceTencentCloudGaapProxyStatistics() *schema.Resource {
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Metric Names. Valid values: InBandwidth,OutBandwidth, Concurrent, InPackets, OutPackets, PacketLoss, Latency, HttpQPS, HttpsQPS.",
Description: "Metric Names. Valid values: InBandwidth,OutBandwidth, Concurrent, InPackets, OutPackets, PacketLoss, Latency, HttpQPS, HttpsQPS, HttpQPSPercent, HttpsQPSPercent.",
},

"granularity": {
Expand Down
33 changes: 24 additions & 9 deletions tencentcloud/services/gaap/resource_tc_gaap_http_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ func ResourceTencentCloudGaapHttpDomain() *schema.Resource {
ForceNew: true,
Description: "ID of the layer7 listener.",
},
"group_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "Group Id.",
},
"is_default_server": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to use as the default domain name, the default is false.",
},
"domain": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -127,22 +139,23 @@ func resourceTencentCloudGaapHttpDomainCreate(d *schema.ResourceData, m interfac

listenerId := d.Get("listener_id").(string)
domain := d.Get("domain").(string)
isDefaultServer := d.Get("is_default_server").(bool)

service := GaapService{client: m.(tccommon.ProviderMeta).GetAPIV3Conn()}

var (
protocol string
forwardProtocol string
)
httpListeners, err := service.DescribeHTTPListeners(ctx, nil, &listenerId, nil, nil)
httpListeners, err := service.DescribeHTTPListeners(ctx, nil, nil, &listenerId, nil, nil)
if err != nil {
return err
}
if len(httpListeners) > 0 {
protocol = "HTTP"
}

httpsListeners, err := service.DescribeHTTPSListeners(ctx, nil, &listenerId, nil, nil)
httpsListeners, err := service.DescribeHTTPSListeners(ctx, nil, nil, &listenerId, nil, nil)
if err != nil {
return err
}
Expand All @@ -156,7 +169,7 @@ func resourceTencentCloudGaapHttpDomainCreate(d *schema.ResourceData, m interfac

switch protocol {
case "HTTP":
if err := service.CreateHTTPDomain(ctx, listenerId, domain); err != nil {
if err := service.CreateHTTPDomain(ctx, listenerId, domain, isDefaultServer); err != nil {
return err
}

Expand Down Expand Up @@ -244,7 +257,7 @@ func resourceTencentCloudGaapHttpDomainCreate(d *schema.ResourceData, m interfac
return errors.New("when use gaap auth, gaap auth id should be set")
}

if err := service.CreateHTTPSDomain(ctx, listenerId, domain, certificateId, polyClientCertificateIds); err != nil {
if err := service.CreateHTTPSDomain(ctx, listenerId, domain, certificateId, polyClientCertificateIds, isDefaultServer); err != nil {
return err
}

Expand Down Expand Up @@ -350,6 +363,7 @@ func resourceTencentCloudGaapHttpDomainRead(d *schema.ResourceData, m interface{
}
_ = d.Set("gaap_auth", *httpDomain.GaapAuth == 1)
_ = d.Set("gaap_auth_id", httpDomain.GaapCertificateId)
_ = d.Set("is_default_server", httpDomain.IsDefaultServer)

return nil
}
Expand All @@ -376,6 +390,7 @@ func resourceTencentCloudGaapHttpDomainUpdate(d *schema.ResourceData, m interfac
}

listenerId, protocol, domain = split[0], split[1], split[2]
isDefaultServer := d.Get("is_default_server").(bool)
service := GaapService{client: m.(tccommon.ProviderMeta).GetAPIV3Conn()}

switch protocol {
Expand All @@ -387,9 +402,9 @@ func resourceTencentCloudGaapHttpDomainUpdate(d *schema.ResourceData, m interfac
return fmt.Errorf("argument `%s` cannot be changed for http", v)
}
}
if d.HasChange("domain") {
if d.HasChange("domain") || d.HasChange("is_default_server") {
oldDomain, newDomain := d.GetChange("domain")
err := service.ModifyDomain(ctx, listenerId, oldDomain.(string), newDomain.(string))
err := service.ModifyDomain(ctx, listenerId, oldDomain.(string), newDomain.(string), isDefaultServer)
if err != nil {
return err
}
Expand All @@ -399,15 +414,15 @@ func resourceTencentCloudGaapHttpDomainUpdate(d *schema.ResourceData, m interfac
case "HTTPS":
}

if d.HasChange("domain") {
if d.HasChange("domain") || d.HasChange("is_default_server") {
oldDomain, newDomain := d.GetChange("domain")
err := service.ModifyDomain(ctx, listenerId, oldDomain.(string), newDomain.(string))
err := service.ModifyDomain(ctx, listenerId, oldDomain.(string), newDomain.(string), isDefaultServer)
if err != nil {
return err
}
}

listeners, err := service.DescribeHTTPSListeners(ctx, nil, &listenerId, nil, nil)
listeners, err := service.DescribeHTTPSListeners(ctx, nil, nil, &listenerId, nil, nil)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestAccTencentCloudGaapHttpDomainResource_basic(t *testing.T) {
resource.TestCheckResourceAttr("tencentcloud_gaap_http_domain.foo", "realserver_auth", "false"),
resource.TestCheckResourceAttr("tencentcloud_gaap_http_domain.foo", "basic_auth", "false"),
resource.TestCheckResourceAttr("tencentcloud_gaap_http_domain.foo", "gaap_auth", "false"),
resource.TestCheckResourceAttr("tencentcloud_gaap_http_domain.foo", "is_default_server", "false"),
),
},
{
Expand Down
Loading
Loading