From 5a4443d625fbff131d10335910fa417c5142142d Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Sat, 21 Dec 2024 00:09:37 +0800 Subject: [PATCH] SDDP: Improves the invoking sddp api method and supports refreshing credential automatically --- alicloud/data_source_alicloud_sddp_configs.go | 10 +--- .../data_source_alicloud_sddp_data_limits.go | 10 +--- .../data_source_alicloud_sddp_instances.go | 10 +--- alicloud/data_source_alicloud_sddp_rules.go | 10 +--- alicloud/resource_alicloud_sddp_config.go | 15 ++---- alicloud/resource_alicloud_sddp_data_limit.go | 22 +++----- .../resource_alicloud_sddp_data_limit_test.go | 24 ++++++--- alicloud/resource_alicloud_sddp_instance.go | 25 +++------ alicloud/resource_alicloud_sddp_rule.go | 40 +++----------- alicloud/service_alicloud_sddp.go | 39 +++----------- website/docs/d/sddp_configs.html.markdown | 24 ++++----- website/docs/d/sddp_data_limits.html.markdown | 28 +++++----- website/docs/d/sddp_instances.html.markdown | 24 ++++----- website/docs/d/sddp_rules.html.markdown | 52 +++++++++---------- 14 files changed, 123 insertions(+), 210 deletions(-) diff --git a/alicloud/data_source_alicloud_sddp_configs.go b/alicloud/data_source_alicloud_sddp_configs.go index 3f1a85c470dd..c56211f88970 100644 --- a/alicloud/data_source_alicloud_sddp_configs.go +++ b/alicloud/data_source_alicloud_sddp_configs.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "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" @@ -89,15 +88,10 @@ func dataSourceAlicloudSddpConfigsRead(d *schema.ResourceData, meta interface{}) } } var response map[string]interface{} - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error 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-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_sddp_data_limits.go b/alicloud/data_source_alicloud_sddp_data_limits.go index 8f42c8d2cb38..9c250e79b28f 100644 --- a/alicloud/data_source_alicloud_sddp_data_limits.go +++ b/alicloud/data_source_alicloud_sddp_data_limits.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" @@ -119,16 +118,11 @@ func dataSourceAlicloudSddpDataLimitsRead(d *schema.ResourceData, meta interface } } var response map[string]interface{} - conn, err := client.NewSddpClient() - 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_sddp_instances.go b/alicloud/data_source_alicloud_sddp_instances.go index e6d5cc0af2f2..aebe67186f79 100644 --- a/alicloud/data_source_alicloud_sddp_instances.go +++ b/alicloud/data_source_alicloud_sddp_instances.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" @@ -77,15 +76,10 @@ func dataSourceAlicloudSddpInstancesRead(d *schema.ResourceData, meta interface{ action := "DescribeUserStatus" request := make(map[string]interface{}) var response map[string]interface{} - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error 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-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_sddp_rules.go b/alicloud/data_source_alicloud_sddp_rules.go index 2a4643529897..08bd8117b083 100644 --- a/alicloud/data_source_alicloud_sddp_rules.go +++ b/alicloud/data_source_alicloud_sddp_rules.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" @@ -252,16 +251,11 @@ func dataSourceAlicloudSddpRulesRead(d *schema.ResourceData, meta interface{}) e } } var response map[string]interface{} - conn, err := client.NewSddpClient() - 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_sddp_config.go b/alicloud/resource_alicloud_sddp_config.go index ff9ad3d8370b..cebc4fc93903 100644 --- a/alicloud/resource_alicloud_sddp_config.go +++ b/alicloud/resource_alicloud_sddp_config.go @@ -5,7 +5,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" @@ -52,10 +51,7 @@ func resourceAlicloudSddpConfigCreate(d *schema.ResourceData, meta interface{}) var response map[string]interface{} action := "CreateConfig" request := make(map[string]interface{}) - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error if v, ok := d.GetOk("code"); ok { request["Code"] = v } @@ -70,7 +66,7 @@ func resourceAlicloudSddpConfigCreate(d *schema.ResourceData, meta interface{}) } 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("2019-01-03"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -109,10 +105,7 @@ func resourceAlicloudSddpConfigRead(d *schema.ResourceData, meta interface{}) er } func resourceAlicloudSddpConfigUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error var response map[string]interface{} update := false request := map[string]interface{}{ @@ -137,7 +130,7 @@ func resourceAlicloudSddpConfigUpdate(d *schema.ResourceData, meta interface{}) action := "CreateConfig" 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("2019-01-03"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_sddp_data_limit.go b/alicloud/resource_alicloud_sddp_data_limit.go index e762a20ae75e..449a3d332983 100644 --- a/alicloud/resource_alicloud_sddp_data_limit.go +++ b/alicloud/resource_alicloud_sddp_data_limit.go @@ -5,7 +5,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" @@ -108,10 +107,7 @@ func resourceAlicloudSddpDataLimitCreate(d *schema.ResourceData, meta interface{ var response map[string]interface{} action := "CreateDataLimit" request := make(map[string]interface{}) - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error if v, ok := d.GetOkExists("audit_status"); ok { request["AuditStatus"] = v } @@ -141,7 +137,7 @@ func resourceAlicloudSddpDataLimitCreate(d *schema.ResourceData, meta interface{ } 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("2019-01-03"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -214,13 +210,10 @@ func resourceAlicloudSddpDataLimitUpdate(d *schema.ResourceData, meta interface{ request["Lang"] = v } action := "ModifyDataLimit" - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error 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("2019-01-03"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -241,10 +234,7 @@ func resourceAlicloudSddpDataLimitDelete(d *schema.ResourceData, meta interface{ client := meta.(*connectivity.AliyunClient) action := "DeleteDataLimit" var response map[string]interface{} - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "Id": d.Id(), } @@ -254,7 +244,7 @@ func resourceAlicloudSddpDataLimitDelete(d *schema.ResourceData, meta interface{ } 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-01-03"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_sddp_data_limit_test.go b/alicloud/resource_alicloud_sddp_data_limit_test.go index f84207dc0afd..2a90ac3c2587 100644 --- a/alicloud/resource_alicloud_sddp_data_limit_test.go +++ b/alicloud/resource_alicloud_sddp_data_limit_test.go @@ -116,11 +116,21 @@ variable "database_name" { default = "tftestdatabase" } -data "alicloud_db_zones" "default" {} +data "alicloud_db_zones" "default" { + engine = "MySQL" + engine_version = "8.0" + instance_charge_type = "PostPaid" + category = "HighAvailability" + db_instance_storage_type = "cloud_essd" +} data "alicloud_db_instance_classes" "default" { - engine = "MySQL" - engine_version = "5.6" + zone_id = data.alicloud_db_zones.default.zones.0.id + engine = "MySQL" + engine_version = "8.0" + category = "HighAvailability" + db_instance_storage_type = "cloud_essd" + instance_charge_type = "PostPaid" } data "alicloud_vpcs" "default" { @@ -133,10 +143,10 @@ data "alicloud_vswitches" "default" { } resource "alicloud_db_instance" "default" { - engine = "MySQL" - engine_version = "5.6" - instance_type = data.alicloud_db_instance_classes.default.instance_classes[0].instance_class - instance_storage = "10" + engine = "MySQL" + engine_version = "8.0" + instance_type = data.alicloud_db_instance_classes.default.instance_classes.0.instance_class + instance_storage = data.alicloud_db_instance_classes.default.instance_classes.0.storage_range.min vswitch_id = data.alicloud_vswitches.default.ids[0] instance_name = var.name } diff --git a/alicloud/resource_alicloud_sddp_instance.go b/alicloud/resource_alicloud_sddp_instance.go index eaec93f8dc6e..f62bd8f901d3 100644 --- a/alicloud/resource_alicloud_sddp_instance.go +++ b/alicloud/resource_alicloud_sddp_instance.go @@ -5,7 +5,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" @@ -145,12 +144,10 @@ func resourceAlicloudSddpInstance() *schema.Resource { func resourceAlicloudSddpInstanceCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error + var endpoint string action := "CreateInstance" request := make(map[string]interface{}) - conn, err := client.NewBssopenapiClient() - if err != nil { - return WrapError(err) - } request["ClientToken"] = buildClientToken("CreateInstance") request["ProductCode"] = "sddp" @@ -215,18 +212,16 @@ func resourceAlicloudSddpInstanceCreate(d *schema.ResourceData, meta interface{} "Value": client.RegionId, }) request["Parameter"] = parameterMapList - 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("2017-12-14"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPostWithEndpoint("BssOpenApi", "2017-12-14", action, nil, request, true, endpoint) if err != nil { if NeedRetry(err) { wait() return resource.RetryableError(err) } if IsExpectedErrors(err, []string{"NotApplicable"}) { - conn.Endpoint = String(connectivity.BssOpenAPIEndpointInternational) + endpoint = connectivity.BssOpenAPIEndpointInternational return resource.RetryableError(err) } return resource.NonRetryableError(err) @@ -273,11 +268,9 @@ func resourceAlicloudSddpInstanceRead(d *schema.ResourceData, meta interface{}) } func resourceAlicloudSddpInstanceUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewBssopenapiClient() - if err != nil { - return WrapError(err) - } var response map[string]interface{} + var err error + var endpoint string update := false request := map[string]interface{}{ "InstanceId": d.Id(), @@ -370,18 +363,16 @@ func resourceAlicloudSddpInstanceUpdate(d *schema.ResourceData, meta interface{} request["ModifyType"] = v } action := "ModifyInstance" - 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("2017-12-14"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPostWithEndpoint("BssOpenApi", "2017-12-14", action, nil, request, true, endpoint) if err != nil { if NeedRetry(err) { wait() return resource.RetryableError(err) } if IsExpectedErrors(err, []string{"NotApplicable"}) { - conn.Endpoint = String(connectivity.BssOpenAPIEndpointInternational) + endpoint = connectivity.BssOpenAPIEndpointInternational return resource.RetryableError(err) } return resource.NonRetryableError(err) diff --git a/alicloud/resource_alicloud_sddp_rule.go b/alicloud/resource_alicloud_sddp_rule.go index f6c599df4269..37a138a3ffce 100644 --- a/alicloud/resource_alicloud_sddp_rule.go +++ b/alicloud/resource_alicloud_sddp_rule.go @@ -5,7 +5,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" @@ -109,10 +108,7 @@ func resourceAliCloudSddpRuleCreate(d *schema.ResourceData, meta interface{}) er var response map[string]interface{} action := "CreateRule" request := make(map[string]interface{}) - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } + var err error request["Name"] = d.Get("rule_name") request["Category"] = d.Get("category").(int) @@ -162,11 +158,9 @@ func resourceAliCloudSddpRuleCreate(d *schema.ResourceData, meta interface{}) er request["Lang"] = 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-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -292,16 +286,10 @@ func resourceAliCloudSddpRuleUpdate(d *schema.ResourceData, meta interface{}) er if update { action := "ModifyRule" - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error 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-01-03"), StringPointer("AK"), nil, modifyRuleReq, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, modifyRuleReq, false) if err != nil { if NeedRetry(err) { wait() @@ -346,16 +334,10 @@ func resourceAliCloudSddpRuleUpdate(d *schema.ResourceData, meta interface{}) er if update { action := "ModifyRuleStatus" - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error 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-01-03"), StringPointer("AK"), nil, modifyRuleStatusReq, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, modifyRuleStatusReq, false) if err != nil { if NeedRetry(err) { wait() @@ -383,11 +365,7 @@ func resourceAliCloudSddpRuleDelete(d *schema.ResourceData, meta interface{}) er client := meta.(*connectivity.AliyunClient) action := "DeleteRule" var response map[string]interface{} - conn, err := client.NewSddpClient() - if err != nil { - return WrapError(err) - } - + var err error request := map[string]interface{}{ "Id": d.Id(), } @@ -396,11 +374,9 @@ func resourceAliCloudSddpRuleDelete(d *schema.ResourceData, meta interface{}) er request["Lang"] = v } - 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-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_sddp.go b/alicloud/service_alicloud_sddp.go index f0f5e3bc5ae0..8b51ca841302 100644 --- a/alicloud/service_alicloud_sddp.go +++ b/alicloud/service_alicloud_sddp.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" ) @@ -15,14 +14,9 @@ type SddpService struct { } func (s *SddpService) DescribeSddpRule(id string) (object map[string]interface{}, err error) { + client := s.client var response map[string]interface{} action := "DescribeRules" - - conn, err := s.client.NewSddpClient() - if err != nil { - return nil, WrapError(err) - } - request := map[string]interface{}{ "PageSize": PageSizeLarge, "CurrentPage": 1, @@ -30,11 +24,9 @@ func (s *SddpService) DescribeSddpRule(id string) (object map[string]interface{} 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -81,21 +73,16 @@ func (s *SddpService) DescribeSddpRule(id string) (object map[string]interface{} } func (s *SddpService) DescribeSddpConfig(id string) (object map[string]interface{}, err error) { + client := s.client var response map[string]interface{} - conn, err := s.client.NewSddpClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeConfigs" request := map[string]interface{}{ "Lang": "zh", } 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -130,17 +117,12 @@ func (s *SddpService) DescribeSddpConfig(id string) (object map[string]interface func (s *SddpService) DescribeSddpInstance(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewSddpClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeUserStatus" request := map[string]interface{}{} - 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -164,10 +146,7 @@ func (s *SddpService) DescribeSddpInstance(id string) (object map[string]interfa func (s *SddpService) DescribeSddpDataLimit(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewSddpClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeDataLimits" request := map[string]interface{}{ "CurrentPage": 1, @@ -175,11 +154,9 @@ func (s *SddpService) DescribeSddpDataLimit(id string) (object map[string]interf } 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("2019-01-03"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Sddp", "2019-01-03", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/website/docs/d/sddp_configs.html.markdown b/website/docs/d/sddp_configs.html.markdown index 82b85219221f..87d42336c384 100644 --- a/website/docs/d/sddp_configs.html.markdown +++ b/website/docs/d/sddp_configs.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Sddp Configs to the user. --- -# alicloud\_sddp\_configs +# alicloud_sddp_configs This data source provides the Sddp Configs of the current Alibaba Cloud user. --> **NOTE:** Available in v1.133.0+. +-> **NOTE:** Available since v1.133.0. ## Example Usage @@ -39,17 +39,17 @@ The following arguments are supported: * `ids` - (Optional, ForceNew, Computed) A list of Config IDs. * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `configs` - A list of Sddp Configs. Each element contains the following attributes: - * `code` - Abnormal Alarm General Configuration Module by Using the Encoding.Valid values: `access_failed_cnt`, `access_permission_exprie_max_days`, `log_datasize_avg_days`. - * `config_id` - Configure the Number. - * `default_value` - Default Value. - * `description` - Abnormal Alarm General Description of the Configuration Item. - * `id` - The ID of the Config. - * `value` - The Specified Exception Alarm Generic by Using the Value. Code Different Values for This Parameter the Specific Meaning of Different. - * `access_failed_cnt`: Value Represents the Non-Authorized Resource Repeatedly Attempts to Access the Threshold. - * `access_permission_exprie_max_days`: Value Represents the Permissions during Periods of Inactivity Exceeding a Threshold. - * `log_datasize_avg_days`: Value Represents the Date Certain Log Output Is Less than 10 Days before the Average Value of the Threshold. + * `code` - Abnormal Alarm General Configuration Module by Using the Encoding.Valid values: `access_failed_cnt`, `access_permission_exprie_max_days`, `log_datasize_avg_days`. + * `config_id` - Configure the Number. + * `default_value` - Default Value. + * `description` - Abnormal Alarm General Description of the Configuration Item. + * `id` - The ID of the Config. + * `value` - The Specified Exception Alarm Generic by Using the Value. Code Different Values for This Parameter the Specific Meaning of Different. + * `access_failed_cnt`: Value Represents the Non-Authorized Resource Repeatedly Attempts to Access the Threshold. + * `access_permission_exprie_max_days`: Value Represents the Permissions during Periods of Inactivity Exceeding a Threshold. + * `log_datasize_avg_days`: Value Represents the Date Certain Log Output Is Less than 10 Days before the Average Value of the Threshold. diff --git a/website/docs/d/sddp_data_limits.html.markdown b/website/docs/d/sddp_data_limits.html.markdown index 8c9359b4e3af..6a7c7c2c2333 100644 --- a/website/docs/d/sddp_data_limits.html.markdown +++ b/website/docs/d/sddp_data_limits.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Sddp Data Limits to the user. --- -# alicloud\_sddp\_data\_limits +# alicloud_sddp_data_limits This data source provides the Sddp Data Limits of the current Alibaba Cloud user. --> **NOTE:** Available in v1.159.0+. +-> **NOTE:** Available since v1.159.0. ## Example Usage @@ -33,19 +33,19 @@ The following arguments are supported: * `parent_id` - (Optional, ForceNew) The parent asset ID of the data asset. * `resource_type` - (Optional, ForceNew) The type of the service to which the data asset belongs. Valid values: `MaxCompute`, `OSS`, `RDS`. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `limits` - A list of Sddp Data Limits. Each element contains the following attributes: - * `audit_status` - Whether to enable the log auditing feature. - * `check_status` - The status of the connectivity test between the data asset and SDDP. - * `data_limit_id` - The first ID of the resource. - * `engine_type` -The type of the database. - * `id` - The ID of the Data Limit. - * `local_name` - The name of the service to which the data asset belongs. - * `log_store_day` - The retention period of raw logs after you enable the log auditing feature. - * `parent_id` - The ID of the data asset. - * `port` - The port that is used to connect to the database. - * `resource_type` - The type of the service to which the data asset belongs. - * `user_name` - The name of the user who owns the data asset. \ No newline at end of file + * `audit_status` - Whether to enable the log auditing feature. + * `check_status` - The status of the connectivity test between the data asset and SDDP. + * `data_limit_id` - The first ID of the resource. + * `engine_type` -The type of the database. + * `id` - The ID of the Data Limit. + * `local_name` - The name of the service to which the data asset belongs. + * `log_store_day` - The retention period of raw logs after you enable the log auditing feature. + * `parent_id` - The ID of the data asset. + * `port` - The port that is used to connect to the database. + * `resource_type` - The type of the service to which the data asset belongs. + * `user_name` - The name of the user who owns the data asset. \ No newline at end of file diff --git a/website/docs/d/sddp_instances.html.markdown b/website/docs/d/sddp_instances.html.markdown index 850377c9e8b1..ac4399076a0e 100644 --- a/website/docs/d/sddp_instances.html.markdown +++ b/website/docs/d/sddp_instances.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Sddp Instances to the user. --- -# alicloud\_sddp\_instances +# alicloud_sddp_instances This data source provides the Sddp Instances of the current Alibaba Cloud user. --> **NOTE:** Available in v1.136.0+. +-> **NOTE:** Available since v1.136.0. ## Example Usage @@ -31,17 +31,17 @@ The following arguments are supported: * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `instances` - A list of Sddp Instances. Each element contains the following attributes: - * `authed` - Whether the required RAM authorization is configured. - * `instance_id` - The ID of the instance. - * `instance_num` - The number of instances. - * `odps_set` - Whether the authorized MaxCompute (ODPS) assets. - * `oss_bucket_set` - Whether the authorized oss assets. - * `oss_size` - The OSS size of the instance. - * `payment_type` - The payment type of the resource. Valid values: `Subscription`. - * `rds_set` - Whether the authorized rds assets. - * `status` - The status of the resource. + * `authed` - Whether the required RAM authorization is configured. + * `instance_id` - The ID of the instance. + * `instance_num` - The number of instances. + * `odps_set` - Whether the authorized MaxCompute (ODPS) assets. + * `oss_bucket_set` - Whether the authorized oss assets. + * `oss_size` - The OSS size of the instance. + * `payment_type` - The payment type of the resource. Valid values: `Subscription`. + * `rds_set` - Whether the authorized rds assets. + * `status` - The status of the resource. diff --git a/website/docs/d/sddp_rules.html.markdown b/website/docs/d/sddp_rules.html.markdown index 704d47af907c..7e872222aa0b 100644 --- a/website/docs/d/sddp_rules.html.markdown +++ b/website/docs/d/sddp_rules.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Sddp Rules to the user. --- -# alicloud\_sddp\_rules +# alicloud_sddp_rules This data source provides the Sddp Rules of the current Alibaba Cloud user. --> **NOTE:** Available in v1.132.0+. +-> **NOTE:** Available since v1.132.0. ## Example Usage @@ -68,32 +68,32 @@ The following arguments are supported: * `2`: Medium Risk Level. * `3`: High Risk Level. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `names` - A list of Rule names. * `rules` - A list of Sddp Rules. Each element contains the following attributes: - * `category` - Sensitive Data Identification Rules for the Type of. - * `category_name` - Sensitive Data Identification Rules Belongs Type Name. - * `content` - Sensitive Data Identification Rules the Content. - * `content_category` - The Content Classification. - * `create_time` - Sensitive Data Identification Rules the Creation Time of the Number of Milliseconds. - * `custom_type` - Sensitive Data Identification Rules of Type. 0: the Built-in 1: The User-Defined. - * `description` - Sensitive Data Identification a Description of the Rule Information. - * `display_name` - Sensitive Data Identification Rules, Founder of Account Display Name. - * `gmt_modified` - Sensitive Data Identification Rules to the Modified Time of the Number of Milliseconds. - * `group_id` - Group ID. - * `id` - The ID of the Rule. - * `login_name` - Sensitive Data Identification Rules, Founder Of Account Login. - * `major_key` - The Primary Key. - * `product_code` - Product Code. - * `product_id` - Product ID. - * `risk_level_id` - Sensitive Data Identification Rules of Risk Level ID. Valid values:1:S1, Weak Risk Level. 2:S2, Medium Risk Level. 3:S3 High Risk Level. 4:S4, the Highest Risk Level. - * `risk_level_name` - Sensitive Data Identification Rules the Risk Level of. S1: Weak Risk Level S2: Moderate Risk Level S3: High Risk Level S4: the Highest Risk Level. - * `rule_id` - The first ID of the resource. - * `stat_express` - Triggered the Alarm Conditions. - * `status` - Sensitive Data Identification Rules Detection State of. - * `target` - The Target. - * `user_id` - The User ID. - * `warn_level` - The Level of Risk. + * `category` - Sensitive Data Identification Rules for the Type of. + * `category_name` - Sensitive Data Identification Rules Belongs Type Name. + * `content` - Sensitive Data Identification Rules the Content. + * `content_category` - The Content Classification. + * `create_time` - Sensitive Data Identification Rules the Creation Time of the Number of Milliseconds. + * `custom_type` - Sensitive Data Identification Rules of Type. 0: the Built-in 1: The User-Defined. + * `description` - Sensitive Data Identification a Description of the Rule Information. + * `display_name` - Sensitive Data Identification Rules, Founder of Account Display Name. + * `gmt_modified` - Sensitive Data Identification Rules to the Modified Time of the Number of Milliseconds. + * `group_id` - Group ID. + * `id` - The ID of the Rule. + * `login_name` - Sensitive Data Identification Rules, Founder Of Account Login. + * `major_key` - The Primary Key. + * `product_code` - Product Code. + * `product_id` - Product ID. + * `risk_level_id` - Sensitive Data Identification Rules of Risk Level ID. Valid values:1:S1, Weak Risk Level. 2:S2, Medium Risk Level. 3:S3 High Risk Level. 4:S4, the Highest Risk Level. + * `risk_level_name` - Sensitive Data Identification Rules the Risk Level of. S1: Weak Risk Level S2: Moderate Risk Level S3: High Risk Level S4: the Highest Risk Level. + * `rule_id` - The first ID of the resource. + * `stat_express` - Triggered the Alarm Conditions. + * `status` - Sensitive Data Identification Rules Detection State of. + * `target` - The Target. + * `user_id` - The User ID. + * `warn_level` - The Level of Risk.