diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index e47b117806b3..ae9275c0dff2 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -2015,35 +2015,6 @@ func (client *AliyunClient) WithHbaseClient(do func(*hbase.Client) (interface{}, return do(client.hbaseconn) } -func (client *AliyunClient) NewAdbClient() (*rpc.Client, error) { - productCode := "ads" - endpoint := "" - if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { - if v := client.config.AdbEndpoint; v != "" { - client.config.Endpoints.Store(productCode, v) - } - if err := client.loadEndpoint(productCode); err != nil { - return nil, err - } - } - if v, exist := client.config.Endpoints.Load(productCode); exist && v.(string) != "" { - endpoint = v.(string) - } - if endpoint == "" { - return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) - } - - sdkConfig := client.teaSdkConfig - sdkConfig.SetEndpoint(endpoint) - - conn, err := rpc.NewClient(&sdkConfig) - if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err) - } - - return conn, nil -} - func (client *AliyunClient) WithAdbClient(do func(*adb.Client) (interface{}, error)) (interface{}, error) { // Initialize the adb client if necessary if client.adbconn == nil { @@ -2995,30 +2966,6 @@ func (client *AliyunClient) NewHcsSgwClient() (*rpc.Client, error) { } return conn, nil } - -func (client *AliyunClient) NewAdsClient() (*rpc.Client, error) { - productCode := "ads" - endpoint := "" - if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { - if err := client.loadEndpoint(productCode); err != nil { - return nil, err - } - } - if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" { - endpoint = v.(string) - } - if endpoint == "" { - return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) - } - sdkConfig := client.teaSdkConfig - sdkConfig.SetEndpoint(endpoint) - conn, err := rpc.NewClient(&sdkConfig) - if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err) - } - return conn, nil -} - func (client *AliyunClient) NewDdoscooClient() (*rpc.Client, error) { productCode := "ddoscoo" endpoint := "" diff --git a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go index a6d8740044e1..84b4461f65b8 100644 --- a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go +++ b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.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" @@ -182,20 +181,15 @@ func dataSourceAlicloudAdbDbClusterLakeVersionsRead(d *schema.ResourceData, meta } } - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } var objects []interface{} var response map[string]interface{} + var err error for { action := "DescribeDBClusters" - 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("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -203,7 +197,6 @@ func dataSourceAlicloudAdbDbClusterLakeVersionsRead(d *schema.ResourceData, meta } return resource.NonRetryableError(err) } - response = resp addDebug(action, response, request) return nil }) diff --git a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go index 796739aecfe9..e0b58d01eed6 100644 --- a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go +++ b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go @@ -109,17 +109,16 @@ variable "name" { data "alicloud_resource_manager_resource_groups" "default" {} -data "alicloud_zones" "default" { - available_resource_creation = "VSwitch" +data "alicloud_adb_zones" "default" { } data "alicloud_vpcs" "default" { - name_regex = "^default-NODELETING$" + name_regex = "^default-NODELETING$" } data "alicloud_vswitches" "default" { - vpc_id = data.alicloud_vpcs.default.ids.0 - zone_id = data.alicloud_zones.default.ids[length(data.alicloud_zones.default.ids) - 1] + vpc_id = data.alicloud_vpcs.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 } resource "alicloud_adb_db_cluster_lake_version" "default" { @@ -129,7 +128,7 @@ resource "alicloud_adb_db_cluster_lake_version" "default" { storage_resource = "0ACU" vswitch_id = data.alicloud_vswitches.default.ids.0 vpc_id = data.alicloud_vpcs.default.ids.0 - zone_id = data.alicloud_zones.default.ids[length(data.alicloud_zones.default.ids) - 1] + zone_id = data.alicloud_adb_zones.default.ids.0 } data "alicloud_adb_db_cluster_lake_versions" "default" { diff --git a/alicloud/data_source_alicloud_adb_db_clusters.go b/alicloud/data_source_alicloud_adb_db_clusters.go index 9e2cc3a1cacd..6b389eb81151 100644 --- a/alicloud/data_source_alicloud_adb_db_clusters.go +++ b/alicloud/data_source_alicloud_adb_db_clusters.go @@ -6,7 +6,6 @@ import ( "strings" "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/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -313,14 +312,9 @@ func dataSourceAlicloudAdbDbClustersRead(d *schema.ResourceData, meta interface{ } } var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_adb_db_clusters", action, AlibabaCloudSdkGoERROR) } diff --git a/alicloud/data_source_alicloud_adb_resource_groups.go b/alicloud/data_source_alicloud_adb_resource_groups.go index 460e764340a1..f6d876278bd4 100644 --- a/alicloud/data_source_alicloud_adb_resource_groups.go +++ b/alicloud/data_source_alicloud_adb_resource_groups.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" @@ -99,18 +98,13 @@ func dataSourceAlicloudAdbResourceGroupsRead(d *schema.ResourceData, meta interf } } - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } var objects []interface{} var response map[string]interface{} + var err error action := "DescribeDBResourceGroup" - 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -118,7 +112,6 @@ func dataSourceAlicloudAdbResourceGroupsRead(d *schema.ResourceData, meta interf } return resource.NonRetryableError(err) } - response = resp addDebug(action, response, request) return nil }) diff --git a/alicloud/resource_alicloud_adb_db_cluster.go b/alicloud/resource_alicloud_adb_db_cluster.go index b808868c8b23..a49773a65794 100644 --- a/alicloud/resource_alicloud_adb_db_cluster.go +++ b/alicloud/resource_alicloud_adb_db_cluster.go @@ -8,7 +8,6 @@ import ( "strings" "time" - 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" @@ -214,12 +213,9 @@ func resourceAliCloudAdbDbClusterCreate(d *schema.ResourceData, meta interface{} client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error action := "CreateDBCluster" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } if v, ok := d.GetOk("compute_resource"); ok { request["ComputeResource"] = v } @@ -322,12 +318,10 @@ func resourceAliCloudAdbDbClusterCreate(d *schema.ResourceData, meta interface{} request["EnableSSL"] = v } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) request["ClientToken"] = buildClientToken("CreateDBCluster") 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -433,6 +427,7 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error d.Partial(true) if d.HasChange("tags") { @@ -448,13 +443,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["DBClusterDescription"] = d.Get("description") action := "ModifyDBClusterDescription" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -479,13 +470,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["MaintainTime"] = d.Get("maintain_time") action := "ModifyDBClusterMaintainTime" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -510,13 +497,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["NewResourceGroupId"] = d.Get("resource_group_id") action := "ModifyDBClusterResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -562,14 +545,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} if update { action := "ModifyDBClusterPayType" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"OperationDenied.OrderProcessing"}) { wait() @@ -617,13 +595,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } if update { action := "ModifyAutoRenewAttribute" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -658,17 +632,13 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterAccessWhiteListReq["SecurityIps"] = convertListToCommaSeparate(d.Get("security_ips").(*schema.Set).List()) if update { action := "ModifyDBClusterAccessWhiteList" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } if modifyDBClusterAccessWhiteListReq["SecurityIps"].(string) == "" { modifyDBClusterAccessWhiteListReq["SecurityIps"] = LOCAL_HOST_IP } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterAccessWhiteListReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterAccessWhiteListReq, false) if err != nil { if NeedRetry(err) { wait() @@ -734,13 +704,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing"}) { wait() @@ -795,13 +761,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { // There is service bug and needs checking IncorrectDBInstanceState. // If the bug is fixed, the IncorrectDBInstanceState checking can be removed. @@ -849,13 +811,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { // There is service bug and needs checking IncorrectDBInstanceState. // If the bug is fixed, the IncorrectDBInstanceState checking can be removed. @@ -900,16 +858,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} if update { action := "ModifyDBClusterSSL" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterSSLReq, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterSSLReq, false) if err != nil { if NeedRetry(err) { wait() @@ -948,17 +899,14 @@ func resourceAliCloudAdbDbClusterDelete(d *schema.ResourceData, meta interface{} adbService := AdbService{client} action := "DeleteDBCluster" var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "DBClusterId": d.Id(), } var taskId string 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("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing"}) { wait() diff --git a/alicloud/resource_alicloud_adb_db_cluster_lake_version.go b/alicloud/resource_alicloud_adb_db_cluster_lake_version.go index 78bf9b2da252..d65e6e661596 100644 --- a/alicloud/resource_alicloud_adb_db_cluster_lake_version.go +++ b/alicloud/resource_alicloud_adb_db_cluster_lake_version.go @@ -150,13 +150,9 @@ func resourceAliCloudAdbDbClusterLakeVersionCreate(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error action := "CreateDBCluster" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - request["RegionId"] = client.RegionId request["DBClusterVersion"] = d.Get("db_cluster_version") request["VPCId"] = d.Get("vpc_id") @@ -194,11 +190,9 @@ func resourceAliCloudAdbDbClusterLakeVersionCreate(d *schema.ResourceData, meta request["RestoreToTime"] = v } - 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("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -277,6 +271,7 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error d.Partial(true) update := false @@ -297,18 +292,11 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { - if NeedRetry(err) { + if NeedRetry(err) || IsExpectedErrors(err, []string{"OperationDenied.OrderProcessing"}) { wait() return resource.RetryableError(err) } @@ -345,16 +333,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyClusterAccessWhiteList" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyClusterAccessWhiteListReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyClusterAccessWhiteListReq, false) if err != nil { if NeedRetry(err) { wait() @@ -392,16 +373,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBClusterDescription" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyDBClusterDescriptionReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyDBClusterDescriptionReq, false) if err != nil { if NeedRetry(err) { wait() @@ -439,16 +413,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBClusterResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyDBClusterResourceGroupReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyDBClusterResourceGroupReq, false) if err != nil { if NeedRetry(err) { wait() @@ -481,12 +448,7 @@ func resourceAliCloudAdbDbClusterLakeVersionDelete(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) action := "DeleteDBCluster" var response map[string]interface{} - - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - + var err error request := map[string]interface{}{ "DBClusterId": d.Id(), "RegionId": client.RegionId, @@ -496,7 +458,7 @@ func resourceAliCloudAdbDbClusterLakeVersionDelete(d *schema.ResourceData, meta 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("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_adb_db_cluster_test.go b/alicloud/resource_alicloud_adb_db_cluster_test.go index 29da808f64ce..6b085fa9497c 100644 --- a/alicloud/resource_alicloud_adb_db_cluster_test.go +++ b/alicloud/resource_alicloud_adb_db_cluster_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -40,14 +39,8 @@ func testSweepAdbDbInstances(region string) error { request["PageSize"] = PageSizeLarge request["PageNumber"] = 1 var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { log.Println(WrapErrorf(err, DataDefaultErrorMsg, "alicloud_adb_db_clusters", action, AlibabaCloudSdkGoERROR)) break @@ -78,17 +71,12 @@ func testSweepAdbDbInstances(region string) error { } log.Printf("[INFO] Deleting adb Instance: %s (%s)", name, id) action := "DeleteDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - log.Println(WrapError(err)) - break - } request := map[string]interface{}{ "DBClusterId": id, } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_adb_lake_account.go b/alicloud/resource_alicloud_adb_lake_account.go index 662bb8ab7b5c..9fc0a16887fa 100644 --- a/alicloud/resource_alicloud_adb_lake_account.go +++ b/alicloud/resource_alicloud_adb_lake_account.go @@ -9,7 +9,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" @@ -111,11 +110,8 @@ func resourceAliCloudAdbLakeAccountCreate(d *schema.ResourceData, meta interface action := "CreateAccount" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query["AccountName"] = d.Get("account_name") query["DBClusterId"] = d.Get("db_cluster_id") @@ -127,11 +123,9 @@ func resourceAliCloudAdbLakeAccountCreate(d *schema.ResourceData, meta interface request["AccountType"] = v } request["AccountPassword"] = d.Get("account_password") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -218,15 +212,12 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface client := meta.(*connectivity.AliyunClient) var request map[string]interface{} var response map[string]interface{} + var err error var query map[string]interface{} update := false d.Partial(true) parts := strings.Split(d.Id(), ":") action := "ModifyAccountDescription" - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DBClusterId"] = parts[0] @@ -237,11 +228,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -261,10 +250,6 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface update = false parts = strings.Split(d.Id(), ":") action = "ResetAccountPassword" - conn, err = client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] @@ -279,11 +264,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -304,10 +287,6 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface update = false parts = strings.Split(d.Id(), ":") action = "ModifyAccountPrivileges" - conn, err = client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DBClusterId"] = parts[0] @@ -341,11 +320,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -373,20 +350,15 @@ func resourceAliCloudAdbLakeAccountDelete(d *schema.ResourceData, meta interface action := "DeleteAccount" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_adb_resource_group.go b/alicloud/resource_alicloud_adb_resource_group.go index e209f76f07e6..5bf9f3f417f2 100644 --- a/alicloud/resource_alicloud_adb_resource_group.go +++ b/alicloud/resource_alicloud_adb_resource_group.go @@ -6,7 +6,6 @@ import ( "strings" "time" - 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" @@ -77,13 +76,9 @@ func resourceAliCloudAdbResourceGroup() *schema.Resource { func resourceAliCloudAdbResourceGroupCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "CreateDBResourceGroup" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - request["DBClusterId"] = d.Get("db_cluster_id") request["GroupName"] = d.Get("group_name") @@ -95,11 +90,9 @@ func resourceAliCloudAdbResourceGroupCreate(d *schema.ResourceData, meta interfa request["NodeNum"] = v } - 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if IsExpectedErrors(err, []string{"ResourceNotEnough"}) || NeedRetry(err) { wait() @@ -190,16 +183,9 @@ func resourceAliCloudAdbResourceGroupUpdate(d *schema.ResourceData, meta interfa if update { action := "ModifyDBResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if IsExpectedErrors(err, []string{"ResourceNotEnough"}) || NeedRetry(err) { wait() @@ -223,12 +209,6 @@ func resourceAliCloudAdbResourceGroupDelete(d *schema.ResourceData, meta interfa client := meta.(*connectivity.AliyunClient) action := "DeleteDBResourceGroup" var response map[string]interface{} - - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - parts, err := ParseResourceId(d.Id(), 2) if err != nil { return WrapError(err) @@ -239,11 +219,9 @@ func resourceAliCloudAdbResourceGroupDelete(d *schema.ResourceData, meta interfa "GroupName": parts[1], } - 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_adb.go b/alicloud/service_alicloud_adb.go index 4c5b3a005d5c..6ae474d9d5f9 100644 --- a/alicloud/service_alicloud_adb.go +++ b/alicloud/service_alicloud_adb.go @@ -584,10 +584,7 @@ func (s *AdbService) AdbTaskStateRefreshFunc(id, taskId string) resource.StateRe func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } + action := "DescribeAutoRenewAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -595,7 +592,7 @@ func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]in } runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { err = WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) return @@ -618,10 +615,6 @@ func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]in func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusterAccessWhiteList" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -629,7 +622,7 @@ func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[str } runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidDBCluster.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("AnalyticdbForMysql3.0DbCluster", id)), NotFoundMsg, ProviderERROR) @@ -660,14 +653,10 @@ func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[str } func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string) error { - + var response map[string]interface{} + var err error if d.HasChange("tags") { added, removed := parsingTags(d) - conn, err := s.client.NewAdsClient() - if err != nil { - return WrapError(err) - } - removedTagKeys := make([]string, 0) for _, v := range removed { if !ignoredTags(v, "") { @@ -685,8 +674,8 @@ func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string request[fmt.Sprintf("TagKey.%d", i+1)] = key } 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("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err = resource.Retry(10*time.Minute, func() *resource.RetryError { + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -717,8 +706,8 @@ func (s *AdbService) 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("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err = resource.Retry(10*time.Minute, func() *resource.RetryError { + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -741,18 +730,12 @@ func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string func (s *AdbService) DescribeAdbDbCluster(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusterAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DBClusterId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidDBCluster.NotFound", "InvalidDBClusterId.NotFoundError"}) { err = WrapErrorf(Error(GetNotFoundMessage("AdbDbCluster", id)), NotFoundMsg, ProviderERROR) @@ -779,18 +762,12 @@ func (s *AdbService) DescribeAdbDbCluster(id string) (object map[string]interfac func (s *AdbService) DescribeDBClusters(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusters" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DBClusterIds": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { err = WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) return @@ -834,12 +811,6 @@ func (s *AdbService) AdbDbClusterStateRefreshFunc(id string, stateField string, func (s *AdbService) DescribeAdbDbClusterLakeVersion(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBClusterAttribute" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - request := map[string]interface{}{ "DBClusterId": id, } @@ -849,7 +820,7 @@ func (s *AdbService) DescribeAdbDbClusterLakeVersion(id string) (object map[stri 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("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -914,12 +885,6 @@ func (s *AdbService) AdbDbClusterLakeVersionStateRefreshFunc(d *schema.ResourceD func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeClusterAccessWhiteList" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - request := map[string]interface{}{ "DBClusterId": id, } @@ -928,7 +893,7 @@ func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[strin 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("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -964,12 +929,6 @@ func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[strin func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBResourceGroup" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - parts, err := ParseResourceId(id, 2) if err != nil { return object, WrapError(err) @@ -985,7 +944,7 @@ func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]inte 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1030,21 +989,13 @@ func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]inte func (s *AdbService) DescribeAdbDbClusterSSL(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBClusterSSL" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - request := map[string]interface{}{ "DBClusterId": id, } - 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("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"ADBVersionNotSupport"}) || NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_adb_v2.go b/alicloud/service_alicloud_adb_v2.go index 9ab4d2534b9d..fd0da61d9533 100644 --- a/alicloud/service_alicloud_adb_v2.go +++ b/alicloud/service_alicloud_adb_v2.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" ) @@ -27,21 +26,15 @@ func (s *AdbServiceV2) DescribeAdbLakeAccount(id string) (object map[string]inte err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } action := "DescribeAccountAllPrivileges" - conn, err := client.NewAdbClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] request["RegionId"] = client.RegionId - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -73,20 +66,14 @@ func (s *AdbServiceV2) DescribeDescribeAccounts(id string) (object map[string]in err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } action := "DescribeAccounts" - conn, err := client.NewAdbClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, true) if err != nil { if NeedRetry(err) { diff --git a/website/docs/d/adb_db_cluster_lake_versions.html.markdown b/website/docs/d/adb_db_cluster_lake_versions.html.markdown index 36739a7cae98..442d46b49e85 100644 --- a/website/docs/d/adb_db_cluster_lake_versions.html.markdown +++ b/website/docs/d/adb_db_cluster_lake_versions.html.markdown @@ -11,15 +11,41 @@ description: |- This data source provides the Adb DBCluster Lake Versions of the current Alibaba Cloud user. --> **NOTE:** Available in v1.190.0+. +-> **NOTE:** Available since v1.190.0. ## Example Usage Basic Usage ```terraform +provider "alicloud" { + region = "ap-southeast-1" +} + +data "alicloud_adb_zones" "default" { +} + +data "alicloud_vpcs" "default" { + name_regex = "^default-NODELETING$" +} + +data "alicloud_vswitches" "default" { + vpc_id = data.alicloud_vpcs.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 +} + +resource "alicloud_adb_db_cluster_lake_version" "default" { + db_cluster_version = "5.0" + vpc_id = data.alicloud_vpcs.default.ids.0 + vswitch_id = data.alicloud_vswitches.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 + compute_resource = "16ACU" + storage_resource = "0ACU" + payment_type = "PayAsYouGo" + enable_default_resource_group = false +} data "alicloud_adb_db_cluster_lake_versions" "ids" { - ids = ["example_id"] + ids = [alicloud_adb_db_cluster_lake_version.default.id] } output "adb_db_cluster_lake_version_id_1" { value = data.alicloud_adb_db_cluster_lake_versions.ids.versions.0.id @@ -36,29 +62,29 @@ The following arguments are supported: * `resource_group_id` - (Optional, ForceNew) The ID of the resource group. * `status` - (Optional, ForceNew) The status of the resource. Valid values: `Preparing`, `Creating`, `Restoring`, `Running`, `Deleting`, `ClassChanging`, `NetAddressCreating`, `NetAddressDeleting`. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `versions` - A list of Adb Db Clusters. Each element contains the following attributes: - * `id` - The ID of the DBCluster. - * `db_cluster_id` - The ID of the DBCluster. - * `commodity_code` - The name of the service. - * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. - * `connection_string` - The endpoint of the cluster. - * `create_time` - The CreateTime of the ADB cluster. - * `db_cluster_version` - The db cluster version. - * `engine` - The engine of the database. - * `engine_version` - The engine version of the database. - * `expire_time` - The time when the cluster expires. - * `expired` - Indicates whether the cluster has expired. - * `lock_mode` - The lock mode of the cluster. - * `lock_reason` - The reason why the cluster is locked. - * `payment_type` - The payment type of the resource. - * `port` - The port that is used to access the cluster. - * `status` - The status of the resource. - * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. - * `vpc_id` - The vpc id. - * `vswitch_id` - The vswitch id. - * `zone_id` - The zone ID of the resource. - * `resource_group_id` - The ID of the resource group. \ No newline at end of file + * `id` - The ID of the DBCluster. + * `db_cluster_id` - The ID of the DBCluster. + * `commodity_code` - The name of the service. + * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. + * `connection_string` - The endpoint of the cluster. + * `create_time` - The CreateTime of the ADB cluster. + * `db_cluster_version` - The db cluster version. + * `engine` - The engine of the database. + * `engine_version` - The engine version of the database. + * `expire_time` - The time when the cluster expires. + * `expired` - Indicates whether the cluster has expired. + * `lock_mode` - The lock mode of the cluster. + * `lock_reason` - The reason why the cluster is locked. + * `payment_type` - The payment type of the resource. + * `port` - The port that is used to access the cluster. + * `status` - The status of the resource. + * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. + * `vpc_id` - The vpc id. + * `vswitch_id` - The vswitch id. + * `zone_id` - The zone ID of the resource. + * `resource_group_id` - The ID of the resource group. \ No newline at end of file