diff --git a/alicloud/data_source_alicloud_governance_baselines.go b/alicloud/data_source_alicloud_governance_baselines.go index 4d459d2aa3ed..6bdf3e653480 100644 --- a/alicloud/data_source_alicloud_governance_baselines.go +++ b/alicloud/data_source_alicloud_governance_baselines.go @@ -7,7 +7,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" @@ -71,18 +70,13 @@ func dataSourceAliCloudGovernanceBaselineRead(d *schema.ResourceData, meta inter var response map[string]interface{} var query map[string]interface{} action := "ListAccountFactoryBaselines" - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) query = make(map[string]interface{}) query["RegionId"] = client.RegionId - 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, true) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_governance_account.go b/alicloud/resource_alicloud_governance_account.go index 4be865fe0e25..dd83d5496e6a 100644 --- a/alicloud/resource_alicloud_governance_account.go +++ b/alicloud/resource_alicloud_governance_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" @@ -93,10 +92,7 @@ func resourceAliCloudGovernanceAccountCreate(d *schema.ResourceData, meta interf var request map[string]interface{} var response map[string]interface{} query := make(map[string]interface{}) - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) if v, ok := d.GetOk("account_id"); ok { request["AccountUid"] = v @@ -143,11 +139,9 @@ func resourceAliCloudGovernanceAccountCreate(d *schema.ResourceData, meta interf baselineItemsMaps = append(baselineItemsMaps, baselineItem) } request["BaselineItems"] = baselineItemsMaps - 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -229,10 +223,7 @@ func resourceAliCloudGovernanceAccountUpdate(d *schema.ResourceData, meta interf update := false action := "EnrollAccount" - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) query = make(map[string]interface{}) request["AccountUid"] = d.Id() @@ -262,11 +253,9 @@ func resourceAliCloudGovernanceAccountUpdate(d *schema.ResourceData, meta interf request["BaselineId"] = d.Get("baseline_id") 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_governance_baseline.go b/alicloud/resource_alicloud_governance_baseline.go index b10a13a64fbe..540b16c99a5b 100644 --- a/alicloud/resource_alicloud_governance_baseline.go +++ b/alicloud/resource_alicloud_governance_baseline.go @@ -6,7 +6,6 @@ import ( "log" "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" @@ -69,10 +68,7 @@ func resourceAliCloudGovernanceBaselineCreate(d *schema.ResourceData, meta inter var request map[string]interface{} var response map[string]interface{} query := make(map[string]interface{}) - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) query["RegionId"] = client.RegionId @@ -95,11 +91,9 @@ func resourceAliCloudGovernanceBaselineCreate(d *schema.ResourceData, meta inter if v, ok := d.GetOk("description"); ok { request["Description"] = v } - 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -170,10 +164,7 @@ func resourceAliCloudGovernanceBaselineUpdate(d *schema.ResourceData, meta inter var query map[string]interface{} update := false action := "UpdateAccountFactoryBaseline" - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) query = make(map[string]interface{}) query["BaselineId"] = d.Id() @@ -205,11 +196,9 @@ func resourceAliCloudGovernanceBaselineUpdate(d *schema.ResourceData, meta inter } 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -235,19 +224,14 @@ func resourceAliCloudGovernanceBaselineDelete(d *schema.ResourceData, meta inter var request map[string]interface{} var response map[string]interface{} query := make(map[string]interface{}) - conn, err := client.NewGovernanceClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) query["BaselineId"] = d.Id() query["RegionId"] = client.RegionId - 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/service_alicloud_governance_v2.go b/alicloud/service_alicloud_governance_v2.go index 94321dbd1826..2d5c2b51d880 100644 --- a/alicloud/service_alicloud_governance_v2.go +++ b/alicloud/service_alicloud_governance_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" ) @@ -23,20 +22,14 @@ func (s *GovernanceServiceV2) DescribeGovernanceBaseline(id string) (object map[ var response map[string]interface{} var query map[string]interface{} action := "GetAccountFactoryBaseline" - conn, err := client.NewGovernanceClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["BaselineId"] = id query["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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -91,20 +84,14 @@ func (s *GovernanceServiceV2) DescribeGovernanceAccount(id string) (object map[s var response map[string]interface{} var query map[string]interface{} action := "GetEnrolledAccount" - conn, err := client.NewGovernanceClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) request["AccountUid"] = id 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-01-20"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("governance", "2021-01-20", action, query, request, true) if err != nil { if NeedRetry(err) {