From 55a5e2d143018c31f8a3ab0b848c275bbb9008f0 Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Fri, 31 Jan 2025 20:13:41 +0800 Subject: [PATCH] VpnGateway: Improves the invoking api method and supports refreshing credential automatically --- ..._source_alicloud_vpn_gateway_vco_routes.go | 10 +- ...ce_alicloud_vpn_gateway_vpn_attachments.go | 10 +- alicloud/data_source_alicloud_vpn_gateways.go | 11 +- .../data_source_alicloud_vpn_ipsec_servers.go | 10 +- ...a_source_alicloud_vpn_pbr_route_entries.go | 10 +- ...resource_alicloud_vpn_gateway_vco_route.go | 19 +- ...rce_alicloud_vpn_gateway_vpn_attachment.go | 28 +- ...licloud_vpn_gateway_vpn_attachment_test.go | 17 +- .../resource_alicloud_vpn_ipsec_server.go | 28 +- ...resource_alicloud_vpn_ipsec_server_test.go | 9 +- .../resource_alicloud_vpn_pbr_route_entry.go | 33 +- alicloud/resource_alicloud_vpn_route_entry.go | 33 +- alicloud/service_alicloud_vpc.go | 539 ++++-------------- .../d/vpn_gateway_vco_routes.html.markdown | 6 +- .../vpn_gateway_vpn_attachments.html.markdown | 86 ++- .../docs/d/vpn_ipsec_servers.html.markdown | 64 +-- 16 files changed, 248 insertions(+), 665 deletions(-) diff --git a/alicloud/data_source_alicloud_vpn_gateway_vco_routes.go b/alicloud/data_source_alicloud_vpn_gateway_vco_routes.go index 5ba70958b712..446c223670fa 100644 --- a/alicloud/data_source_alicloud_vpn_gateway_vco_routes.go +++ b/alicloud/data_source_alicloud_vpn_gateway_vco_routes.go @@ -5,7 +5,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -125,16 +124,11 @@ func dataSourceAlicloudVpnGatewayVcoRoutesRead(d *schema.ResourceData, meta inte } status, statusOk := d.GetOk("status") var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_vpn_gateway_vpn_attachments.go b/alicloud/data_source_alicloud_vpn_gateway_vpn_attachments.go index 3354418e32bd..cf30f7455d65 100644 --- a/alicloud/data_source_alicloud_vpn_gateway_vpn_attachments.go +++ b/alicloud/data_source_alicloud_vpn_gateway_vpn_attachments.go @@ -6,7 +6,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -279,16 +278,11 @@ func dataSourceAlicloudVpnGatewayVpnAttachmentsRead(d *schema.ResourceData, meta } status, statusOk := d.GetOk("status") var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_vpn_gateways.go b/alicloud/data_source_alicloud_vpn_gateways.go index e8d8c757561c..b15d8c29f908 100644 --- a/alicloud/data_source_alicloud_vpn_gateways.go +++ b/alicloud/data_source_alicloud_vpn_gateways.go @@ -10,7 +10,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -228,20 +227,14 @@ func dataSourceAlicloudVpnsRead(d *schema.ResourceData, meta interface{}) error } var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error wait := incrementalWait(3*time.Second, 3*time.Second) request["PageNumber"] = 1 request["PageSize"] = PageSizeLarge for { err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_vpn_ipsec_servers.go b/alicloud/data_source_alicloud_vpn_ipsec_servers.go index fdd3ae664faf..acc59f4e5650 100644 --- a/alicloud/data_source_alicloud_vpn_ipsec_servers.go +++ b/alicloud/data_source_alicloud_vpn_ipsec_servers.go @@ -6,7 +6,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -212,16 +211,11 @@ func dataSourceAlicloudVpnIpsecServersRead(d *schema.ResourceData, meta interfac request["IpsecServerId"] = v } var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_vpn_pbr_route_entries.go b/alicloud/data_source_alicloud_vpn_pbr_route_entries.go index 28621509eab2..60b13b82eb12 100644 --- a/alicloud/data_source_alicloud_vpn_pbr_route_entries.go +++ b/alicloud/data_source_alicloud_vpn_pbr_route_entries.go @@ -5,7 +5,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -96,16 +95,11 @@ func dataSourceAlicloudVpnPbrRouteEntriesRead(d *schema.ResourceData, meta inter } } var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_vpn_gateway_vco_route.go b/alicloud/resource_alicloud_vpn_gateway_vco_route.go index 98a049b1f17b..1c1e43bfbacd 100644 --- a/alicloud/resource_alicloud_vpn_gateway_vco_route.go +++ b/alicloud/resource_alicloud_vpn_gateway_vco_route.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -65,10 +64,7 @@ func resourceAlicloudVpnGatewayVcoRouteCreate(d *schema.ResourceData, meta inter var response map[string]interface{} action := "CreateVcoRouteEntry" request := make(map[string]interface{}) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request["RegionId"] = client.RegionId request["Weight"] = d.Get("weight") request["NextHop"] = d.Get("next_hop") @@ -78,11 +74,9 @@ func resourceAlicloudVpnGatewayVcoRouteCreate(d *schema.ResourceData, meta inter request["OverlayMode"] = v } request["ClientToken"] = buildClientToken("CreateVcoRouteEntry") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -122,10 +116,7 @@ func resourceAlicloudVpnGatewayVcoRouteRead(d *schema.ResourceData, meta interfa } func resourceAlicloudVpnGatewayVcoRouteDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error parts, err := ParseResourceId(d.Id(), 4) if err != nil { return WrapError(err) @@ -141,11 +132,9 @@ func resourceAlicloudVpnGatewayVcoRouteDelete(d *schema.ResourceData, meta inter request["Weight"] = parts[3] request["ClientToken"] = buildClientToken("DeleteVcoRouteEntry") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutDelete)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_vpn_gateway_vpn_attachment.go b/alicloud/resource_alicloud_vpn_gateway_vpn_attachment.go index 1581cacac408..dc52c0ac3e2d 100644 --- a/alicloud/resource_alicloud_vpn_gateway_vpn_attachment.go +++ b/alicloud/resource_alicloud_vpn_gateway_vpn_attachment.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -240,10 +239,7 @@ func resourceAlicloudVpnGatewayVpnAttachmentCreate(d *schema.ResourceData, meta var response map[string]interface{} action := "CreateVpnAttachment" request := make(map[string]interface{}) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request["CustomerGatewayId"] = d.Get("customer_gateway_id") if v, ok := d.GetOkExists("effect_immediately"); ok { request["EffectImmediately"] = v @@ -316,11 +312,9 @@ func resourceAlicloudVpnGatewayVpnAttachmentCreate(d *schema.ResourceData, meta request["BgpConfig"] = bgpMapsString } request["ClientToken"] = buildClientToken("CreateVpnAttachment") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -429,10 +423,7 @@ func resourceAlicloudVpnGatewayVpnAttachmentRead(d *schema.ResourceData, meta in func resourceAlicloudVpnGatewayVpnAttachmentUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) vpcService := VpcService{client} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error var response map[string]interface{} update := false request := map[string]interface{}{ @@ -547,11 +538,9 @@ func resourceAlicloudVpnGatewayVpnAttachmentUpdate(d *schema.ResourceData, meta if update { action := "ModifyVpnAttachmentAttribute" request["ClientToken"] = buildClientToken("ModifyVpnAttachmentAttribute") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -576,20 +565,15 @@ func resourceAlicloudVpnGatewayVpnAttachmentDelete(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) action := "DeleteVpnAttachment" var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{} request["RegionId"] = client.RegionId request["VpnConnectionId"] = d.Id() request["ClientToken"] = buildClientToken("DeleteVpnAttachment") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_vpn_gateway_vpn_attachment_test.go b/alicloud/resource_alicloud_vpn_gateway_vpn_attachment_test.go index 37b185a1aba9..289c678bc11d 100644 --- a/alicloud/resource_alicloud_vpn_gateway_vpn_attachment_test.go +++ b/alicloud/resource_alicloud_vpn_gateway_vpn_attachment_test.go @@ -40,30 +40,23 @@ func testSweepVpnGatewayVpnAttachment(region string) error { if err != nil { return fmt.Errorf("error getting Alicloud client: %s", err) } - aliyunClient := rawClient.(*connectivity.AliyunClient) + client := rawClient.(*connectivity.AliyunClient) prefixes := []string{ "tf-testAcc", "tf_testAcc", } action := "DescribeVpnConnections" request := map[string]interface{}{} - request["RegionId"] = aliyunClient.RegionId + request["RegionId"] = client.RegionId request["PageSize"] = PageSizeLarge request["PageNumber"] = 1 var response map[string]interface{} - conn, err := aliyunClient.NewVpcClient() - if err != nil { - log.Printf("[ERROR] %s get an error: %#v", action, err) - return nil - } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -103,9 +96,9 @@ func testSweepVpnGatewayVpnAttachment(region string) error { action := "DeleteVpnAttachment" request := map[string]interface{}{ "VpnConnectionId": item["VpnConnectionId"], - "RegionId": aliyunClient.RegionId, + "RegionId": client.RegionId, } - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, false) if err != nil { log.Printf("[ERROR] Failed to delete Vpn Gateway Vpn Attachment (%s): %s", name, err) } diff --git a/alicloud/resource_alicloud_vpn_ipsec_server.go b/alicloud/resource_alicloud_vpn_ipsec_server.go index 4e83e6cb36a0..98431967a259 100644 --- a/alicloud/resource_alicloud_vpn_ipsec_server.go +++ b/alicloud/resource_alicloud_vpn_ipsec_server.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -143,10 +142,7 @@ func resourceAlicloudVpnIpsecServerCreate(d *schema.ResourceData, meta interface var response map[string]interface{} action := "CreateIpsecServer" request := make(map[string]interface{}) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request["ClientIpPool"] = d.Get("client_ip_pool") if v, ok := d.GetOkExists("dry_run"); ok { request["DryRun"] = v @@ -205,12 +201,10 @@ func resourceAlicloudVpnIpsecServerCreate(d *schema.ResourceData, meta interface request["RegionId"] = client.RegionId request["VpnGatewayId"] = d.Get("vpn_gateway_id") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { request["ClientToken"] = buildClientToken("CreateIpsecServer") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -287,10 +281,7 @@ func resourceAlicloudVpnIpsecServerRead(d *schema.ResourceData, meta interface{} } func resourceAlicloudVpnIpsecServerUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error var response map[string]interface{} update := false request := map[string]interface{}{ @@ -377,12 +368,10 @@ func resourceAlicloudVpnIpsecServerUpdate(d *schema.ResourceData, meta interface request["DryRun"] = v } action := "UpdateIpsecServer" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { request["ClientToken"] = buildClientToken("UpdateIpsecServer") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"VpnGateway.Configuring"}) { wait() @@ -403,10 +392,7 @@ func resourceAlicloudVpnIpsecServerDelete(d *schema.ResourceData, meta interface client := meta.(*connectivity.AliyunClient) action := "DeleteIpsecServer" var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "IpsecServerId": d.Id(), } @@ -415,12 +401,10 @@ func resourceAlicloudVpnIpsecServerDelete(d *schema.ResourceData, meta interface request["DryRun"] = v } request["RegionId"] = client.RegionId - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { request["ClientToken"] = buildClientToken("DeleteIpsecServer") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"VpnGateway.Configuring"}) { wait() diff --git a/alicloud/resource_alicloud_vpn_ipsec_server_test.go b/alicloud/resource_alicloud_vpn_ipsec_server_test.go index c55c07bc1ed6..8881bf2ca6c3 100644 --- a/alicloud/resource_alicloud_vpn_ipsec_server_test.go +++ b/alicloud/resource_alicloud_vpn_ipsec_server_test.go @@ -49,17 +49,12 @@ func testSweepVpnIpsecServer(region string) error { request["MaxResults"] = PageSizeLarge var response map[string]interface{} - conn, err := aliyunClient.NewVpcClient() - if err != nil { - log.Printf("[ERROR] %s get an error: %#v", action, err) - return nil - } for { runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = aliyunClient.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -99,7 +94,7 @@ func testSweepVpnIpsecServer(region string) error { "IpsecServerId": item["IpsecServerId"], "RegionId": aliyunClient.RegionId, } - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = aliyunClient.RpcPost("Vpc", "2016-04-28", action, nil, request, false) if err != nil { log.Printf("[ERROR] Failed to delete Vpn Ipsec Server (%s): %s", item["IpsecServerName"].(string), err) } diff --git a/alicloud/resource_alicloud_vpn_pbr_route_entry.go b/alicloud/resource_alicloud_vpn_pbr_route_entry.go index 26ab945f42ba..5219fa65597c 100644 --- a/alicloud/resource_alicloud_vpn_pbr_route_entry.go +++ b/alicloud/resource_alicloud_vpn_pbr_route_entry.go @@ -5,8 +5,6 @@ import ( "log" "time" - util "github.com/alibabacloud-go/tea-utils/service" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -73,10 +71,7 @@ func resourceAlicloudVpnPbrRouteEntryCreate(d *schema.ResourceData, meta interfa var response map[string]interface{} action := "CreateVpnPbrRouteEntry" request := make(map[string]interface{}) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request["RegionId"] = client.RegionId request["VpnGatewayId"] = d.Get("vpn_gateway_id") request["RouteDest"] = d.Get("route_dest") @@ -85,12 +80,10 @@ func resourceAlicloudVpnPbrRouteEntryCreate(d *schema.ResourceData, meta interfa request["PublishVpc"] = d.Get("publish_vpc") request["RouteSource"] = d.Get("route_source") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { request["ClientToken"] = buildClientToken(action) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -146,10 +139,7 @@ func resourceAlicloudVpnPbrRouteEntryUpdate(d *schema.ResourceData, meta interfa client := meta.(*connectivity.AliyunClient) var response map[string]interface{} d.Partial(true) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error parts, err := ParseResourceId(d.Id(), 4) if err != nil { return WrapError(err) @@ -174,12 +164,10 @@ func resourceAlicloudVpnPbrRouteEntryUpdate(d *schema.ResourceData, meta interfa if update { request["RouteType"] = "pbr" action := "PublishVpnRouteEntry" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -213,12 +201,10 @@ func resourceAlicloudVpnPbrRouteEntryUpdate(d *schema.ResourceData, meta interfa if update { action := "ModifyVpnPbrRouteEntryWeight" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, weightRequest, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, weightRequest, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -243,10 +229,7 @@ func resourceAlicloudVpnPbrRouteEntryDelete(d *schema.ResourceData, meta interfa client := meta.(*connectivity.AliyunClient) vpcService := VpcService{client} var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error parts, err := ParseResourceId(d.Id(), 4) if err != nil { return WrapError(err) @@ -265,12 +248,10 @@ func resourceAlicloudVpnPbrRouteEntryDelete(d *schema.ResourceData, meta interfa } action := "DeleteVpnPbrRouteEntry" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_vpn_route_entry.go b/alicloud/resource_alicloud_vpn_route_entry.go index c2a4f416a9eb..78fafc40dcc3 100644 --- a/alicloud/resource_alicloud_vpn_route_entry.go +++ b/alicloud/resource_alicloud_vpn_route_entry.go @@ -5,8 +5,6 @@ import ( "log" "time" - util "github.com/alibabacloud-go/tea-utils/service" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -78,10 +76,7 @@ func resourceAliyunVpnRouteEntryCreate(d *schema.ResourceData, meta interface{}) var response map[string]interface{} action := "CreateVpnRouteEntry" request := make(map[string]interface{}) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error request["RegionId"] = client.RegionId request["VpnGatewayId"] = d.Get("vpn_gateway_id") request["RouteDest"] = d.Get("route_dest") @@ -89,12 +84,10 @@ func resourceAliyunVpnRouteEntryCreate(d *schema.ResourceData, meta interface{}) request["Weight"] = d.Get("weight") request["PublishVpc"] = d.Get("publish_vpc") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { request["ClientToken"] = buildClientToken(action) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -153,10 +146,7 @@ func resourceAliyunVpnRouteEntryUpdate(d *schema.ResourceData, meta interface{}) vpcService := VpcService{client} var response map[string]interface{} d.Partial(true) - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error parts, err := ParseResourceId(d.Id(), 3) if err != nil { return WrapError(err) @@ -180,12 +170,10 @@ func resourceAliyunVpnRouteEntryUpdate(d *schema.ResourceData, meta interface{}) if update { request["RouteType"] = "dbr" action := "PublishVpnRouteEntry" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -229,12 +217,10 @@ func resourceAliyunVpnRouteEntryUpdate(d *schema.ResourceData, meta interface{}) if update { action := "ModifyVpnRouteEntryWeight" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, weightRequest, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, weightRequest, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring"}) || NeedRetry(err) { wait() @@ -259,10 +245,7 @@ func resourceAliyunVpnRouteEntryDelete(d *schema.ResourceData, meta interface{}) client := meta.(*connectivity.AliyunClient) vpcService := VpcService{client} var response map[string]interface{} - conn, err := client.NewVpcClient() - if err != nil { - return WrapError(err) - } + var err error parts, err := ParseResourceId(d.Id(), 3) if err != nil { return WrapError(err) @@ -280,12 +263,10 @@ func resourceAliyunVpnRouteEntryDelete(d *schema.ResourceData, meta interface{}) } action := "DeleteVpnRouteEntry" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) request["ClientToken"] = buildClientToken(action) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"VpnGateway.Configuring", "TaskConflict", "Appliance.Configuring", "VpnTask.CONFLICT", "VpnConnection.Configuring", "VpnRouteEntry.Configuring"}) || NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_vpc.go b/alicloud/service_alicloud_vpc.go index 7284412fc708..a15d210b1755 100644 --- a/alicloud/service_alicloud_vpc.go +++ b/alicloud/service_alicloud_vpc.go @@ -14,7 +14,6 @@ import ( "fmt" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/alibaba-cloud-sdk-go/services/vpc" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" ) @@ -72,18 +71,13 @@ func (s *VpcService) DescribeEipAssociation(id string) (object map[string]interf func (s *VpcService) DescribeNatGateway(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeNatGateways" request := map[string]interface{}{ "RegionId": s.client.RegionId, "NatGatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidNatGatewayId.NotFound", "InvalidRegionId.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("NatGateway", id)), NotFoundMsg, ProviderERROR) @@ -110,18 +104,13 @@ func (s *VpcService) DescribeNatGateway(id string) (object map[string]interface{ func (s *VpcService) DescribeVpc(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpcs" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpcId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"Forbidden.VpcNotFound", "InvalidVpcID.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("Vpc", id)), NotFoundMsg, ProviderERROR) @@ -147,21 +136,16 @@ func (s *VpcService) DescribeVpc(id string) (object map[string]interface{}, err } func (s *VpcService) DescribeVpcWithTeadsl(id string) (object map[string]interface{}, err error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpcs" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpcId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) invoker := NewInvoker() err = invoker.Run(func() error { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidVpcID.NotFound", "Forbidden.VpcNotFound"}) { return WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR) @@ -184,10 +168,7 @@ func (s *VpcService) DescribeVpcWithTeadsl(id string) (object map[string]interfa } func (s *VpcService) ListTagResources(id string, resourceType string) (object interface{}, err error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListTagResources" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -200,7 +181,7 @@ func (s *VpcService) ListTagResources(id string, resourceType string) (object in for { wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -279,19 +260,14 @@ func (s *VpcService) DescribeVSwitch(id string) (v vpc.DescribeVSwitchAttributes } func (s *VpcService) DescribeVSwitchWithTeadsl(id string) (object map[string]interface{}, err error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVSwitchAttributes" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VSwitchId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidVswitchID.NotFound"}) { return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR) @@ -328,10 +304,7 @@ func (s *VpcService) VSwitchStateRefreshFunc(id string, failStates []string) res func (s *VpcService) DescribeSnatEntry(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeSnatTableEntries" parts, err := ParseResourceId(id, 2) if err != nil { @@ -343,11 +316,9 @@ func (s *VpcService) DescribeSnatEntry(id string) (object map[string]interface{} "SnatEntryId": parts[1], "SnatTableId": parts[0], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -381,10 +352,7 @@ func (s *VpcService) DescribeSnatEntry(id string) (object map[string]interface{} func (s *VpcService) DescribeForwardEntry(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeForwardTableEntries" parts, err := ParseResourceId(id, 2) if err != nil { @@ -396,9 +364,7 @@ func (s *VpcService) DescribeForwardEntry(id string) (object map[string]interfac "ForwardEntryId": parts[1], "ForwardTableId": parts[0], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidForwardEntryId.NotFound", "InvalidForwardTableId.NotFound", "InvalidRegionId.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("ForwardEntry", id)), NotFoundMsg, ProviderERROR) @@ -635,18 +601,13 @@ func (s *VpcService) WaitForCenInstanceGrant(id string, status Status, timeout i func (s *VpcService) DescribeCommonBandwidthPackage(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeCommonBandwidthPackages" request := map[string]interface{}{ "RegionId": s.client.RegionId, "BandwidthPackageId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidRegionId.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("CommonBandwidthPackage", id)), NotFoundMsg, ProviderERROR) @@ -673,18 +634,13 @@ func (s *VpcService) DescribeCommonBandwidthPackage(id string) (object map[strin func (s *VpcService) DescribeRouteTable(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeRouteTableList" request := map[string]interface{}{ "RegionId": s.client.RegionId, "RouteTableId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { err = WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) return @@ -970,20 +926,15 @@ func (s *VpcService) WaitForRouteTableAttachment(id string, status Status, timeo func (s *VpcService) DescribeNetworkAcl(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeNetworkAclAttributes" request := map[string]interface{}{ "RegionId": s.client.RegionId, "NetworkAclId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1147,10 +1098,7 @@ func (s *VpcService) DescribeTags(resourceId string, resourceTags map[string]int func (s *VpcService) setInstanceTags(d *schema.ResourceData, resourceType TagResourceType) error { if d.HasChange("tags") { added, removed := parsingTags(d) - conn, err := s.client.NewVpcClient() - if err != nil { - return WrapError(err) - } + client := s.client if len(removed) > 0 { action := "UnTagResources" @@ -1165,7 +1113,7 @@ func (s *VpcService) setInstanceTags(d *schema.ResourceData, resourceType TagRes wait := incrementalWait(2*time.Second, 1*time.Second) err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1198,7 +1146,7 @@ func (s *VpcService) setInstanceTags(d *schema.ResourceData, resourceType TagRes wait := incrementalWait(2*time.Second, 1*time.Second) err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1249,10 +1197,7 @@ func (s *VpcService) SetInstanceSecondaryCidrBlocks(d *schema.ResourceData) erro oraw, nraw := d.GetChange("secondary_cidr_blocks") removed := oraw.(*schema.Set).Difference(nraw.(*schema.Set)).List() added := nraw.(*schema.Set).Difference(oraw.(*schema.Set)).List() - conn, err := s.client.NewVpcClient() - if err != nil { - return WrapError(err) - } + client := s.client if len(removed) > 0 { action := "UnassociateVpcCidrBlock" request := map[string]interface{}{ @@ -1261,7 +1206,7 @@ func (s *VpcService) SetInstanceSecondaryCidrBlocks(d *schema.ResourceData) erro } for _, item := range removed { request["SecondaryCidrBlock"] = item - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } @@ -1277,7 +1222,7 @@ func (s *VpcService) SetInstanceSecondaryCidrBlocks(d *schema.ResourceData) erro } for _, item := range added { request["SecondaryCidrBlock"] = item - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } @@ -1289,11 +1234,8 @@ func (s *VpcService) SetInstanceSecondaryCidrBlocks(d *schema.ResourceData) erro return nil } -func (s *VpcService) DescribeNatGatewayTransform(id string) ([]interface{}, error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } +func (s *VpcService) DescribeNatGatewayTransform(id string) (object []interface{}, err error) { + client := s.client action := "GetNatGatewayConvertStatus" request := map[string]interface{}{ @@ -1301,11 +1243,7 @@ func (s *VpcService) DescribeNatGatewayTransform(id string) ([]interface{}, erro "NatGatewayId": id, } request["ClientToken"] = buildClientToken("GetNatGatewayConvertStatus") - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - - response, err1 := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err1 := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err1 != nil { if IsExpectedErrors(err1, []string{"InvalidVpcID.NotFound", "Forbidden.VpcNotFound"}) { return nil, WrapErrorf(err, NotFoundMsg, AlibabaCloudSdkGoERROR) @@ -1324,7 +1262,7 @@ func (s *VpcService) DescribeNatGatewayTransform(id string) ([]interface{}, erro return nil, WrapErrorf(err3, FailedGetAttributeMsg, id, "$.DstNatType", response) } - object := ob.([]interface{}) + object = ob.([]interface{}) if len(object) < 1 || natType.(string) != "Enhanced" { return nil, WrapErrorf(Error(GetNotFoundMessage("NAT", id)), NotFoundWithResponse, response) } @@ -1367,10 +1305,7 @@ func (s *VpcService) WaitForNatGatewayTransform(id string, timeout int64) error func (s *VpcService) DescribeRouteTableList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeRouteTableList" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -1379,11 +1314,9 @@ func (s *VpcService) DescribeRouteTableList(id string) (object map[string]interf "PageNumber": 1, } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err := resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1425,10 +1358,7 @@ func (s *VpcService) SetResourceTags(d *schema.ResourceData, resourceType string if d.HasChange("tags") { added, removed := parsingTags(d) - conn, err := s.client.NewVpcClient() - if err != nil { - return WrapError(err) - } + client := s.client removedTagKeys := make([]string, 0) for _, v := range removed { @@ -1448,7 +1378,7 @@ func (s *VpcService) SetResourceTags(d *schema.ResourceData, resourceType string } wait := incrementalWait(2*time.Second, 1*time.Second) err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1480,7 +1410,7 @@ func (s *VpcService) SetResourceTags(d *schema.ResourceData, resourceType string wait := incrementalWait(2*time.Second, 1*time.Second) err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1503,18 +1433,13 @@ func (s *VpcService) SetResourceTags(d *schema.ResourceData, resourceType string func (s *VpcService) DescribeVswitch(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVSwitchAttributes" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VSwitchId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidVSwitchId.NotFound", "InvalidVswitchID.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("Vswitch", id)), NotFoundWithError, err) @@ -1637,10 +1562,7 @@ func (s *VpcService) CommonBandwidthPackageStateRefreshFunc(id string, failState func (s *VpcService) DescribeHavip(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeHaVips" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -1648,9 +1570,7 @@ func (s *VpcService) DescribeHavip(id string) (object map[string]interface{}, er "PageSize": 20, } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidFilterKey.ValueNotSupported", "InvalidHaVipId.NotFound", "InvalidRegionId.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("Havip", id)), NotFoundMsg, ProviderERROR) @@ -1723,20 +1643,15 @@ func (s *VpcService) NatGatewayStateRefreshFunc(id string, failStates []string) func (s *VpcService) DescribeVpcFlowLog(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeFlowLogs" request := map[string]interface{}{ "RegionId": s.client.RegionId, "FlowLogId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1841,16 +1756,11 @@ func (s *VpcService) DeleteAclResources(id string) (object map[string]interface{ "RegionId": s.client.RegionId, } action := "UnassociateNetworkAcl" - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client request["ClientToken"] = buildClientToken("UnassociateNetworkAcl") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"IncorrectStatus.Vpc", "OperationConflict", "IncorrectStatus", "ServiceUnavailable", "LastTokenProcessing", "SystemBusy", "ResourceStatus.Error"}) || NeedRetry(err) { wait() @@ -1876,20 +1786,15 @@ func (s *VpcService) DeleteAclResources(id string) (object map[string]interface{ func (s *VpcService) DescribeEipAddress(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeEipAddresses" request := map[string]interface{}{ "RegionId": s.client.RegionId, "AllocationId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1942,10 +1847,7 @@ func (s *VpcService) DescribeExpressConnectPhysicalConnection(id string) (object var response map[string]interface{} action := "DescribePhysicalConnections" - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -1962,11 +1864,9 @@ func (s *VpcService) DescribeExpressConnectPhysicalConnection(id string) (object idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2035,10 +1935,7 @@ func (s *VpcService) ExpressConnectPhysicalConnectionStateRefreshFunc(id string, func (s *VpcService) DescribeExpressConnectVirtualBorderRouter(id string, includeCrossAccountVbr bool) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVirtualBorderRouters" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -2048,11 +1945,9 @@ func (s *VpcService) DescribeExpressConnectVirtualBorderRouter(id string, includ } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2112,20 +2007,15 @@ func (s *VpcService) ExpressConnectVirtualBorderRouterStateRefreshFunc(id string func (s *VpcService) DescribeVpcDhcpOptionsSet(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetDhcpOptionsSet" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DhcpOptionsSetId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2224,10 +2114,7 @@ func (s *VpcService) DescribeVpcDhcpOptionsSetAttachmentStateRefreshFunc(id stri func (s *VpcService) DescribeVpcNatIpCidr(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListNatIpCidrs" parts, err := ParseResourceId(id, 2) if err != nil { @@ -2239,12 +2126,10 @@ func (s *VpcService) DescribeVpcNatIpCidr(id string) (object map[string]interfac "NatGatewayId": parts[0], "NatIpCidr": parts[1], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { request["ClientToken"] = buildClientToken("ListNatIpCidrs") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2275,10 +2160,7 @@ func (s *VpcService) DescribeVpcNatIpCidr(id string) (object map[string]interfac func (s *VpcService) DescribeVpcNatIp(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { @@ -2290,12 +2172,10 @@ func (s *VpcService) DescribeVpcNatIp(id string) (object map[string]interface{}, "NatGatewayId": parts[0], "NatIpIds": []string{parts[1]}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { request["ClientToken"] = buildClientToken("ListNatIps") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2345,20 +2225,15 @@ func (s *VpcService) VpcNatIpStateRefreshFunc(id string, failStates []string) re func (s *VpcService) DescribeVpcTrafficMirrorFilter(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListTrafficMirrorFilters" request := map[string]interface{}{ "RegionId": s.client.RegionId, "TrafficMirrorFilterIds": []string{id}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2409,10 +2284,7 @@ func (s *VpcService) VpcTrafficMirrorFilterStateRefreshFunc(id string, failState func (s *VpcService) DescribeVpcTrafficMirrorFilterEgressRule(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListTrafficMirrorFilters" parts, err := ParseResourceId(id, 2) if err != nil { @@ -2427,11 +2299,9 @@ func (s *VpcService) DescribeVpcTrafficMirrorFilterEgressRule(id string) (object } idExist := false - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2492,10 +2362,7 @@ func (s *VpcService) VpcTrafficMirrorFilterEgressRuleStateRefreshFunc(id string, func (s *VpcService) DescribeVpcTrafficMirrorFilterIngressRule(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListTrafficMirrorFilters" parts, err := ParseResourceId(id, 2) if err != nil { @@ -2510,11 +2377,9 @@ func (s *VpcService) DescribeVpcTrafficMirrorFilterIngressRule(id string) (objec } idExist := false - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2575,20 +2440,15 @@ func (s *VpcService) VpcTrafficMirrorFilterIngressRuleStateRefreshFunc(id string func (s *VpcService) DescribeVpcTrafficMirrorSession(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListTrafficMirrorSessions" request := map[string]interface{}{ "RegionId": s.client.RegionId, "TrafficMirrorSessionIds": []string{id}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2639,20 +2499,15 @@ func (s *VpcService) VpcTrafficMirrorSessionStateRefreshFunc(id string, failStat func (s *VpcService) DescribeVpcIpv6Gateway(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeIpv6GatewayAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "Ipv6GatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2699,10 +2554,7 @@ func (s *VpcService) VpcIpv6GatewayStateRefreshFunc(id string, failStates []stri func (s *VpcService) DescribeVpcIpv6EgressRule(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { err = WrapError(err) @@ -2717,11 +2569,9 @@ func (s *VpcService) DescribeVpcIpv6EgressRule(id string) (object map[string]int } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2781,20 +2631,15 @@ func (s *VpcService) VpcIpv6EgressRuleStateRefreshFunc(id string, failStates []s func (s *VpcService) DescribeVpcIpv6InternetBandwidth(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeIpv6Addresses" request := map[string]interface{}{ "RegionId": s.client.RegionId, "Ipv6InternetBandwidthId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2825,20 +2670,15 @@ func (s *VpcService) DescribeVpcIpv6InternetBandwidth(id string) (object map[str func (s *VpcService) DescribeVpcBgpGroup(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeBgpGroups" request := map[string]interface{}{ "RegionId": s.client.RegionId, "BgpGroupId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2889,21 +2729,16 @@ func (s *VpcService) VpcBgpGroupStateRefreshFunc(id string, failStates []string) func (s *VpcService) DescribeVpcVbrHa(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVbrHa" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VbrHaId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { request["ClientToken"] = buildClientToken("DescribeVbrHa") - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -2950,20 +2785,15 @@ func (s *VpcService) VpcVbrHaStateRefreshFunc(id string, failStates []string) re func (s *VpcService) DescribeVpcBgpPeer(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeBgpPeers" request := map[string]interface{}{ "RegionId": s.client.RegionId, "BgpPeerId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3014,10 +2844,7 @@ func (s *VpcService) VpcBgpPeerStateRefreshFunc(id string, failStates []string) func (s *VpcService) DescribeVpcBgpNetwork(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeBgpNetworks" parts, err := ParseResourceId(id, 2) if err != nil { @@ -3032,11 +2859,9 @@ func (s *VpcService) DescribeVpcBgpNetwork(id string) (object map[string]interfa } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3096,18 +2921,13 @@ func (s *VpcService) VpcBgpNetworkStateRefreshFunc(id string, failStates []strin func (s *VpcService) DescribeVpnGateway(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpnGateway" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpnGatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidVpnGatewayInstanceId.NotFound", "InvalidRegionId.NotFound"}) { return object, WrapErrorf(Error(GetNotFoundMessage("VpnGateway", id)), NotFoundWithResponse, response) @@ -3128,18 +2948,13 @@ func (s *VpcService) DescribeVpnGateway(id string) (object map[string]interface{ func (s *VpcService) DescribeVpnGateways(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpnGateways" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpnGatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidCustomerGatewayInstanceId"}) { return object, WrapErrorf(Error(GetNotFoundMessage("VpnCustomerGateway", id)), NotFoundWithResponse, response) @@ -3191,18 +3006,13 @@ func (s *VpcService) VpnGatewayStateRefreshFunc(id string, failStates []string) func (s *VpcService) DescribeVpnCustomerGateway(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeCustomerGateway" request := map[string]interface{}{ "RegionId": s.client.RegionId, "CustomerGatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidCustomerGatewayInstanceId"}) { return object, WrapErrorf(Error(GetNotFoundMessage("VpnCustomerGateway", id)), NotFoundWithResponse, response) @@ -3223,10 +3033,7 @@ func (s *VpcService) DescribeVpnCustomerGateway(id string) (object map[string]in func (s *VpcService) DescribeVpnRouteEntry(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return object, WrapError(err) - } + client := s.client action := "DescribeVpnRouteEntries" parts, err := ParseResourceId(id, 3) if err != nil { @@ -3240,11 +3047,9 @@ func (s *VpcService) DescribeVpnRouteEntry(id string) (object map[string]interfa } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3304,20 +3109,15 @@ func (s *VpcService) VpnRouteEntryStateRefreshFunc(id string, failStates []strin func (s *VpcService) DescribeVpnIpsecServer(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListIpsecServers" request := map[string]interface{}{ "RegionId": s.client.RegionId, "IpsecServerId": []string{id}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3348,18 +3148,13 @@ func (s *VpcService) DescribeVpnIpsecServer(id string) (object map[string]interf func (s *VpcService) DescribeVpnConnection(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpnConnection" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpnConnectionId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidVpnConnectionInstanceId.NotFound"}) { return object, WrapErrorf(Error(GetNotFoundMessage("VpnCustomerGateway", id)), NotFoundWithResponse, response) @@ -3400,10 +3195,7 @@ func (s *VpcService) VpnConnectionStateRefreshFunc(id string, failStates []strin func (s *VpcService) DescribeVpnPbrRouteEntry(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return object, WrapError(err) - } + client := s.client action := "DescribeVpnPbrRouteEntries" parts, err := ParseResourceId(id, 4) if err != nil { @@ -3417,11 +3209,9 @@ func (s *VpcService) DescribeVpnPbrRouteEntry(id string) (object map[string]inte } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3481,20 +3271,15 @@ func (s *VpcService) VpnPbrRouteEntryStateRefreshFunc(id string, failStates []st func (s *VpcService) DescribeVpnGatewayVpnAttachment(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpnConnection" request := map[string]interface{}{ "RegionId": s.client.RegionId, "VpnConnectionId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3541,20 +3326,15 @@ func (s *VpcService) VpnGatewayVpnAttachmentStateRefreshFunc(id string, failStat func (s *VpcService) DescribeVpcIpv4Gateway(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetIpv4GatewayAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "Ipv4GatewayId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3601,21 +3381,16 @@ func (s *VpcService) VpcIpv4GatewayStateRefreshFunc(id string, failStates []stri func (s *VpcService) GetVpcPrefixListEntries(id string) (objects []map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetVpcPrefixListEntries" request := map[string]interface{}{ "RegionId": s.client.RegionId, "PrefixListId": id, } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3653,20 +3428,15 @@ func (s *VpcService) GetVpcPrefixListEntries(id string) (objects []map[string]in func (s *VpcService) DescribeVpcPrefixList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListPrefixLists" request := map[string]interface{}{ "RegionId": s.client.RegionId, "PrefixListIds": []string{id}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3719,10 +3489,7 @@ func (s *VpcService) VpcPrefixListStateRefreshFunc(id string, failStates []strin func (s *VpcService) DescribeVpnGatewayVcoRoute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVcoRouteEntries" parts, err := ParseResourceId(id, 4) if err != nil { @@ -3737,11 +3504,9 @@ func (s *VpcService) DescribeVpnGatewayVcoRoute(id string) (object map[string]in } idExist := false for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3785,10 +3550,7 @@ func (s *VpcService) DescribeVpnGatewayVcoRoute(id string) (object map[string]in func (s *VpcService) DescribeVpcIpv4CidrBlock(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeVpcs" parts, err := ParseResourceId(id, 2) if err != nil { @@ -3802,11 +3564,9 @@ func (s *VpcService) DescribeVpcIpv4CidrBlock(id string) (object map[string]inte "PageSize": PageSizeLarge, } idExist := false - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3852,20 +3612,15 @@ func (s *VpcService) DescribeVpcIpv4CidrBlock(id string) (object map[string]inte func (s *VpcService) DescribeVpcPublicIpAddressPool(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "ListPublicIpAddressPools" request := map[string]interface{}{ "RegionId": s.client.RegionId, "PublicIpAddressPoolIds": []string{id}, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3918,10 +3673,7 @@ func (s *VpcService) VpcPublicIpAddressPoolStateRefreshFunc(id string, failState func (s *VpcService) DescribeVpcPublicIpAddressPoolCidrBlock(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { return object, WrapError(err) @@ -3932,11 +3684,9 @@ func (s *VpcService) DescribeVpcPublicIpAddressPoolCidrBlock(id string) (object "PublicIpAddressPoolId": parts[0], "CidrBlock": parts[1], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -3991,10 +3741,7 @@ func (s *VpcService) DescribeVpcNetworkAclAttachment(id string) (object map[stri var response map[string]interface{} action := "DescribeNetworkAcls" - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { @@ -4009,11 +3756,9 @@ func (s *VpcService) DescribeVpcNetworkAclAttachment(id string) (object map[stri } idExist := false - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4084,10 +3829,7 @@ func (s *VpcService) VpcNetworkAclAttachmentStateRefreshFunc(id string, failStat func (s *VpcService) DescribeVpcGatewayRouteTableAttachment(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetIpv4GatewayAttribute" parts, err := ParseResourceId(id, 2) if err != nil { @@ -4098,11 +3840,9 @@ func (s *VpcService) DescribeVpcGatewayRouteTableAttachment(id string) (object m "RegionId": s.client.RegionId, "Ipv4GatewayId": parts[1], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4151,10 +3891,7 @@ func (s *VpcService) DescribeExpressConnectGrantRuleToCen(id string) (object map var response map[string]interface{} action := "DescribeGrantRulesToCen" - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 3) if err != nil { @@ -4169,11 +3906,9 @@ func (s *VpcService) DescribeExpressConnectGrantRuleToCen(id string) (object map } idExist := false - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4213,10 +3948,7 @@ func (s *VpcService) DescribeExpressConnectGrantRuleToCen(id string) (object map } func (s *VpcService) DescribeExpressConnectRouterInterface(id string) (object map[string]interface{}, err error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return object, WrapError(err) - } + client := s.client request := map[string]interface{}{ "Filter.1.Key": "RouterInterfaceId", @@ -4226,11 +3958,9 @@ func (s *VpcService) DescribeExpressConnectRouterInterface(id string) (object ma var response map[string]interface{} action := "DescribeRouterInterfaces" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + resp, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4275,20 +4005,15 @@ func (s *VpcService) ExpressConnectRouterInterfaceStateRefreshFunc(id string, fa func (s *VpcService) DescribeHighDefinitionMonitorLogAttribute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeHighDefinitionMonitorLogAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "InstanceId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4311,10 +4036,7 @@ func (s *VpcService) DescribeHighDefinitionMonitorLogAttribute(id string) (objec } func (s *VpcService) DescribeVpcHaVipAttachment(id string) (object map[string]interface{}, err error) { - conn, err := s.client.NewVpcClient() - if err != nil { - return object, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { return object, WrapError(err) @@ -4328,11 +4050,9 @@ func (s *VpcService) DescribeVpcHaVipAttachment(id string) (object map[string]in var response map[string]interface{} action := "DescribeHaVips" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, request, &runtime) + resp, err := client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -4384,10 +4104,7 @@ func (s *VpcService) VpcHaVipAttachmentStateRefreshFunc(id string, failStates [] func (s *VpcService) ModifyExpressConnectPhysicalConnectionStatus(d *schema.ResourceData, status string) (err error) { var response map[string]interface{} - conn, err := s.client.NewVpcClient() - if err != nil { - return WrapError(err) - } + client := s.client switch status { case "Confirmed": @@ -4399,11 +4116,9 @@ func (s *VpcService) ModifyExpressConnectPhysicalConnectionStatus(d *schema.Reso "PhysicalConnectionId": d.Id(), } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(20*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, confirmedReq, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, confirmedReq, true) if err != nil { if NeedRetry(err) { wait() @@ -4442,11 +4157,9 @@ func (s *VpcService) ModifyExpressConnectPhysicalConnectionStatus(d *schema.Reso createPhysicalConnectionOccupancyOrderReq["PricingCycle"] = v } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(20*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, createPhysicalConnectionOccupancyOrderReq, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, createPhysicalConnectionOccupancyOrderReq, true) if err != nil { if NeedRetry(err) { wait() @@ -4482,11 +4195,9 @@ func (s *VpcService) ModifyExpressConnectPhysicalConnectionStatus(d *schema.Reso "PhysicalConnectionId": d.Id(), } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(20*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, canceledReq, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, canceledReq, true) if err != nil { if NeedRetry(err) { wait() @@ -4515,11 +4226,9 @@ func (s *VpcService) ModifyExpressConnectPhysicalConnectionStatus(d *schema.Reso "PhysicalConnectionId": d.Id(), } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(20*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2016-04-28"), StringPointer("AK"), nil, terminatedReq, &runtime) + response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, terminatedReq, true) if err != nil { if NeedRetry(err) { wait() diff --git a/website/docs/d/vpn_gateway_vco_routes.html.markdown b/website/docs/d/vpn_gateway_vco_routes.html.markdown index 18c24a4b85ac..fc9a4ca30ba9 100644 --- a/website/docs/d/vpn_gateway_vco_routes.html.markdown +++ b/website/docs/d/vpn_gateway_vco_routes.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Vpn Gateway Vco Routes to the user. --- -# alicloud\_vpn\_gateway\_vco\_routes +# alicloud_vpn_gateway_vco_routes This data source provides the Vpn Gateway Vco Routes of the current Alibaba Cloud user. --> **NOTE:** Available in v1.183.0+. +-> **NOTE:** Available since v1.183.0. ## Example Usage @@ -111,7 +111,7 @@ The following arguments are supported: * `route_entry_type` - (Optional, ForceNew) The Routing input type. Valid values: `custom`, `bgp`. * `status` - (Optional, ForceNew) The status of the vpn route entry. Valid values: `normal`, `published`. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: diff --git a/website/docs/d/vpn_gateway_vpn_attachments.html.markdown b/website/docs/d/vpn_gateway_vpn_attachments.html.markdown index fbc02668ed6f..300e14b13407 100644 --- a/website/docs/d/vpn_gateway_vpn_attachments.html.markdown +++ b/website/docs/d/vpn_gateway_vpn_attachments.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Vpn Gateway Vpn Attachments to the user. --- -# alicloud\_vpn\_gateway\_vpn\_attachments +# alicloud_vpn_gateway_vpn_attachments This data source provides the Vpn Gateway Vpn Attachments of the current Alibaba Cloud user. --> **NOTE:** Available in v1.181.0+. +-> **NOTE:** Available since v1.181.0+. ## Example Usage @@ -47,51 +47,49 @@ The following arguments are supported: * `status` - (Optional, ForceNew) The status of the resource. Valid values: `init`, `active`, `attaching`, `attached`, `detaching`, `financialLocked`, `provisioning`, `updating`, `upgrading`, `deleted`. * `vpn_gateway_id` - (Deprecated) The parameter 'vpn_gateway_id' has been deprecated from 1.194.0. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `names` - A list of Vpn Attachment names. * `attachments` - A list of Vpn Gateway Vpn Attachments. Each element contains the following attributes: - * `bgp_config` - The configurations of the BGP routing protocol. - * `local_asn` - The ASN on the Alibaba Cloud side. - * `local_bgp_ip` - The BGP IP address on the Alibaba Cloud side. - * `status` - The negotiation status of the BGP routing protocol. - * `tunnel_cidr` - The CIDR block of the IPsec tunnel. The CIDR block belongs to 169.254.0.0/16. The mask of the CIDR block is 30 bits in length. - * `create_time` - The creation time of the resource. - * `customer_gateway_id` - The ID of the customer gateway. - * `effect_immediately` - Indicates whether IPsec-VPN negotiations are initiated immediately. Valid values. - * `health_check_config` - The health check configurations. - * `dip` - The destination IP address. - * `status` - The status of the health check. - * `interval` - The interval between two consecutive health checks. Unit: seconds. - * `retry` - The maximum number of health check retries. - * `sip` - The source IP address. - * `enable` - Specifies whether to enable health checks. - * `policy` - (Optional) Whether to revoke the published route when the health check fails. - * `id` - The ID of the Vpn Attachment. - * `ike_config` - Configuration negotiated in the second stage. - * `remote_id` - The identifier of the peer. The default value is the IP address of the VPN gateway. The value can be a fully qualified domain name (FQDN) or an IP address. - * `ike_lifetime` - The IKE lifetime. Unit: seconds. - * `ike_pfs` - The DH group. - * `local_id` - The local ID, which supports the FQDN and IP formats. The current VPN gateway IP address is selected by default. The alicloud_cen_transit_router_vpn_attachment resource will not have a value until after it is created. - * `psk` - The pre-shared key. - * `ike_auth_alg` - The IKE authentication algorithm. - * `ike_enc_alg` - The IKE encryption algorithm. - * `ike_mode` - The IKE negotiation mode. - * `ike_version` - The version of the IKE protocol. - * `ipsec_config` - The configuration of Phase 2 negotiations. - * `ipsec_enc_alg` - The IPsec encryption algorithm. - * `ipsec_lifetime` - The IPsec lifetime. Unit: seconds. - * `ipsec_pfs` - The DH group. - * `ipsec_auth_alg` - The IPsec authentication algorithm. - * `local_subnet` - The CIDR block of the virtual private cloud (VPC). - * `network_type` - The network type. - * `remote_subnet` - The CIDR block of the on-premises data center. - * `status` - The status of the resource. - * `vpn_attachment_name` - The name of the IPsec-VPN connection. - * `vpn_connection_id` - The first ID of the resource. - * `connection_status` - The status of the IPsec-VPN connection. - * `enable_nat_traversal` - Allow NAT penetration. - * `enable_dpd` - Whether to enable the DPD (peer survival detection) function. + * `bgp_config` - The configurations of the BGP routing protocol. + * `local_asn` - The ASN on the Alibaba Cloud side. + * `local_bgp_ip` - The BGP IP address on the Alibaba Cloud side. + * `status` - The negotiation status of the BGP routing protocol. + * `tunnel_cidr` - The CIDR block of the IPsec tunnel. The CIDR block belongs to 169.254.0.0/16. The mask of the CIDR block is 30 bits in length. + * `create_time` - The creation time of the resource. + * `customer_gateway_id` - The ID of the customer gateway. + * `effect_immediately` - Indicates whether IPsec-VPN negotiations are initiated immediately. Valid values. + * `health_check_config` - The health check configurations. + * `dip` - The destination IP address. + * `status` - The status of the health check. + * `interval` - The interval between two consecutive health checks. Unit: seconds. + * `retry` - The maximum number of health check retries. + * `sip` - The source IP address. + * `enable` - Specifies whether to enable health checks. + * `policy` - (Optional) Whether to revoke the published route when the health check fails. + * `id` - The ID of the Vpn Attachment. + * `ike_config` - Configuration negotiated in the second stage. + * `remote_id` - The identifier of the peer. The default value is the IP address of the VPN gateway. The value can be a fully qualified domain name (FQDN) or an IP address. + * `ike_lifetime` - The IKE lifetime. Unit: seconds. + * `ike_pfs` - The DH group. + * `local_id` - The local ID, which supports the FQDN and IP formats. The current VPN gateway IP address is selected by default. The alicloud_cen_transit_router_vpn_attachment resource will not have a value until after it is created. + * `psk` - The pre-shared key. + * `ike_auth_alg` - The IKE authentication algorithm. + * `ike_enc_alg` - The IKE encryption algorithm. + * `ike_mode` - The IKE negotiation mode. + * `ike_version` - The version of the IKE protocol. + * `ipsec_config` - The configuration of Phase 2 negotiations. + * `ipsec_enc_alg` - The IPsec encryption algorithm. + * `ipsec_lifetime` - The IPsec lifetime. Unit: seconds. + * `ipsec_pfs` - The DH group. + * `ipsec_auth_alg` - The IPsec authentication algorithm. + * `local_subnet` - The CIDR block of the virtual private cloud (VPC). + * `network_type` - The network type. + * `remote_subnet` - The CIDR block of the on-premises data center. + * `status` - The status of the resource. + * `vpn_attachment_name` - The name of the IPsec-VPN connection. + * `vpn_connection_id` - The first ID of the resource. + * `connection_status` - The status of the IPsec-VPN connection. * `internet_ip` - The internet ip of the resource. The alicloud_cen_transit_router_vpn_attachment resource will not have a value until after it is created. \ No newline at end of file diff --git a/website/docs/d/vpn_ipsec_servers.html.markdown b/website/docs/d/vpn_ipsec_servers.html.markdown index 28ea81a3f339..63f34879e8c8 100644 --- a/website/docs/d/vpn_ipsec_servers.html.markdown +++ b/website/docs/d/vpn_ipsec_servers.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Vpn Ipsec Servers to the user. --- -# alicloud\_vpn\_ipsec\_servers +# alicloud_vpn_ipsec_servers This data source provides the Vpn Ipsec Servers of the current Alibaba Cloud user. --> **NOTE:** Available in v1.161.0+. +-> **NOTE:** Available since v1.161.0+. ## Example Usage @@ -43,38 +43,38 @@ The following arguments are supported: * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). * `vpn_gateway_id` - (Optional, ForceNew) The ID of the VPN gateway. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `names` - A list of Ipsec Server names. * `servers` - A list of Vpn Ipsec Servers. Each element contains the following attributes: - * `client_ip_pool` - The CIDR block of the client, which is assigned an access address to the virtual NIC of the client. - * `create_time` - The creation time of the IPsec server. T represents the delimiter, and Z represents UTC, which is World Standard Time. - * `effect_immediately` - Indicates whether the current IPsec tunnel is deleted and negotiations are reinitiated. - * `id` - The ID of the Ipsec Server. - * `idaas_instance_id` - The ID of the Identity as a Service (IDaaS) instance. - * `ike_config` - The configurations of Phase 1 negotiations. - * `ike_auth_alg` - The IKE authentication algorithm. - * `ike_enc_alg` - The IKE encryption algorithm. - * `ike_lifetime` - The IKE lifetime. Unit: seconds. - * `ike_mode` - The IKE negotiation mode. - * `ike_pfs` - Diffie-Hellman key exchange algorithm. - * `ike_version` - The IKE version. - * `local_id` - IPsec server identifier. Supports the format of FQDN and IP address. The public IP address of the VPN gateway is selected by default. - * `remote_id` - The peer identifier. Supports the format of FQDN and IP address, which is empty by default. - * `internet_ip` - The public IP address of the VPN gateway. - * `ipsec_config` - The configuration of Phase 2 negotiations. - * `ipsec_enc_alg` - IPsec encryption algorithm. - * `ipsec_lifetime` - IPsec survival time. Unit: seconds. - * `ipsec_pfs` - Diffie-Hellman key exchange algorithm. - * `ipsec_auth_alg` - IPsec authentication algorithm. - * `ipsec_server_id` - The ID of the IPsec server. - * `ipsec_server_name` - The name of the IPsec server. - * `local_subnet` - Local network segment: the network segment on The VPC side that needs to be interconnected with the client network segment. - * `max_connections` - The number of SSL connections of the VPN gateway. SSL-VPN the number of SSL connections shared with the IPsec server. For example, if the number of SSL connections is 5 and you have three SSL clients connected to the SSL-VPN, you can also use two clients to connect to the IPsec server. - * `multi_factor_auth_enabled` - Whether the two-factor authentication function has been turned on. - * `online_client_count` - The number of clients that have connected to the IPsec server. - * `psk` - The pre-shared key. - * `psk_enabled` - Whether to enable the pre-shared key authentication method. The value is only `true`, which indicates that the pre-shared key authentication method is enabled. - * `vpn_gateway_id` - The ID of the VPN gateway. \ No newline at end of file + * `client_ip_pool` - The CIDR block of the client, which is assigned an access address to the virtual NIC of the client. + * `create_time` - The creation time of the IPsec server. T represents the delimiter, and Z represents UTC, which is World Standard Time. + * `effect_immediately` - Indicates whether the current IPsec tunnel is deleted and negotiations are reinitiated. + * `id` - The ID of the Ipsec Server. + * `idaas_instance_id` - The ID of the Identity as a Service (IDaaS) instance. + * `ike_config` - The configurations of Phase 1 negotiations. + * `ike_auth_alg` - The IKE authentication algorithm. + * `ike_enc_alg` - The IKE encryption algorithm. + * `ike_lifetime` - The IKE lifetime. Unit: seconds. + * `ike_mode` - The IKE negotiation mode. + * `ike_pfs` - Diffie-Hellman key exchange algorithm. + * `ike_version` - The IKE version. + * `local_id` - IPsec server identifier. Supports the format of FQDN and IP address. The public IP address of the VPN gateway is selected by default. + * `remote_id` - The peer identifier. Supports the format of FQDN and IP address, which is empty by default. + * `internet_ip` - The public IP address of the VPN gateway. + * `ipsec_config` - The configuration of Phase 2 negotiations. + * `ipsec_enc_alg` - IPsec encryption algorithm. + * `ipsec_lifetime` - IPsec survival time. Unit: seconds. + * `ipsec_pfs` - Diffie-Hellman key exchange algorithm. + * `ipsec_auth_alg` - IPsec authentication algorithm. + * `ipsec_server_id` - The ID of the IPsec server. + * `ipsec_server_name` - The name of the IPsec server. + * `local_subnet` - Local network segment: the network segment on The VPC side that needs to be interconnected with the client network segment. + * `max_connections` - The number of SSL connections of the VPN gateway. SSL-VPN the number of SSL connections shared with the IPsec server. For example, if the number of SSL connections is 5 and you have three SSL clients connected to the SSL-VPN, you can also use two clients to connect to the IPsec server. + * `multi_factor_auth_enabled` - Whether the two-factor authentication function has been turned on. + * `online_client_count` - The number of clients that have connected to the IPsec server. + * `psk` - The pre-shared key. + * `psk_enabled` - Whether to enable the pre-shared key authentication method. The value is only `true`, which indicates that the pre-shared key authentication method is enabled. + * `vpn_gateway_id` - The ID of the VPN gateway. \ No newline at end of file