Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCDN: Improves the invoking dcdn api method and supports refreshing credential automatically #7745

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 120 additions & 132 deletions alicloud/connectivity/client.go

Large diffs are not rendered by default.

312 changes: 290 additions & 22 deletions alicloud/connectivity/endpoint.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions alicloud/connectivity/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package connectivity

import "strings"

func ConvertKebabToSnake(s string) string {
return strings.ReplaceAll(s, "-", "_")
}
10 changes: 2 additions & 8 deletions alicloud/data_source_alicloud_dcdn_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"regexp"

"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/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down Expand Up @@ -214,14 +213,9 @@ func dataSourceAlicloudDcdnDomainsRead(d *schema.ResourceData, meta interface{})
}
}
var response map[string]interface{}
conn, err := client.NewDcdnClient()
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("2018-01-15"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("dcdn", "2018-01-15", action, nil, request, true)
if err != nil {
return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_dcdn_domains", action, AlibabaCloudSdkGoERROR)
}
Expand Down
1 change: 1 addition & 0 deletions alicloud/data_source_alicloud_dcdn_domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ resource "alicloud_dcdn_domain" "default" {
port = "80"
priority = "20"
type = "ipaddr"
weight = 10
}
resource_group_id = data.alicloud_resource_manager_resource_groups.default.ids.0
scope = "overseas"
Expand Down
10 changes: 2 additions & 8 deletions alicloud/data_source_alicloud_dcdn_ipa_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -157,16 +156,11 @@ func dataSourceAlicloudDcdnIpaDomainsRead(d *schema.ResourceData, meta interface
}
}
var response map[string]interface{}
conn, err := client.NewDcdnClient()
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("2018-01-15"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("dcdn", "2018-01-15", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
4 changes: 2 additions & 2 deletions alicloud/data_source_alicloud_dcdn_ipa_domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestAccAlicloudDCDNIpaDomainsDataSource(t *testing.T) {
"domains.0.description": "",
"domains.0.id": CHECKSET,
"domains.0.resource_group_id": CHECKSET,
"domains.0.scope": "domestic",
"domains.0.scope": "overseas",
"domains.0.sources.#": "1",
"domains.0.sources.0.content": "www.alicloud-provider.cn",
"domains.0.sources.0.port": "8898",
Expand Down Expand Up @@ -108,7 +108,7 @@ variable "domain_name" {

resource "alicloud_dcdn_ipa_domain" "default" {
domain_name = "${var.domain_name}"
scope = "domestic"
scope = "overseas"
sources {
content = "www.alicloud-provider.cn"
port = 8898
Expand Down
10 changes: 2 additions & 8 deletions alicloud/data_source_alicloud_dcdn_waf_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -97,16 +96,11 @@ func dataSourceAlicloudDcdnWafDomainsRead(d *schema.ResourceData, meta interface
}
}
var response map[string]interface{}
conn, err := client.NewDcdnClient()
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("2018-01-15"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("dcdn", "2018-01-15", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
10 changes: 2 additions & 8 deletions alicloud/data_source_alicloud_dcdn_waf_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -125,16 +124,11 @@ func dataSourceAlicloudDcdnWafPoliciesRead(d *schema.ResourceData, meta interfac
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewDcdnClient()
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("2018-01-15"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("dcdn", "2018-01-15", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
11 changes: 2 additions & 9 deletions alicloud/data_source_alicloud_dcdn_waf_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -225,28 +224,22 @@ func dataSourceAlicloudDcdnWafRulesRead(d *schema.ResourceData, meta interface{}
}
}

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

for {
action := "DescribeDcdnWafRules"
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("2018-01-15"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("dcdn", "2018-01-15", 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
Loading
Loading