From c0c38de1b1cc39b4a8e4f32ce39322e190aa2ea8 Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Sat, 21 Dec 2024 00:35:42 +0800 Subject: [PATCH] MscOpenSubscription: Improves the invoking MscOpenSubscription api method and supports refreshing credential automatically --- ...ud_msc_sub_contact_verification_message.go | 10 +---- .../data_source_alicloud_msc_sub_contacts.go | 10 +---- ...a_source_alicloud_msc_sub_subscriptions.go | 10 +---- .../data_source_alicloud_msc_sub_webhooks.go | 10 +---- alicloud/resource_alicloud_msc_sub_contact.go | 35 +++++------------- .../resource_alicloud_msc_sub_contact_test.go | 2 - .../resource_alicloud_msc_sub_subscription.go | 17 ++------- ...urce_alicloud_msc_sub_subscription_test.go | 1 - alicloud/resource_alicloud_msc_sub_webhook.go | 33 +++++------------ .../resource_alicloud_msc_sub_webhook_test.go | 10 +---- .../service_alicloud_msc_open_subscription.go | 37 ++++--------------- ...contact_verification_message.html.markdown | 4 +- website/docs/d/msc_sub_contacts.html.markdown | 32 ++++++++-------- .../d/msc_sub_subscriptions.html.markdown | 32 ++++++++-------- website/docs/d/msc_sub_webhooks.html.markdown | 14 +++---- 15 files changed, 81 insertions(+), 176 deletions(-) diff --git a/alicloud/data_source_alicloud_msc_sub_contact_verification_message.go b/alicloud/data_source_alicloud_msc_sub_contact_verification_message.go index 6b4ee5fb2fdf..75715b7f0383 100644 --- a/alicloud/data_source_alicloud_msc_sub_contact_verification_message.go +++ b/alicloud/data_source_alicloud_msc_sub_contact_verification_message.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -41,18 +40,13 @@ func dataSourceAlicloudMscSubContactVerificationMessageRead(d *schema.ResourceDa action := "SendVerificationMessage" var response map[string]interface{} request := make(map[string]interface{}) - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error request["ContactId"] = d.Get("contact_id") request["Type"] = d.Get("type") request["Locale"] = "en" - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_msc_sub_contacts.go b/alicloud/data_source_alicloud_msc_sub_contacts.go index df434059738e..7235f5c738fe 100644 --- a/alicloud/data_source_alicloud_msc_sub_contacts.go +++ b/alicloud/data_source_alicloud_msc_sub_contacts.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" @@ -130,16 +129,11 @@ func dataSourceAlicloudMscSubContactsRead(d *schema.ResourceData, meta interface } } var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_msc_sub_subscriptions.go b/alicloud/data_source_alicloud_msc_sub_subscriptions.go index b185a410c8db..cced83c5d536 100644 --- a/alicloud/data_source_alicloud_msc_sub_subscriptions.go +++ b/alicloud/data_source_alicloud_msc_sub_subscriptions.go @@ -7,7 +7,6 @@ import ( "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" @@ -95,16 +94,11 @@ func dataSourceAlicloudMscSubSubscriptionsRead(d *schema.ResourceData, meta inte request["MaxResults"] = PageSizeLarge var objects []map[string]interface{} var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_msc_sub_webhooks.go b/alicloud/data_source_alicloud_msc_sub_webhooks.go index d962d377f656..44e3c81fa7ff 100644 --- a/alicloud/data_source_alicloud_msc_sub_webhooks.go +++ b/alicloud/data_source_alicloud_msc_sub_webhooks.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" @@ -94,16 +93,11 @@ func dataSourceAlicloudMscSubWebhooksRead(d *schema.ResourceData, meta interface } } var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_msc_sub_contact.go b/alicloud/resource_alicloud_msc_sub_contact.go index a60bb57195c5..73e82cfb1023 100644 --- a/alicloud/resource_alicloud_msc_sub_contact.go +++ b/alicloud/resource_alicloud_msc_sub_contact.go @@ -6,7 +6,6 @@ import ( "regexp" "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" @@ -51,10 +50,6 @@ func resourceAlicloudMscSubContact() *schema.Resource { func resourceAlicloudMscSubContactCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) request := make(map[string]interface{}) - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } request["ContactName"] = d.Get("contact_name") request["Email"] = d.Get("email") request["Mobile"] = d.Get("mobile") @@ -62,12 +57,11 @@ func resourceAlicloudMscSubContactCreate(d *schema.ResourceData, meta interface{ request["ClientToken"] = buildClientToken("CreateContact") request["Locale"] = "en" var response map[string]interface{} + var err error action := "CreateContact" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -75,8 +69,7 @@ func resourceAlicloudMscSubContactCreate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -111,10 +104,7 @@ func resourceAlicloudMscSubContactRead(d *schema.ResourceData, meta interface{}) func resourceAlicloudMscSubContactUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error update := false request := map[string]interface{}{ @@ -135,11 +125,9 @@ func resourceAlicloudMscSubContactUpdate(d *schema.ResourceData, meta interface{ if update { action := "UpdateContact" request["ClientToken"] = buildClientToken("UpdateContact") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -147,8 +135,7 @@ func resourceAlicloudMscSubContactUpdate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -163,10 +150,7 @@ func resourceAlicloudMscSubContactUpdate(d *schema.ResourceData, meta interface{ func resourceAlicloudMscSubContactDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "ContactId": d.Id(), } @@ -174,7 +158,7 @@ func resourceAlicloudMscSubContactDelete(d *schema.ResourceData, meta interface{ action := "DeleteContact" wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -182,8 +166,7 @@ func resourceAlicloudMscSubContactDelete(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { diff --git a/alicloud/resource_alicloud_msc_sub_contact_test.go b/alicloud/resource_alicloud_msc_sub_contact_test.go index 30cdff365071..6d8f4849920d 100644 --- a/alicloud/resource_alicloud_msc_sub_contact_test.go +++ b/alicloud/resource_alicloud_msc_sub_contact_test.go @@ -19,7 +19,6 @@ import ( ) func TestAccAlicloudMscSubContact_basic0(t *testing.T) { - checkoutSupportedRegions(t, true, connectivity.MSCSupportRegions) var v map[string]interface{} resourceId := "alicloud_msc_sub_contact.default" ra := resourceAttrInit(resourceId, AlicloudMscSubContactMap0) @@ -118,7 +117,6 @@ variable "name" { } func TestAccAlicloudMscSubContact_basic1(t *testing.T) { - checkoutSupportedRegions(t, true, connectivity.MSCSupportRegions) var v map[string]interface{} resourceId := "alicloud_msc_sub_contact.default" ra := resourceAttrInit(resourceId, AlicloudMscSubContactMap1) diff --git a/alicloud/resource_alicloud_msc_sub_subscription.go b/alicloud/resource_alicloud_msc_sub_subscription.go index 9bd70aeac103..d67768673f14 100644 --- a/alicloud/resource_alicloud_msc_sub_subscription.go +++ b/alicloud/resource_alicloud_msc_sub_subscription.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" @@ -80,15 +79,12 @@ func resourceAlicloudMscSubSubscriptionCreate(d *schema.ResourceData, meta inter var response map[string]interface{} action := "CreateSubscriptionItem" request := make(map[string]interface{}) - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error request["ItemName"] = d.Get("item_name") request["Locale"] = "en" 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("2021-07-13"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -159,10 +155,7 @@ func resourceAlicloudMscSubSubscriptionRead(d *schema.ResourceData, meta interfa func resourceAlicloudMscSubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error update := false request := map[string]interface{}{ "ItemId": d.Id(), @@ -215,11 +208,9 @@ func resourceAlicloudMscSubSubscriptionUpdate(d *schema.ResourceData, meta inter if update { action := "UpdateSubscriptionItem" request["ClientToken"] = buildClientToken("UpdateSubscriptionItem") - 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("2021-07-13"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_msc_sub_subscription_test.go b/alicloud/resource_alicloud_msc_sub_subscription_test.go index cd8c41081090..c107f4f5d5e4 100644 --- a/alicloud/resource_alicloud_msc_sub_subscription_test.go +++ b/alicloud/resource_alicloud_msc_sub_subscription_test.go @@ -21,7 +21,6 @@ import ( ) func TestAccAlicloudMscSubSubscription_basic0(t *testing.T) { - checkoutSupportedRegions(t, true, connectivity.MSCSupportRegions) var v map[string]interface{} resourceId := "alicloud_msc_sub_subscription.default" ra := resourceAttrInit(resourceId, AlicloudMscSubSubscriptionMap0) diff --git a/alicloud/resource_alicloud_msc_sub_webhook.go b/alicloud/resource_alicloud_msc_sub_webhook.go index 09560a623241..2ea7e898583f 100644 --- a/alicloud/resource_alicloud_msc_sub_webhook.go +++ b/alicloud/resource_alicloud_msc_sub_webhook.go @@ -6,7 +6,6 @@ import ( "regexp" "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" @@ -40,21 +39,16 @@ func resourceAlicloudMscSubWebhook() *schema.Resource { func resourceAlicloudMscSubWebhookCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) request := make(map[string]interface{}) - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } request["Locale"] = "en" request["ServerUrl"] = d.Get("server_url") request["WebhookName"] = d.Get("webhook_name") request["ClientToken"] = buildClientToken("CreateWebhook") var response map[string]interface{} + var err error action := "CreateWebhook" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -62,8 +56,7 @@ func resourceAlicloudMscSubWebhookCreate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -97,10 +90,7 @@ func resourceAlicloudMscSubWebhookRead(d *schema.ResourceData, meta interface{}) func resourceAlicloudMscSubWebhookUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error update := false request := map[string]interface{}{ "WebhookId": d.Id(), @@ -117,11 +107,9 @@ func resourceAlicloudMscSubWebhookUpdate(d *schema.ResourceData, meta interface{ request["Locale"] = "en" action := "UpdateWebhook" request["ClientToken"] = buildClientToken("UpdateWebhook") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -129,7 +117,7 @@ func resourceAlicloudMscSubWebhookUpdate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -145,10 +133,7 @@ func resourceAlicloudMscSubWebhookUpdate(d *schema.ResourceData, meta interface{ func resourceAlicloudMscSubWebhookDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "WebhookId": d.Id(), "Locale": "en", @@ -157,7 +142,7 @@ func resourceAlicloudMscSubWebhookDelete(d *schema.ResourceData, meta interface{ action := "DeleteWebhook" wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -165,7 +150,7 @@ func resourceAlicloudMscSubWebhookDelete(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { diff --git a/alicloud/resource_alicloud_msc_sub_webhook_test.go b/alicloud/resource_alicloud_msc_sub_webhook_test.go index ec803828df5c..8bff2c9f4a71 100644 --- a/alicloud/resource_alicloud_msc_sub_webhook_test.go +++ b/alicloud/resource_alicloud_msc_sub_webhook_test.go @@ -46,16 +46,10 @@ func testSweepMscSubWebhook(region string) error { request["MaxResults"] = PageSizeLarge var response map[string]interface{} - conn, err := client.NewMscopensubscriptionClient() - if err != nil { - log.Printf("[ERROR] %s get an error: %#v", action, err) - } 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -94,7 +88,7 @@ func testSweepMscSubWebhook(region string) error { request := map[string]interface{}{ "WebhookId": item["WebhookId"], } - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-07-13"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("MscOpenSubscription", "2021-07-13", action, nil, request, true) if err != nil { log.Printf("[ERROR] Failed to delete Msc Sub Webhook (%s): %s", item["WebhookName"].(string), err) } diff --git a/alicloud/service_alicloud_msc_open_subscription.go b/alicloud/service_alicloud_msc_open_subscription.go index ffd42f21c809..e1b8e874d3e0 100644 --- a/alicloud/service_alicloud_msc_open_subscription.go +++ b/alicloud/service_alicloud_msc_open_subscription.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" ) @@ -16,20 +15,15 @@ type MscOpenSubscriptionService struct { func (s *MscOpenSubscriptionService) GetContact(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewMscopensubscriptionClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetContact" request := map[string]interface{}{ "ContactId": id, "Locale": "en", } - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -59,20 +53,15 @@ func (s *MscOpenSubscriptionService) GetContact(id string) (object map[string]in func (s *MscOpenSubscriptionService) DescribeMscSubContact(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewMscopensubscriptionClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetContact" request := map[string]interface{}{ "ContactId": id, "Locale": "en", } - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -102,20 +91,15 @@ func (s *MscOpenSubscriptionService) DescribeMscSubContact(id string) (object ma func (s *MscOpenSubscriptionService) DescribeMscSubSubscription(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewMscopensubscriptionClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetSubscriptionItem" request := map[string]interface{}{ "ItemId": id, "Locale": "en", } - 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("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -142,19 +126,14 @@ func (s *MscOpenSubscriptionService) DescribeMscSubSubscription(id string) (obje func (s *MscOpenSubscriptionService) DescribeMscSubWebhook(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewMscopensubscriptionClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetWebhook" request := map[string]interface{}{ "WebhookId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2021-07-13"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("MscOpenSubscription", "2021-07-13", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/website/docs/d/msc_sub_contact_verification_message.html.markdown b/website/docs/d/msc_sub_contact_verification_message.html.markdown index 17e960bfe8ce..b23ffbecca8b 100644 --- a/website/docs/d/msc_sub_contact_verification_message.html.markdown +++ b/website/docs/d/msc_sub_contact_verification_message.html.markdown @@ -7,10 +7,10 @@ description: |- Provide a data source to send the verification message to the user. --- -# alicloud\_msc\_sub\_contact\_verification\_message +# alicloud_msc_sub_contact_verification_message --> **NOTE:** Available in v1.156.0+. +-> **NOTE:** Available since v1.156.0. ## Example Usage diff --git a/website/docs/d/msc_sub_contacts.html.markdown b/website/docs/d/msc_sub_contacts.html.markdown index 4e9c4a8208ae..9973af8be673 100644 --- a/website/docs/d/msc_sub_contacts.html.markdown +++ b/website/docs/d/msc_sub_contacts.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Message Center Contacts to the user. --- -# alicloud\_msc\_sub\_contacts +# alicloud_msc_sub_contacts This data source provides the Message Center Contacts of the current Alibaba Cloud user. --> **NOTE:** Available in v1.132.0+. +-> **NOTE:** Available since v1.132.0. ## Example Usage @@ -39,22 +39,22 @@ The following arguments are supported: * `name_regex` - (Optional, ForceNew) A regex string to filter results by Contact name. * `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: * `names` - A list of Contact names. * `contacts` - A list of Msc Sub Contacts. Each element contains the following attributes: - * `account_uid` - UID. - * `contact_id` - The first ID of the resource. - * `contact_name` - The User's Contact Name. **Note:** The name must be 2 to 12 characters in length, and can contain uppercase and lowercase letters. - * `email` - The User's Contact Email Address. - * `id` - The ID of the Contact. - * `is_account` - Indicates Whether the BGP Group Is the Account Itself. - * `is_obsolete` - Whether They Have Expired Or Not. - * `is_verified_email` - Email Validation for. - * `is_verified_mobile` - If the Phone Verification. - * `last_email_verification_time_stamp` - Last Verification Email Transmission Time. - * `last_mobile_verification_time_stamp` - The Pieces of Authentication SMS Sending Time. - * `mobile` - The User's Telephone. - * `position` - The User's Position. Valid values: `CEO`, `Technical Director`, `Maintenance Director`, `Project Director`,`Finance Director` and `Other`. + * `account_uid` - UID. + * `contact_id` - The first ID of the resource. + * `contact_name` - The User's Contact Name. **Note:** The name must be 2 to 12 characters in length, and can contain uppercase and lowercase letters. + * `email` - The User's Contact Email Address. + * `id` - The ID of the Contact. + * `is_account` - Indicates Whether the BGP Group Is the Account Itself. + * `is_obsolete` - Whether They Have Expired Or Not. + * `is_verified_email` - Email Validation for. + * `is_verified_mobile` - If the Phone Verification. + * `last_email_verification_time_stamp` - Last Verification Email Transmission Time. + * `last_mobile_verification_time_stamp` - The Pieces of Authentication SMS Sending Time. + * `mobile` - The User's Telephone. + * `position` - The User's Position. Valid values: `CEO`, `Technical Director`, `Maintenance Director`, `Project Director`,`Finance Director` and `Other`. diff --git a/website/docs/d/msc_sub_subscriptions.html.markdown b/website/docs/d/msc_sub_subscriptions.html.markdown index cd453c4a3b2d..9d4fefcd7293 100644 --- a/website/docs/d/msc_sub_subscriptions.html.markdown +++ b/website/docs/d/msc_sub_subscriptions.html.markdown @@ -3,15 +3,15 @@ subcategory: "Message Center (MscSub)" layout: "alicloud" page_title: "Alicloud: alicloud_msc_sub_subscriptions" sidebar_current: "docs-alicloud-datasource-msc-sub-subscriptions" -description: |- +description: |- Provides a list of Message Center Subscriptions to the user. --- -# alicloud\_msc\_sub\_subscriptions +# alicloud_msc_sub_subscriptions This data source provides the Message Center Subscriptions of the current Alibaba Cloud user. --> **NOTE:** Available in v1.135.0+. +-> **NOTE:** Available since v1.135.0. ## Example Usage @@ -31,20 +31,20 @@ 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: * `subscriptions` - A list of Msc Sub Subscriptions. Each element contains the following attributes: - * `channel` - The channel the Subscription. - * `contact_ids` - The ids of subscribed contacts. - * `description` - The description of the Subscription. - * `email_status` - The status of email subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. - * `id` - The ID of the Subscription. - * `item_id` - The ID of the Subscription. - * `item_name` - The name of the Subscription. - * `pmsg_status` - The status of pmsg subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. - * `sms_status` - The status of sms subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. - * `tts_status` - The status of tts subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. - * `webhook_ids` - The ids of subscribed webhooks. - * `webhook_status` - The status of webhook subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. + * `channel` - The channel the Subscription. + * `contact_ids` - The ids of subscribed contacts. + * `description` - The description of the Subscription. + * `email_status` - The status of email subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. + * `id` - The ID of the Subscription. + * `item_id` - The ID of the Subscription. + * `item_name` - The name of the Subscription. + * `pmsg_status` - The status of pmsg subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. + * `sms_status` - The status of sms subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. + * `tts_status` - The status of tts subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. + * `webhook_ids` - The ids of subscribed webhooks. + * `webhook_status` - The status of webhook subscription. Valid values: `-1`, `-2`, `0`, `1`. `-1` means required, `-2` means banned; `1` means subscribed; `0` means not subscribed. diff --git a/website/docs/d/msc_sub_webhooks.html.markdown b/website/docs/d/msc_sub_webhooks.html.markdown index 51a294120652..18c360ff3e21 100644 --- a/website/docs/d/msc_sub_webhooks.html.markdown +++ b/website/docs/d/msc_sub_webhooks.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Msc Sub Webhooks to the user. --- -# alicloud\_msc\_sub\_webhooks +# alicloud_msc_sub_webhooks This data source provides the Msc Sub Webhooks of the current Alibaba Cloud user. --> **NOTE:** Available in v1.141.0+. +-> **NOTE:** Available since v1.141.0. ## Example Usage @@ -42,13 +42,13 @@ The following arguments are supported: * `name_regex` - (Optional, ForceNew) A regex string to filter results by Webhook name. * `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: * `names` - A list of Webhook names. * `webhooks` - A list of Msc Sub Webhooks. Each element contains the following attributes: - * `id` - The ID of the Webhook. - * `server_url` - The serverUrl of the Subscription. - * `webhook_id` - The first ID of the resource. - * `webhook_name` - The name of the Webhook. **Note:** The name must be `2` to `12` characters in length, and can contain uppercase and lowercase letters. + * `id` - The ID of the Webhook. + * `server_url` - The serverUrl of the Subscription. + * `webhook_id` - The first ID of the resource. + * `webhook_name` - The name of the Webhook. **Note:** The name must be `2` to `12` characters in length, and can contain uppercase and lowercase letters.