diff --git a/.changelog/2763.txt b/.changelog/2763.txt new file mode 100644 index 0000000000..b471a6bf28 --- /dev/null +++ b/.changelog/2763.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +tencentcloud_vpc_private_nat_gateway +``` diff --git a/go.mod b/go.mod index 562c30c6e8..0a622b6dca 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.961 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.978 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.960 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692 @@ -96,7 +96,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.971 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.978 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 diff --git a/go.sum b/go.sum index 1c4514e560..92d68e89e2 100644 --- a/go.sum +++ b/go.sum @@ -970,6 +970,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.970 h1:IsF+ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.970/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971 h1:T5zEH1QM1XX+hJoAe4krnSjrnsTgHv1KfGC4Sos0Y4M= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.971/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.978 h1:3piderD6Cl4bt8mnSOROm+My1nHM5jtReECZeAn15oQ= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.978/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8= @@ -1118,6 +1120,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.964 h1:+HsB7iM github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.964/go.mod h1:ohfNiTUrMTR50FAUe4wALZVYa1404YQvYB57pvVVADM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.971 h1:eQsRAk1n6z4du93ebKe1XyQpTELY0YIJ4Y7jvMLdNNg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.971/go.mod h1:QpI0wEhuqhVI3jZbakGNzsJlt7YJdB8rqY9b/SI+NMM= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.978 h1:EZlxS90zY799+zYB7dmbMqU8XyWT0lesPTPkCtibC54= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.978/go.mod h1:+8DNFolL3rl8vlN1hiY8HhJG0SchGhzLbCN0K0TA0vU= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833 h1:avaBlZ+Qqv7bfMg/u0jlRsbEBbE18CfqKWbfGc84PLg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833/go.mod h1:fUWG217b//46Oa3VXxC5mgeYeewVAbF+lc81uET89EM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 h1:NLgKNOIHWa38AmW7dyfI9Jlcp2Kr9VRD94f48pPNmxM= diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index d0b8b12816..9e8e818c2e 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1134,6 +1134,7 @@ func Provider() *schema.Provider { "tencentcloud_nat_gateway": vpc.ResourceTencentCloudNatGateway(), "tencentcloud_nat_gateway_snat": vpc.ResourceTencentCloudNatGatewaySnat(), "tencentcloud_nat_refresh_nat_dc_route": vpc.ResourceTencentCloudNatRefreshNatDcRoute(), + "tencentcloud_vpc_private_nat_gateway": vpc.ResourceTencentCloudVpcPrivateNatGateway(), "tencentcloud_oceanus_job": oceanus.ResourceTencentCloudOceanusJob(), "tencentcloud_oceanus_job_config": oceanus.ResourceTencentCloudOceanusJobConfig(), "tencentcloud_oceanus_job_copy": oceanus.ResourceTencentCloudOceanusJobCopy(), diff --git a/tencentcloud/provider.md b/tencentcloud/provider.md index 9ac53a275a..88b33f0b08 100644 --- a/tencentcloud/provider.md +++ b/tencentcloud/provider.md @@ -1242,6 +1242,7 @@ Virtual Private Cloud(VPC) tencentcloud_protocol_template tencentcloud_protocol_template_group tencentcloud_route_table + tencentcloud_vpc_private_nat_gateway tencentcloud_route_table_association tencentcloud_route_entry tencentcloud_route_table_entry diff --git a/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.go b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.go new file mode 100644 index 0000000000..6fb2b5ffbf --- /dev/null +++ b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.go @@ -0,0 +1,278 @@ +package vpc + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312" + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudVpcPrivateNatGateway() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudVpcPrivateNatGatewayCreate, + Read: resourceTencentCloudVpcPrivateNatGatewayRead, + Update: resourceTencentCloudVpcPrivateNatGatewayUpdate, + Delete: resourceTencentCloudVpcPrivateNatGatewayDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "nat_gateway_name": { + Required: true, + Type: schema.TypeString, + Description: "Private network gateway name.", + }, + + "vpc_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Private Cloud instance ID. This parameter is required when creating a VPC type private network NAT gateway or a private network NAT gateway of private network gateway.", + }, + + "cross_domain": { + Optional: true, + Computed: true, + Type: schema.TypeBool, + Description: "Cross-domain parameters. Cross-domain binding of VPCs is supported only when the value is True.", + }, + + "vpc_type": { + Optional: true, + Computed: true, + Type: schema.TypeBool, + Description: "VPC type private network NAT gateway. Only when the value is True will a VPC type private network NAT gateway be created.", + }, + + "ccn_id": { + Optional: true, + Computed: true, + Type: schema.TypeString, + Description: "Cloud Connect Network type The Cloud Connect Network instance ID required to be bound to the private network NAT gateway.", + }, + }, + } +} + +func resourceTencentCloudVpcPrivateNatGatewayCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_vpc_private_nat_gateway.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId) + + var ( + request = vpc.NewCreatePrivateNatGatewayRequest() + response = vpc.NewCreatePrivateNatGatewayResponse() + instanceId string + ) + if v, ok := d.GetOk("nat_gateway_name"); ok { + request.NatGatewayName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("vpc_id"); ok { + request.VpcId = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("cross_domain"); ok { + request.CrossDomain = helper.Bool(v.(bool)) + } + + if v, ok := d.GetOkExists("vpc_type"); ok { + request.VpcType = helper.Bool(v.(bool)) + } + + if v, ok := d.GetOk("ccn_id"); ok { + request.CcnId = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().CreatePrivateNatGateway(request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create vpc privateNatGateway failed, reason:%+v", logId, err) + return err + } + + if response.Response != nil && len(response.Response.PrivateNatGatewaySet) > 0 { + privateNatGateway := response.Response.PrivateNatGatewaySet[0] + if privateNatGateway.NatGatewayId != nil { + instanceId = *response.Response.PrivateNatGatewaySet[0].NatGatewayId + } + } + if instanceId == "" { + d.SetId("") + return fmt.Errorf("instanceId is nil") + } + + service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + err = resource.Retry(5*tccommon.ReadRetryTimeout, func() *resource.RetryError { + privateNatGateway, errRet := service.DescribeVpcPrivateNatGatewayById(ctx, instanceId) + if errRet != nil { + return tccommon.RetryError(errRet) + } + if privateNatGateway.Status == nil { + return resource.RetryableError(fmt.Errorf("waiting for instance create")) + } + if *privateNatGateway.Status != "AVAILABLE" { + return resource.RetryableError(fmt.Errorf("waiting for instance create")) + } + return nil + }) + if err != nil { + return err + } + d.SetId(instanceId) + + return resourceTencentCloudVpcPrivateNatGatewayRead(d, meta) +} + +func resourceTencentCloudVpcPrivateNatGatewayRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_vpc_private_nat_gateway.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId) + + service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + instanceId := d.Id() + + privateNatGateway, err := service.DescribeVpcPrivateNatGatewayById(ctx, instanceId) + if err != nil { + return err + } + + if privateNatGateway == nil { + d.SetId("") + log.Printf("[WARN]%s resource `VpcPrivateNatGateway` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + if privateNatGateway.NatGatewayName != nil { + _ = d.Set("nat_gateway_name", privateNatGateway.NatGatewayName) + } + + if privateNatGateway.VpcId != nil { + _ = d.Set("vpc_id", privateNatGateway.VpcId) + } + + if privateNatGateway.CrossDomain != nil { + _ = d.Set("cross_domain", privateNatGateway.CrossDomain) + } + + if privateNatGateway.VpcType != nil { + _ = d.Set("vpc_type", privateNatGateway.VpcType) + } + + if privateNatGateway.CcnId != nil { + _ = d.Set("ccn_id", privateNatGateway.CcnId) + } + + return nil +} + +func resourceTencentCloudVpcPrivateNatGatewayUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_vpc_private_nat_gateway.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId) + + request := vpc.NewModifyPrivateNatGatewayAttributeRequest() + + instanceId := d.Id() + + request.NatGatewayId = &instanceId + + immutableArgs := []string{"vpc_id", "cross_domain", "vpc_type", "ccn_id"} + + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + + if d.HasChange("nat_gateway_name") { + if v, ok := d.GetOk("nat_gateway_name"); ok { + request.NatGatewayName = helper.String(v.(string)) + } + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyPrivateNatGatewayAttribute(request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s update vpc privateNatGateway failed, reason:%+v", logId, err) + return err + } + + service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + err = resource.Retry(5*tccommon.ReadRetryTimeout, func() *resource.RetryError { + privateNatGateway, errRet := service.DescribeVpcPrivateNatGatewayById(ctx, instanceId) + if errRet != nil { + return tccommon.RetryError(errRet) + } + if privateNatGateway.Status == nil { + return resource.RetryableError(fmt.Errorf("waiting for instance update")) + } + if *privateNatGateway.Status != "AVAILABLE" { + return resource.RetryableError(fmt.Errorf("waiting for instance update")) + } + return nil + }) + if err != nil { + return err + } + return resourceTencentCloudVpcPrivateNatGatewayRead(d, meta) +} + +func resourceTencentCloudVpcPrivateNatGatewayDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_vpc_private_nat_gateway.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId) + + service := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + instanceId := d.Id() + + if err := service.DeleteVpcPrivateNatGatewayById(ctx, instanceId); err != nil { + return err + } + + err := resource.Retry(5*tccommon.ReadRetryTimeout, func() *resource.RetryError { + privateNatGateway, errRet := service.DescribeVpcPrivateNatGatewayById(ctx, instanceId) + if errRet != nil { + return tccommon.RetryError(errRet) + } + if privateNatGateway != nil { + return resource.RetryableError(fmt.Errorf("waiting for instance delete")) + } + return nil + }) + + if err != nil { + return err + } + return nil +} diff --git a/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.md b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.md new file mode 100644 index 0000000000..964413ebca --- /dev/null +++ b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway.md @@ -0,0 +1,18 @@ +Provides a resource to create a vpc private nat gateway + +Example Usage + +```hcl +resource "tencentcloud_vpc_private_nat_gateway" "private_nat_gateway" { + nat_gateway_name = "xxx" + vpc_id = "xxx" +} +``` + +Import + +vpc private_nat_gateway can be imported using the id, e.g. + +``` +terraform import tencentcloud_vpc_private_nat_gateway.private_nat_gateway private_nat_gateway_id +``` \ No newline at end of file diff --git a/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway_test.go b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway_test.go new file mode 100644 index 0000000000..aa3e9b1d16 --- /dev/null +++ b/tencentcloud/services/vpc/resource_tc_vpc_private_nat_gateway_test.go @@ -0,0 +1,67 @@ +package vpc_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudVpcPrivateNatGatewayResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccVpcPrivateNatGateway, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "id"), + resource.TestCheckResourceAttr("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "nat_gateway_name", "private-nat-gateway"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "vpc_id"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "cross_domain"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "vpc_type"), + resource.TestCheckResourceAttr("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "ccn_id", ""), + ), + }, + { + Config: testAccVpcPrivateNatGatewayUpdateName, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "id"), + resource.TestCheckResourceAttr("tencentcloud_vpc_private_nat_gateway.private_nat_gateway", "nat_gateway_name", "private-nat-gateway-update"), + ), + }, + { + ResourceName: "tencentcloud_vpc_private_nat_gateway.private_nat_gateway", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccVpcPrivateNatGateway = ` +resource "tencentcloud_vpc" "foo" { + name = "private-nat-gateway-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_vpc_private_nat_gateway" "private_nat_gateway" { + nat_gateway_name = "private-nat-gateway" + vpc_id = tencentcloud_vpc.foo.id +} +` + +const testAccVpcPrivateNatGatewayUpdateName = ` +resource "tencentcloud_vpc" "foo" { + name = "private-nat-gateway-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_vpc_private_nat_gateway" "private_nat_gateway" { + nat_gateway_name = "private-nat-gateway-update" + vpc_id = tencentcloud_vpc.foo.id +} +` diff --git a/tencentcloud/services/vpc/service_tencentcloud_vpc.go b/tencentcloud/services/vpc/service_tencentcloud_vpc.go index 026ecd3617..139a9a6929 100644 --- a/tencentcloud/services/vpc/service_tencentcloud_vpc.go +++ b/tencentcloud/services/vpc/service_tencentcloud_vpc.go @@ -8050,3 +8050,56 @@ func (me *VpcService) DeleteVpcPeerConnectAccecptOrRejectById(ctx context.Contex return } + +func (me *VpcService) DescribeVpcPrivateNatGatewayById(ctx context.Context, instanceId string) (privateNatGateway *vpc.PrivateNatGateway, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := vpc.NewDescribePrivateNatGatewaysRequest() + request.NatGatewayIds = []*string{&instanceId} + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseVpcClient().DescribePrivateNatGateways(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if len(response.Response.PrivateNatGatewaySet) < 1 { + return + } + + privateNatGateway = response.Response.PrivateNatGatewaySet[0] + return +} + +func (me *VpcService) DeleteVpcPrivateNatGatewayById(ctx context.Context, instanceId string) (errRet error) { + logId := tccommon.GetLogId(ctx) + + request := vpc.NewDeletePrivateNatGatewayRequest() + request.NatGatewayId = &instanceId + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseVpcClient().DeletePrivateNatGateway(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index 6f638426d3..cb33214d0e 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.971" + params["RequestClient"] = "SDK_GO_1.0.978" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/client.go index 89de3dab48..569a2d55f3 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/client.go @@ -9301,6 +9301,10 @@ func NewDeleteVpnConnectionResponse() (response *DeleteVpnConnectionResponse) { // DeleteVpnConnection // 本接口(DeleteVpnConnection)用于删除VPN通道。 // +// >?本接口为异步接口 +// +// > +// // 可能返回的错误码: // INVALIDPARAMETERVALUE_MALFORMED = "InvalidParameterValue.Malformed" // RESOURCENOTFOUND = "ResourceNotFound" @@ -9315,6 +9319,10 @@ func (c *Client) DeleteVpnConnection(request *DeleteVpnConnectionRequest) (respo // DeleteVpnConnection // 本接口(DeleteVpnConnection)用于删除VPN通道。 // +// >?本接口为异步接口 +// +// > +// // 可能返回的错误码: // INVALIDPARAMETERVALUE_MALFORMED = "InvalidParameterValue.Malformed" // RESOURCENOTFOUND = "ResourceNotFound" diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/models.go index b414784cd3..95b748474e 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312/models.go @@ -900,6 +900,9 @@ type AssignIpv6AddressesRequestParams struct { // 自动分配`IPv6`地址个数,内网IP地址个数总和不能超过配额数。与入参`Ipv6Addresses`合并计算配额。与Ipv6Addresses必填一个。 Ipv6AddressCount *uint64 `json:"Ipv6AddressCount,omitnil,omitempty" name:"Ipv6AddressCount"` + + // 用于保证请求幂等性的字符串。该字符串由客户生成,需保证不同请求之间唯一,最大值不超过64个ASCII字符。若不指定该参数,则无法保证请求的幂等性。 + ClientToken *string `json:"ClientToken,omitnil,omitempty" name:"ClientToken"` } type AssignIpv6AddressesRequest struct { @@ -913,6 +916,9 @@ type AssignIpv6AddressesRequest struct { // 自动分配`IPv6`地址个数,内网IP地址个数总和不能超过配额数。与入参`Ipv6Addresses`合并计算配额。与Ipv6Addresses必填一个。 Ipv6AddressCount *uint64 `json:"Ipv6AddressCount,omitnil,omitempty" name:"Ipv6AddressCount"` + + // 用于保证请求幂等性的字符串。该字符串由客户生成,需保证不同请求之间唯一,最大值不超过64个ASCII字符。若不指定该参数,则无法保证请求的幂等性。 + ClientToken *string `json:"ClientToken,omitnil,omitempty" name:"ClientToken"` } func (r *AssignIpv6AddressesRequest) ToJsonString() string { @@ -930,6 +936,7 @@ func (r *AssignIpv6AddressesRequest) FromJsonString(s string) error { delete(f, "NetworkInterfaceId") delete(f, "Ipv6Addresses") delete(f, "Ipv6AddressCount") + delete(f, "ClientToken") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "AssignIpv6AddressesRequest has unknown keys!", "") } @@ -3357,6 +3364,7 @@ type CreateBandwidthPackageRequestParams struct { //