Skip to content

Commit

Permalink
resource/alicloud_cloud_monitor_service_basic_public: Supports intern…
Browse files Browse the repository at this point in the history
…ational account
  • Loading branch information
xiaozhu36 committed Jan 10, 2025
1 parent a734b98 commit 28e0f75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
32 changes: 19 additions & 13 deletions alicloud/resource_alicloud_cloud_monitor_service_basic_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,52 @@ func resourceAliCloudCloudMonitorServiceBasicPublicCreate(d *schema.ResourceData
action := "CreateInstance"
var request map[string]interface{}
var response map[string]interface{}
var err error
var endpoint string
query := make(map[string]interface{})
conn, err := client.NewBssopenapiClient()
if err != nil {
return WrapError(err)
}
request = make(map[string]interface{})

request["ClientToken"] = buildClientToken(action)

request["ProductCode"] = "cms"
request["ProductType"] = "cms_basic_public_cn"
if client.IsInternationalAccount() {
request["ProductType"] = "cms_basic_public_intl"
}
request["SubscriptionType"] = "PayAsYouGo"
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("2017-12-14"), StringPointer("AK"), query, request, &runtime)
response, err = client.RpcPostWithEndpoint("BssOpenApi", "2017-12-14", action, query, request, true, endpoint)
request["ClientToken"] = buildClientToken(action)

if err != nil {
if NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
if !client.IsInternationalAccount() && IsExpectedErrors(err, []string{"NotApplicable"}) {
request["ProductType"] = "cms_basic_public_intl"
endpoint = connectivity.BssOpenAPIEndpointInternational
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})

if err != nil {
return WrapErrorf(err, DefaultErrorMsg, "alicloud_cloud_monitor_service_basic_public", action, AlibabaCloudSdkGoERROR)
}
if response["Code"] == "Has.effect.suit" {
parts := strings.Split(response["Message"].(string), ": ")
if len(parts) < 2 {
return WrapErrorf(err, ResponseCodeMsg, "alicloud_cloud_monitor_service_basic_public", action, response)
if IsExpectedErrors(err, []string{"Has.effect.suit"}) {
parts := strings.Split(response["Message"].(string), ": ")
if len(parts) < 2 {
return WrapErrorf(err, ResponseCodeMsg, "alicloud_cloud_monitor_service_basic_public", action, response)
}
d.SetId(parts[1])
return resourceAliCloudCloudMonitorServiceBasicPublicRead(d, meta)
}
d.SetId(parts[1])
return resourceAliCloudCloudMonitorServiceBasicPublicRead(d, meta)
return WrapErrorf(err, DefaultErrorMsg, "alicloud_cloud_monitor_service_basic_public", action, AlibabaCloudSdkGoERROR)
}

id, _ := jsonpath.Get("$.Data.InstanceId", response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func resourceAliCloudCloudMonitorServiceEnterprisePublicCreate(d *schema.Resourc
request["ProductType"] = "cms_enterprise_public_intl"
}
request["SubscriptionType"] = "PayAsYouGo"
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 = client.RpcPostWithEndpoint("BssOpenApi", "2017-12-14", action, query, request, true, endpoint)
Expand Down

0 comments on commit 28e0f75

Please sign in to comment.