Skip to content

Commit

Permalink
Ga: Improves the invoking ga api method and supports refreshing crede…
Browse files Browse the repository at this point in the history
…ntial automatically
  • Loading branch information
xiaozhu36 committed Oct 19, 2024
1 parent e35f621 commit 2687372
Show file tree
Hide file tree
Showing 65 changed files with 422 additions and 949 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,12 @@ func dataSourceAlicloudGaAcceleratorSpareIpAttachmentsRead(d *schema.ResourceDat
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
if err != nil {
return WrapError(err)
}
var err error
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_accelerators.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,11 @@ func dataSourceAlicloudGaAcceleratorsRead(d *schema.ResourceData, meta interface
status, statusOk := d.GetOk("status")
bandwidthBillingType, BandwidthBillingTypeOk := d.GetOk("bandwidth_billing_type")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ga_accelerators", action, AlibabaCloudSdkGoERROR)
}
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,13 @@ func dataSourceAlicloudGaAclsRead(d *schema.ResourceData, meta interface{}) erro
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_additional_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,13 @@ func dataSourceAlicloudGaAdditionalCertificatesRead(d *schema.ResourceData, meta
}
}
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_bandwidth_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,11 @@ func dataSourceAlicloudGaBandwidthPackagesRead(d *schema.ResourceData, meta inte
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ga_bandwidth_packages", action, AlibabaCloudSdkGoERROR)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,14 @@ func dataSourceAlicloudGaBasicAccelerateIpEndpointRelationsRead(d *schema.Resour
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_basic_accelerate_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,14 @@ func dataSourceAlicloudGaBasicAccelerateIpsRead(d *schema.ResourceData, meta int
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_basic_accelerators.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,13 @@ func dataSourceAlicloudGaBasicAcceleratorsRead(d *schema.ResourceData, meta inte
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_basic_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,14 @@ func dataSourceAlicloudGaBasicEndpointsRead(d *schema.ResourceData, meta interfa
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,14 @@ func dataSourceAlicloudGaCustomRoutingEndpointGroupDestinationsRead(d *schema.Re
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,14 @@ func dataSourceAlicloudGaCustomRoutingEndpointGroupsRead(d *schema.ResourceData,
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,14 @@ func dataSourceAliCloudGaCustomRoutingEndpointTrafficPoliciesRead(d *schema.Reso
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_custom_routing_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,14 @@ func dataSourceAlicloudGaCustomRoutingEndpointsRead(d *schema.ResourceData, meta
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,14 @@ func dataSourceAlicloudGaCustomRoutingPortMappingsRead(d *schema.ResourceData, m
var objects []map[string]interface{}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
11 changes: 2 additions & 9 deletions alicloud/data_source_alicloud_ga_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -110,28 +109,22 @@ func dataSourceAlicloudGaDomainsRead(d *schema.ResourceData, meta interface{}) e
}
}

conn, err := client.NewGaplusClient()
if err != nil {
return WrapError(err)
}
var err error
var objects []interface{}
var response map[string]interface{}

for {
action := "ListDomains"
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
response = resp
addDebug(action, response, request)
return nil
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ func dataSourceAliCloudGaEndpointGroupIpAddressCidrBlocksRead(d *schema.Resource
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
if err != nil {
return WrapError(err)
}
var err error

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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_endpoint_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,13 @@ func dataSourceAliCloudGaEndpointGroupsRead(d *schema.ResourceData, meta interfa
}

var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_forwarding_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,11 @@ func dataSourceAlicloudGaForwardingRulesRead(d *schema.ResourceData, meta interf
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ga_forwarding_rules", action, AlibabaCloudSdkGoERROR)
}
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_ip_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ func dataSourceAlicloudGaIpSetsRead(d *schema.ResourceData, meta interface{}) er
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ga_ip_sets", action, AlibabaCloudSdkGoERROR)
}
Expand Down
7 changes: 2 additions & 5 deletions alicloud/data_source_alicloud_ga_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,11 @@ func dataSourceAlicloudGaListenersRead(d *schema.ResourceData, meta interface{})
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewGaplusClient()
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-11-20"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("Ga", "2019-11-20", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ga_listeners", action, AlibabaCloudSdkGoERROR)
}
Expand Down
Loading

0 comments on commit 2687372

Please sign in to comment.