From dd6c042577e13941a0c3494a1df79ee6de86f2c5 Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Wed, 16 Oct 2024 14:43:19 +0800 Subject: [PATCH 1/2] client: Improves the method of setting endpoint --- alicloud/connectivity/client.go | 252 ++++++++++++------------- alicloud/connectivity/endpoint.go | 293 +++++++++++++++++++++++++++--- alicloud/connectivity/helper.go | 7 + alicloud/provider.go | 172 +++++++++++++++++- 4 files changed, 566 insertions(+), 158 deletions(-) create mode 100644 alicloud/connectivity/helper.go diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index 4e027e09340e..a1d664e2f9a3 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -604,66 +604,6 @@ func (client *AliyunClient) WithEssClient(do func(*ess.Client) (interface{}, err return do(client.essconn) } -type ossCredentials struct { - client *AliyunClient -} - -func (defCre *ossCredentials) GetAccessKeyID() string { - value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeyId() - if err == nil && value != nil { - return *value - } - return defCre.client.config.AccessKey -} - -func (defCre *ossCredentials) GetAccessKeySecret() string { - value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeySecret() - if err == nil && value != nil { - return *value - } - return defCre.client.config.SecretKey -} - -func (defCre *ossCredentials) GetSecurityToken() string { - value, err := defCre.client.teaSdkConfig.Credential.GetSecurityToken() - if err == nil && value != nil { - return *value - } - return defCre.client.config.SecurityToken -} - -type ossCredentialsProvider struct { - client *AliyunClient -} - -func (defBuild *ossCredentialsProvider) GetCredentials() oss.Credentials { - return &ossCredentials{client: defBuild.client} -} - -func (client *AliyunClient) GetRetryTimeout(defaultTimeout time.Duration) time.Duration { - - maxRetryTimeout := client.config.MaxRetryTimeout - if maxRetryTimeout != 0 { - return time.Duration(maxRetryTimeout) * time.Second - } - - return defaultTimeout -} - -func (client *AliyunClient) GenRoaParam(action, method, version, path string) *openapi.Params { - return &openapi.Params{ - Action: tea.String(action), - Version: tea.String(version), - Protocol: tea.String(client.config.Protocol), - Pathname: tea.String(path), - Method: tea.String(method), - AuthType: tea.String("AK"), - Style: tea.String("ROA"), - ReqBodyType: tea.String("formData"), - BodyType: tea.String("json"), - } -} - func (client *AliyunClient) WithOssClient(do func(*oss.Client) (interface{}, error)) (interface{}, error) { goSdkMutex.Lock() defer goSdkMutex.Unlock() @@ -2258,7 +2198,7 @@ func (client *AliyunClient) WithDcdnClient(do func(*dcdn.Client) (interface{}, e } func (client *AliyunClient) WithRKvstoreClient(do func(*r_kvstore.Client) (interface{}, error)) (interface{}, error) { - productCode := "redisa" + productCode := "r_kvstore" endpoint := "" if client.r_kvstoreConn == nil { if endpoint == "" { @@ -2372,7 +2312,7 @@ func (client *AliyunClient) NewConfigClient() (*rpc.Client, error) { } func (client *AliyunClient) NewWafClient() (*rpc.Client, error) { - productCode := "waf" + productCode := "waf_openapi" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2541,7 +2481,7 @@ func (client *AliyunClient) NewDcdnClient() (*rpc.Client, error) { } func (client *AliyunClient) NewOdpsClient() (*roa.Client, error) { - productCode := "odps" + productCode := "maxcompute" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2564,7 +2504,7 @@ func (client *AliyunClient) NewOdpsClient() (*roa.Client, error) { } func (client *AliyunClient) NewRessharingClient() (*rpc.Client, error) { - productCode := "ressharing" + productCode := "resourcesharing" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2587,7 +2527,7 @@ func (client *AliyunClient) NewRessharingClient() (*rpc.Client, error) { } func (client *AliyunClient) NewGaplusClient() (*rpc.Client, error) { - productCode := "gaplus" + productCode := "ga" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2704,7 +2644,7 @@ func (client *AliyunClient) NewHitsdbClient() (*rpc.Client, error) { } func (client *AliyunClient) NewAistudioClient() (*rpc.Client, error) { - productCode := "aistudio" + productCode := "brain_industrial" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2928,7 +2868,7 @@ func (client *AliyunClient) NewNasClient() (*rpc.Client, error) { } func (client *AliyunClient) NewDmsenterpriseClient() (*rpc.Client, error) { - productCode := "dmsenterprise" + productCode := "dms_enterprise" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -2953,7 +2893,7 @@ func (client *AliyunClient) NewDmsenterpriseClient() (*rpc.Client, error) { } func (client *AliyunClient) NewHcsSgwClient() (*rpc.Client, error) { - productCode := "hcs_sgw" + productCode := "sgw" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3164,7 +3104,7 @@ func (client *AliyunClient) NewEventbridgeClient() (*rpc.Client, error) { } func (client *AliyunClient) NewOnsproxyClient() (*rpc.Client, error) { - productCode := "onsproxy" + productCode := "amqp" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3187,7 +3127,7 @@ func (client *AliyunClient) NewOnsproxyClient() (*rpc.Client, error) { } func (client *AliyunClient) NewCdsClient() (*rpc.Client, error) { - productCode := "cds" + productCode := "cassandra" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3315,7 +3255,7 @@ func (client *AliyunClient) NewCloudfwClient() (*rpc.Client, error) { } func (client *AliyunClient) NewServerlessClient() (*roa.Client, error) { - productCode := "serverless" + productCode := "sae" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3363,7 +3303,7 @@ func (client *AliyunClient) NewAlbClient() (*rpc.Client, error) { } func (client *AliyunClient) NewRedisaClient() (*rpc.Client, error) { - productCode := "redisa" + productCode := "r_kvstore" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3388,7 +3328,7 @@ func (client *AliyunClient) NewRedisaClient() (*rpc.Client, error) { } func (client *AliyunClient) NewGwsecdClient() (*rpc.Client, error) { - productCode := "gwsecd" + productCode := "ecd" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3463,7 +3403,7 @@ func (client *AliyunClient) NewScdnClient() (*rpc.Client, error) { } func (client *AliyunClient) NewDataworkspublicClient() (*rpc.Client, error) { - productCode := "dataworkspublic" + productCode := "dataworks_public" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3539,7 +3479,7 @@ func (client *AliyunClient) NewCddcClient() (*rpc.Client, error) { } func (client *AliyunClient) NewMscopensubscriptionClient() (*rpc.Client, error) { - productCode := "mscsub" + productCode := "mscopensubscription" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3638,7 +3578,7 @@ func (client *AliyunClient) NewSasClient() (*rpc.Client, error) { } func (client *AliyunClient) NewAlidfsClient() (*rpc.Client, error) { - productCode := "alidfs" + productCode := "dfs" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3888,7 +3828,7 @@ func (client *AliyunClient) NewCloudssoClient() (*rpc.Client, error) { } func (client *AliyunClient) NewSwasClient() (*rpc.Client, error) { - productCode := "swas" + productCode := "swas_open" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3938,7 +3878,7 @@ func (client *AliyunClient) NewVsClient() (*rpc.Client, error) { } func (client *AliyunClient) NewQuickbiClient() (*rpc.Client, error) { - productCode := "quickbi" + productCode := "quickbi_public" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -3963,7 +3903,7 @@ func (client *AliyunClient) NewQuickbiClient() (*rpc.Client, error) { } func (client *AliyunClient) NewDevopsrdcClient() (*rpc.Client, error) { - productCode := "rdcdevops" + productCode := "devops_rdc" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4038,7 +3978,7 @@ func (client *AliyunClient) NewOpensearchClient() (*roa.Client, error) { } func (client *AliyunClient) NewGdsClient() (*rpc.Client, error) { - productCode := "gds" + productCode := "gdb" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4163,7 +4103,7 @@ func (client *AliyunClient) NewImpClient() (*rpc.Client, error) { } func (client *AliyunClient) NewMhubClient() (*rpc.Client, error) { - productCode := "emas" + productCode := "mhub" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4210,7 +4150,7 @@ func (client *AliyunClient) NewServicemeshClient() (*rpc.Client, error) { } func (client *AliyunClient) NewAcrClient() (*rpc.Client, error) { - productCode := "acr" + productCode := "cr" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4235,7 +4175,7 @@ func (client *AliyunClient) NewAcrClient() (*rpc.Client, error) { } func (client *AliyunClient) NewEdsuserClient() (*rpc.Client, error) { - productCode := "eds-user" + productCode := "eds_user" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4367,7 +4307,7 @@ func (client *AliyunClient) NewEssClient() (*rpc.Client, error) { } func (client *AliyunClient) NewDdosbasicClient() (*rpc.Client, error) { - productCode := "ddosbasic" + productCode := "antiddos_public" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4468,7 +4408,7 @@ func (client *AliyunClient) NewEdasClient() (*roa.Client, error) { } func (client *AliyunClient) NewEdasschedulerxClient() (*rpc.Client, error) { - productCode := "edasschedulerx" + productCode := "schedulerx2" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4494,7 +4434,7 @@ func (client *AliyunClient) NewEdasschedulerxClient() (*rpc.Client, error) { } func (client *AliyunClient) NewEhsClient() (*rpc.Client, error) { - productCode := "ehs" + productCode := "ehpc" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4519,7 +4459,7 @@ func (client *AliyunClient) NewEhsClient() (*rpc.Client, error) { } func (client *AliyunClient) NewDysmsClient() (*rpc.Client, error) { - productCode := "dysms" + productCode := "sms" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4544,7 +4484,7 @@ func (client *AliyunClient) NewDysmsClient() (*rpc.Client, error) { } func (client *AliyunClient) NewFcClient() (*roa.Client, error) { - productCode := "fc" + productCode := "fc_open" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4651,7 +4591,7 @@ func (client *AliyunClient) NewVpcpeerClient() (*rpc.Client, error) { } func (client *AliyunClient) NewCbsClient() (*rpc.Client, error) { - productCode := "cbs" + productCode := "dbs" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4726,7 +4666,7 @@ func (client *AliyunClient) NewEbsClient() (*rpc.Client, error) { } func (client *AliyunClient) NewMnsClient() (*rpc.Client, error) { - productCode := "mns" + productCode := "mns_open" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4803,7 +4743,7 @@ func (client *AliyunClient) NewDasClient() (*rpc.Client, error) { } func (client *AliyunClient) NewCloudfirewallClient() (*rpc.Client, error) { - productCode := "cloudfirewall" + productCode := "cloudfw" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4855,7 +4795,7 @@ func (client *AliyunClient) NewThreatdetectionClient() (*rpc.Client, error) { } func (client *AliyunClient) NewSrvcatalogClient() (*rpc.Client, error) { - productCode := "srvcatalog" + productCode := "servicecatalog" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4881,7 +4821,7 @@ func (client *AliyunClient) NewSrvcatalogClient() (*rpc.Client, error) { } func (client *AliyunClient) NewVpcPeerClient() (*rpc.Client, error) { - productCode := "VpcPeer" + productCode := "vpcpeer" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4933,7 +4873,7 @@ func (client *AliyunClient) NewEfloClient() (*rpc.Client, error) { } func (client *AliyunClient) NewOceanbaseClient() (*rpc.Client, error) { - productCode := "oceanbase" + productCode := "oceanbasepro" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -4958,7 +4898,7 @@ func (client *AliyunClient) NewOceanbaseClient() (*rpc.Client, error) { } func (client *AliyunClient) NewBeebotClient() (*rpc.Client, error) { - productCode := "beebot" + productCode := "chatbot" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -5012,7 +4952,7 @@ func (client *AliyunClient) NewComputenestClient() (*rpc.Client, error) { return conn, nil } func (client *AliyunClient) NewRedisClient() (*rpc.Client, error) { - productCode := "redisa" + productCode := "r_kvstore" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -5193,7 +5133,7 @@ func (client *AliyunClient) NewSlsClient() (*openapi.Client, error) { return openapiClient, nil } func (client *AliyunClient) NewRocketmqClient() (*roa.Client, error) { - productCode := "rmq" + productCode := "rocketmq" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -5433,7 +5373,7 @@ func (client *AliyunClient) NewCloudmonitorserviceClient() (*rpc.Client, error) return conn, nil } func (client *AliyunClient) NewWafv3Client() (*rpc.Client, error) { - productCode := "waf" + productCode := "waf_openapi" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -5457,7 +5397,7 @@ func (client *AliyunClient) NewWafv3Client() (*rpc.Client, error) { return conn, nil } func (client *AliyunClient) NewDfsClient() (*rpc.Client, error) { - productCode := "alidfs" + productCode := "dfs" endpoint := "" if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { if err := client.loadEndpoint(productCode); err != nil { @@ -5480,30 +5420,7 @@ func (client *AliyunClient) NewDfsClient() (*rpc.Client, error) { } return conn, nil } -func (client *AliyunClient) NewAmqpClient() (*rpc.Client, error) { - productCode := "onsproxy" - endpoint := "" - if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { - if err := client.loadEndpoint(productCode); err != nil { - endpoint = fmt.Sprintf("amqp-open.%s.aliyuncs.com", client.config.RegionId) - client.config.Endpoints.Store(productCode, endpoint) - log.Printf("[ERROR] loading %s endpoint got an error: %#v. Using the endpoint %s instead.", productCode, err, endpoint) - } - } - if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" { - endpoint = v.(string) - } - if endpoint == "" { - return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) - } - sdkConfig := client.teaSdkConfig - sdkConfig.SetEndpoint(endpoint) - conn, err := rpc.NewClient(&sdkConfig) - if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err) - } - return conn, nil -} + func (client *AliyunClient) NewCenClient() (*rpc.Client, error) { productCode := "cbn" endpoint := "" @@ -5601,21 +5518,32 @@ func (client *AliyunClient) NewGovernanceClient() (*rpc.Client, error) { return conn, nil } -func (client *AliyunClient) loadApiEndpoint(locationCode string) (string, error) { - if v, ok := client.config.Endpoints.Load(locationCode); !ok || v.(string) == "" { - if err := client.loadEndpoint(locationCode); err != nil { - return "", fmt.Errorf("[ERROR] loading %s endpoint got an error: %#v.", locationCode, err) +func (client *AliyunClient) loadApiEndpoint(productCode string) (string, error) { + if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { + if err := client.loadEndpoint(productCode); err != nil { + return "", fmt.Errorf("[ERROR] loading %s endpoint got an error: %#v.", productCode, err) } } else { return v.(string), nil } - if v, ok := client.config.Endpoints.Load(locationCode); ok && v.(string) != "" { + if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" { return v.(string), nil } - return "", fmt.Errorf("[ERROR] missing the product %s endpoint.", locationCode) + return "", fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) } -func (client *AliyunClient) RpcPost(locationCode string, apiVersion string, apiName string, query map[string]interface{}, body map[string]interface{}, autoRetry bool) (map[string]interface{}, error) { - endpoint, err := client.loadApiEndpoint(locationCode) + +// RpcPost invoking RPC API request with POST method +// parameters: +// +// apiProductCode: API Product code, its value equals to the gateway code of the API +// apiVersion - API version +// apiName - API Name +// query - API parameters in query +// body - API parameters in body +// autoRetry - whether to auto retry while the runtime has a 5xx error +func (client *AliyunClient) RpcPost(apiProductCode string, apiVersion string, apiName string, query map[string]interface{}, body map[string]interface{}, autoRetry bool) (map[string]interface{}, error) { + apiProductCode = strings.ToLower(ConvertKebabToSnake(apiProductCode)) + endpoint, err := client.loadApiEndpoint(apiProductCode) if err != nil { return nil, err } @@ -5630,9 +5558,69 @@ func (client *AliyunClient) RpcPost(locationCode string, apiVersion string, apiN sdkConfig.SetSecurityToken(*credential.SecurityToken) conn, err := rpc.NewClient(&sdkConfig) if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", locationCode, err) + return nil, fmt.Errorf("unable to initialize the %s api client: %#v", apiProductCode, err) } runtime := &util.RuntimeOptions{} runtime.SetAutoretry(autoRetry) return conn.DoRequest(tea.String(apiName), nil, tea.String("POST"), tea.String(apiVersion), tea.String("AK"), query, body, runtime) } + +type ossCredentials struct { + client *AliyunClient +} + +func (defCre *ossCredentials) GetAccessKeyID() string { + value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeyId() + if err == nil && value != nil { + return *value + } + return defCre.client.config.AccessKey +} + +func (defCre *ossCredentials) GetAccessKeySecret() string { + value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeySecret() + if err == nil && value != nil { + return *value + } + return defCre.client.config.SecretKey +} + +func (defCre *ossCredentials) GetSecurityToken() string { + value, err := defCre.client.teaSdkConfig.Credential.GetSecurityToken() + if err == nil && value != nil { + return *value + } + return defCre.client.config.SecurityToken +} + +type ossCredentialsProvider struct { + client *AliyunClient +} + +func (defBuild *ossCredentialsProvider) GetCredentials() oss.Credentials { + return &ossCredentials{client: defBuild.client} +} + +func (client *AliyunClient) GetRetryTimeout(defaultTimeout time.Duration) time.Duration { + + maxRetryTimeout := client.config.MaxRetryTimeout + if maxRetryTimeout != 0 { + return time.Duration(maxRetryTimeout) * time.Second + } + + return defaultTimeout +} + +func (client *AliyunClient) GenRoaParam(action, method, version, path string) *openapi.Params { + return &openapi.Params{ + Action: tea.String(action), + Version: tea.String(version), + Protocol: tea.String(client.config.Protocol), + Pathname: tea.String(path), + Method: tea.String(method), + AuthType: tea.String("AK"), + Style: tea.String("ROA"), + ReqBodyType: tea.String("formData"), + BodyType: tea.String("json"), + } +} diff --git a/alicloud/connectivity/endpoint.go b/alicloud/connectivity/endpoint.go index cf815a3866f4..3199b895862a 100644 --- a/alicloud/connectivity/endpoint.go +++ b/alicloud/connectivity/endpoint.go @@ -4,6 +4,7 @@ import ( "encoding/xml" "fmt" "io/ioutil" + "log" "os" "regexp" "strings" @@ -165,26 +166,271 @@ func loadEndpoint(region string, serviceCode ServiceCode) string { return "" } -// regularProductCode specially records those product codes that -// cannot be parsed out by the location service or have been confirmed to be regional endpoints. +// productCodeToLocationCode records all products' code mapping to location +// Key: product code, its value equals to the gateway code of the API after converting it to lowercase and using underscores +// Value: location code +var productCodeToLocationCode = map[string]string{ + "ecs": "ecs", // ECS + "adb": "ads", //ADB + "ess": "ess", //AutoScaling + "cs": "cs", // ACK + "polardb": "polardb", // PolarDB + "cr": "acr", // CR + "dds": "dds", //MongoDB + "gpdb": "gpdb", //GPDB + "fc_open": "fc", // FC, FCV2 + "fc": "fc", // FCV3 + "apigateway": "apigateway", + "datahub": "datahub", // DataHub + "mns_open": "mns", // MessageService + "elasticsearch": "elasticsearch", // Elasticsearch + "ddoscoo": "ddoscoo", // DdosCoo + "ddosbgp": "ddosbgp", // DdosBgp + "antiddos_public": "ddosbasic", // DdosBasic + "bssopenapi": "bssopenapi", //BssOpenApi + "alikafka": "alikafka", //AliKafka + "emr": "emr", //EMR + "smartag": "smartag", // Smartag + "yundun_dbaudit": "dbaudit", //DBAudit + "yundun_bastionhost": "bastionhost", //Bastionhost + "hbase": "hbase", //HBase + "edas": "edas", // EDAS + "alidns": "alidns", //Alidns + "cassandra": "cds", //Cassandra + "eci": "eci", // ECI + "dcdn": "dcdn", // DCDN + "r_kvstore": "redisa", // Redis + "ons": "ons", //Ons + "config": "config", //Config + "fnf": "fnf", // FnF + "ros": "ros", // ROS + "mse": "mse", // MSE + "pvtz": "pvtz", //PrivateZone + "privatelink": "privatelink", // PrivateLink + "maxcompute": "odps", //MaxCompute + "resourcesharing": "ressharing", // ResourceManager + "ga": "gaplus", // Ga + "actiontrail": "actiontrail", //ActionTrail + "hitsdb": "hitsdb", //Lindorm + "brain_industrial": "aistudio", //BrainIndustrial + "eipanycast": "eipanycast", // Eipanycast + "oos": "oos", // OOS + "ims": "ims", //IMS + "resourcemanager": "resourcemanager", // ResourceManager + "nas": "nas", //NAS + "dms_enterprise": "dmsenterprise", //DMSEnterprise + "sgw": "hcs_sgw", // CloudStorageGateway + "slb": "slb", // SLB + "kms": "kms", //KMS + "dm": "dm", //DirectMail + "eventbridge": "eventbridge", // EventBridge + "hbr": "hbr", //HBR + "cas": "cas", //SSLCertificatesService + "arms": "arms", // ARMS + "cloudfw": "cloudfirewall", //CloudFirewall + "sae": "serverless", //SAE + "alb": "alb", // ALB + "ecd": "gwsecd", // ECD + "cloudphone": "cloudphone", // ECP + "scdn": "scdn", //SCDN + "dataworks_public": "dide", //DataWorks + "cdn": "cdn", // CDN + "cddc": "cddc", // CDDC + "mscopensubscription": "mscsub", //MscSub + "sddp": "sddp", // SDDP + "sas": "sas", // ThreatDetection + "ehpc": "ehs", // Ehpc + "ens": "ens", // ENS + "iot": "iot", // Iot + "imm": "imm", // IMM + "clickhouse": "clickhouse", // ClickHouse + "selectdb": "selectdb", //SelectDB + "dts": "dts", // DTS + "dg": "dg", // DatabaseGateway + "cloudsso": "cloudsso", // CloudSSO + "swas_open": "swas", // SimpleApplicationServer + "vs": "vs", // VideoSurveillanceSystem + "quickbi_public": "quickbi", // QuickBI + "devops_rdc": "rdcdevops", // RDC + "vod": "vod", // VOD + "opensearch": "opensearch", // OpenSearch + "gdb": "gds", // GraphDatabase + "dbfs": "dbfs", // DBFS + "eais": "eais", // EAIS + "cloudauth": "cloudauth", // Cloudauth + "imp": "imp", // IMP + "mhub": "emas", // MHUB + "servicemesh": "servicemesh", // ServiceMesh + "eds_user": "edsuser", // ECD + "tag": "tag", // Tag + "schedulerx2": "edasschedulerx", // Schedulerx + "sms": "dysms", // SMS + "vpcpeer": "vpcpeer", // VpcPeer + "dbs": "cbs", // DBS + "nlb": "nlb", // NLB + "ebs": "ebs", // EBS + "bpstudio": "bpstudio", // BPStudio + "das": "hdm", // DAS + "servicecatalog": "srvcatalog", // ServiceCatalog + "eflo": "eflo", //Eflo + "oceanbasepro": "oceanbase", // OceanBase + "chatbot": "beebot", // Chatbot + "computenest": "computenest", // ComputeNest + "drds": "drds", // DRDS + "polardbx": "polardbx", // DRDS + "adcp": "adcp", // AckOne + "sls": "sls", // SLS + "rocketmq": "rmq", // RocketMQ + "resourcecenter": "", // ResourceManager + "hologram": "hologram", // Hologram + "foasconsole": "foasconsole", // RealtimeCompute + "vpc": "vpc", // VPC, VPNGateway,ExpressConnect, CBWP, EIP + "sss": "oss", // OSS + "cms": "cms", // CloudMonitorService + "waf_openapi": "waf", //WAFV3,WAF + "dfs": "alidfs", //DFS + "amqp": "onsproxy", // Amqp + "cbn": "cbn", // CEN + "expressconnectrouter": "ecr", // ExpressConnectRouter + "green": "green", // Aligreen + "governance": "governance", // Governance + "ots": "ots", // OTS + "tablestore": "ots", // OTS + "ram": "ram", //RAM + "market": "market", //Market +} + +// irregularProductEndpoint specially records those product codes that +// cannot be parsed out by the location service. +// Key: product code, its value equals to the gateway code of the API after converting it to lowercase and using underscores +// Value: product endpoint // The priority of this configuration is higher than location service, lower than user environment variable configuration -var regularProductCode = map[string]string{ - "mse": "mse.%s.aliyuncs.com", - "tablestore": "tablestore.%s.aliyuncs.com", - "bssopenapi": BssOpenAPIEndpointDomestic, +var irregularProductEndpoint = map[string]string{ + "tablestore": "tablestore.%s.aliyuncs.com", + "bssopenapi": BssOpenAPIEndpointDomestic, + "ram": "ram.aliyuncs.com", + "ddoscoo": "ddoscoo.cn-hangzhou.aliyuncs.com", + "dcdn": "dcdn.aliyuncs.com", + "config": "config.cn-shanghai.aliyuncs.com", + "ga": "ga.cn-hangzhou.aliyuncs.com", + "brain_industrial": "brain-industrial.cn-hangzhou.aliyuncs.com", + "eipanycast": "eipanycast.cn-hangzhou.aliyuncs.com", + "ims": "ims.aliyuncs.com", + "resourcemanager": "resourcemanager.aliyuncs.com", + "quotas": "quotas.aliyuncs.com", + "cassandra": "cassandra.aliyuncs.com", + "cas": "cas.aliyuncs.com", + "cloudfw": "cloudfw.aliyuncs.com", + "scdn": "scdn.aliyuncs.com", + "cdn": "cdn.aliyuncs.com", + "mscopensubscription": "mscopensubscription.aliyuncs.com", + "cloudauth": "cloudauth.aliyuncs.com", + "imp": "imp.aliyuncs.com", + "mhub": "mhub.cn-shanghai.aliyuncs.com", + "eds_user": "eds-user.cn-shanghai.aliyuncs.com", //eds-user.ap-southeast-1.aliyuncs.com + "vpcpeer": "vpcpeer.aliyuncs.com", + "das": "das.cn-shanghai.aliyuncs.com", + "servicecatalog": "servicecatalog.cn-hangzhou.aliyuncs.com", + "chatbot": "chatbot.cn-shanghai.aliyuncs.com", + "computenest": "computenest.cn-hangzhou.aliyuncs.com", + "resourcecenter": "resourcecenter.aliyuncs.com", //resourcecenter-intl.aliyuncs.com + "market": "market.aliyuncs.com", +} + +// regularProductEndpoint specially records those product codes that have been confirmed to be +// regional or central endpoints. +// Key: product code, its value equals to the gateway code of the API after converting it to lowercase and using underscores +// Value: product endpoint +// The priority of this configuration is lower than location service, and as a backup endpoint +var regularProductEndpoint = map[string]string{ + "mse": "mse.%s.aliyuncs.com", + "vpc": "vpc.%s.aliyuncs.com", + "oss": "oss-%s.aliyuncs.com", + "cr": "cr.%s.aliyuncs.com", + "cms": "metrics.%s.aliyuncs.com", + "sls": "%s.log.aliyuncs.com", + "drds": "drds.%s.aliyuncs.com", + "polardbx": "polardbx.%s.aliyuncs.com", + "fc_open": "%s.fc.aliyuncs.com", + "fc": "%s.fc.aliyuncs.com", + "apigateway": "apigateway.%s.aliyuncs.com", + "mns_open": "mns-open.%s.aliyuncs.com", + "elasticsearch": "elasticsearch.%s.aliyuncs.com", + "alikafka": "alikafka.%s.aliyuncs.com", + "emr": "emr.%s.aliyuncs.com", + "smartag": "smartag.%s.aliyuncs.com", + "alidns": "alidns.%s.aliyuncs.com", + "eci": "eci.%s.aliyuncs.com", + "ons": "ons.%s.aliyuncs.com", + "ros": "ros.aliyuncs.com", + "pvtz": "pvtz.aliyuncs.com", + "privatelink": "privatelink.%s.aliyuncs.com", + "maxcompute": "maxcompute.%s.aliyuncs.com", + "resourcesharing": "resourcesharing.%s.aliyuncs.com", + "actiontrail": "actiontrail.%s.aliyuncs.com", + "hitsdb": "hitsdb.%s.aliyuncs.com", + "oos": "oos.%s.aliyuncs.com", + "nas": "nas.%s.aliyuncs.com", + "dms_enterprise": "dms-enterprise.%s.aliyuncs.com", + "kms": "kms.%s.aliyuncs.com", + "eventbridge": "eventbridge-console.%s.aliyuncs.com", + "hbr": "hbr.%s.aliyuncs.com", + "arms": "arms.%s.aliyuncs.com", + "sae": "sae.%s.aliyuncs.com", + "alb": "alb.%s.aliyuncs.com", + "ecd": "ecd.%s.aliyuncs.com", + "cloudphone": "cloudphone.%s.aliyuncs.com", + "dataworks_public": "dataworks.%s.aliyuncs.com", + "sas": "tds.aliyuncs.com", + "ehpc": "ehpc.%s.aliyuncs.com", + "ens": "ens.aliyuncs.com", + "iot": "iot.%s.aliyuncs.com", + "imm": "imm.%s.aliyuncs.com", + "swas_open": "swas.%s.aliyuncs.com", + "vs": "vs.%s.aliyuncs.com", + "vod": "vod.%s.aliyuncs.com", + "opensearch": "opensearch.%s.aliyuncs.com", + "dbfs": "dbfs.%s.aliyuncs.com", + "eais": "eais.%s.aliyuncs.com", + "servicemesh": "servicemesh.aliyuncs.com", + "tag": "tag.%s.aliyuncs.com", + "schedulerx2": "schedulerx.%s.aliyuncs.com", + "dbs": "dbs-api.%s.aliyuncs.com", + "nlb": "nlb.%s.aliyuncs.com", + "ebs": "ebs.%s.aliyuncs.com", + "eflo": "eflo.%s.aliyuncs.com", + "oceanbasepro": "oceanbasepro.%s.aliyuncs.com", + "adcp": "adcp.%s.aliyuncs.com", + "rocketmq": "rocketmq.%s.aliyuncs.com", + "hologram": "hologram.%s.aliyuncs.com", + "foasconsole": "foasconsole.aliyuncs.com", + "cs": "cs.%s.aliyuncs.com", + "waf_openapi": "wafopenapi.cn-hangzhou.aliyuncs.com", // wafopenapi.ap-southeast-1.aliyuncs.com + "dfs": "dfs.%s.aliyuncs.com", + "amqp": "amqp-open.%s.aliyuncs.com", + "cbn": "cbn.aliyuncs.com", + "expressconnectrouter": "expressconnectrouter.cn-shanghai.aliyuncs.com", + "green": "green.%s.aliyuncs.com", + "governance": "governance.cn-hangzhou.aliyuncs.com", // governance.ap-southeast-1.aliyuncs.com + "sms": "dysmsapi.aliyuncs.com", // dysmsapi.ap-southeast-1.aliyuncs.com + "sddp": "sddp.cn-zhangjiakou.aliyuncs.com", // sddp.ap-southeast-1.aliyuncs.com } // NOTE: The productCode must be lower. func (client *AliyunClient) loadEndpoint(productCode string) error { // Firstly, load endpoint from environment variables - endpoint := strings.TrimSpace(os.Getenv(fmt.Sprintf("%s_ENDPOINT", strings.ToUpper(productCode)))) + endpoint := strings.TrimSpace(os.Getenv(fmt.Sprintf("ALIBABA_CLOUD_ENDPOINT_%s", strings.ToUpper(productCode)))) + if endpoint == "" { + // Compatible with the previous implementation method + endpoint = strings.TrimSpace(os.Getenv(fmt.Sprintf("%s_ENDPOINT", strings.ToUpper(productCode)))) + } if endpoint != "" { client.config.Endpoints.Store(productCode, endpoint) return nil } // Secondly, load endpoint from known rules - if endpointFmt, ok := regularProductCode[productCode]; ok { + if endpointFmt, ok := irregularProductEndpoint[productCode]; ok { if strings.Contains(endpointFmt, "%s") { endpointFmt = fmt.Sprintf(endpointFmt, client.RegionId) } @@ -193,13 +439,16 @@ func (client *AliyunClient) loadEndpoint(productCode string) error { } // Thirdly, load endpoint from location - serviceCode := serviceCodeMapping[productCode] - if serviceCode == "" { - serviceCode = productCode - } - endpoint, err := client.describeEndpointForService(serviceCode) + endpoint, err := client.describeEndpointForService(productCode) if err == nil { - client.config.Endpoints.Store(strings.ToLower(serviceCode), endpoint) + client.config.Endpoints.Store(strings.ToLower(productCode), endpoint) + } else if v, ok := regularProductEndpoint[productCode]; ok { + if strings.Contains(v, "%s") { + v = fmt.Sprintf(v, client.RegionId) + } + client.config.Endpoints.Store(productCode, v) + log.Printf("[WARN] loading %s endpoint got an error: %#v. Using the endpoint %s instead.", productCode, err, v) + return nil } return err } @@ -242,9 +491,13 @@ func incrementalWait(firstDuration time.Duration, increaseDuration time.Duration retryCount++ } } -func (client *AliyunClient) describeEndpointForService(serviceCode string) (string, error) { +func (client *AliyunClient) describeEndpointForService(productCode string) (string, error) { + locationCode := productCodeToLocationCode[productCode] + if locationCode == "" { + locationCode = productCode + } args := location.CreateDescribeEndpointsRequest() - args.ServiceCode = serviceCode + args.ServiceCode = locationCode args.Id = client.config.RegionId args.Domain = client.config.LocationEndpoint if args.Domain == "" { @@ -288,18 +541,14 @@ func (client *AliyunClient) describeEndpointForService(serviceCode string) (stri return nil }) if err != nil { - return "", fmt.Errorf("Describe %s endpoint using region: %#v got an error: %#v.", serviceCode, client.RegionId, err) + return "", fmt.Errorf("Describe %s endpoint using region: %#v got an error: %#v.", productCode, client.RegionId, err) } if endpointResult == "" { - return "", fmt.Errorf("There is no any available endpoint for %s in region %s.", serviceCode, client.RegionId) + return "", fmt.Errorf("There is no any available endpoint for %s in region %s.", productCode, client.RegionId) } return endpointResult, nil } -var serviceCodeMapping = map[string]string{ - "cloudapi": "apigateway", -} - const ( OpenApiGatewayService = "apigateway.cn-hangzhou.aliyuncs.com" OpenOtsService = "ots.cn-hangzhou.aliyuncs.com" diff --git a/alicloud/connectivity/helper.go b/alicloud/connectivity/helper.go new file mode 100644 index 000000000000..ae627d33cb78 --- /dev/null +++ b/alicloud/connectivity/helper.go @@ -0,0 +1,7 @@ +package connectivity + +import "strings" + +func ConvertKebabToSnake(s string) string { + return strings.ReplaceAll(s, "-", "_") +} diff --git a/alicloud/provider.go b/alicloud/provider.go index 435c2d68fa39..0368a585ab2e 100644 --- a/alicloud/provider.go +++ b/alicloud/provider.go @@ -1908,6 +1908,12 @@ func providerConfigure(d *schema.ResourceData, p *schema.Provider) (interface{}, for _, endpointsSetI := range endpointsSet.List() { endpoints := endpointsSetI.(map[string]interface{}) for key, val := range endpoints { + // Compatible with the deprecated endpoint setting + if val == nil || val.(string) == "" { + if v, ok := deprecatedEndpointMap[key]; ok { + val = endpoints[v] + } + } endpointInit.Store(key, val) } config.EcsEndpoint = strings.TrimSpace(endpoints["ecs"].(string)) @@ -2559,6 +2565,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["beebot_endpoint"], }, + "chatbot": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["beebot_endpoint"], + }, "eflo": { Type: schema.TypeString, @@ -2573,7 +2585,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["srvcatalog_endpoint"], }, - + "servicecatalog": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["srvcatalog_endpoint"], + }, "cloudfirewall": { Type: schema.TypeString, Optional: true, @@ -2622,6 +2639,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["cbs_endpoint"], }, + "dbs": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["cbs_endpoint"], + }, "vpcpeer": { Type: schema.TypeString, @@ -2636,6 +2659,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["dysms_endpoint"], }, + "sms": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["dysms_endpoint"], + }, "edas": { Type: schema.TypeString, @@ -2650,7 +2679,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["edasschedulerx_endpoint"], }, - + "schedulerx2": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["edasschedulerx_endpoint"], + }, "ehs": { Type: schema.TypeString, Optional: true, @@ -2672,6 +2706,12 @@ func endpointsSchema() *schema.Schema { Description: descriptions["ddosbasic_endpoint"], }, + "antiddos_public": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["ddosbasic_endpoint"], + }, "smartag": { Type: schema.TypeString, Optional: true, @@ -2685,6 +2725,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["oceanbase_endpoint"], }, + "oceanbasepro": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["oceanbase_endpoint"], + }, "gaplus": { Type: schema.TypeString, @@ -2706,6 +2752,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["edsuser_endpoint"], }, + "eds_user": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["edsuser_endpoint"], + }, "acr": { Type: schema.TypeString, @@ -2751,6 +2803,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["quickbi_endpoint"], }, + "quickbi_public": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["quickbi_endpoint"], + }, "vod": { Type: schema.TypeString, Optional: true, @@ -2769,6 +2827,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["gds_endpoint"], }, + "gdb": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["gds_endpoint"], + }, "dbfs": { Type: schema.TypeString, Optional: true, @@ -2824,6 +2888,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["swas_endpoint"], }, + "swas_open": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["swas_endpoint"], + }, "imm": { Type: schema.TypeString, @@ -2850,6 +2920,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["alidfs_endpoint"], }, + "dfs": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["alidfs_endpoint"], + }, "ens": { Type: schema.TypeString, @@ -2904,7 +2980,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["dataworkspublic_endpoint"], }, - + "dataworks_public": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["dataworkspublic_endpoint"], + }, "hcs_sgw": { Type: schema.TypeString, Optional: true, @@ -2937,6 +3018,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["gwsecd_endpoint"], }, + "ecd": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["gwsecd_endpoint"], + }, "scdn": { Type: schema.TypeString, Optional: true, @@ -2956,7 +3043,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["serverless_endpoint"], }, - + "sae": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["serverless_endpoint"], + }, "hbr": { Type: schema.TypeString, Optional: true, @@ -2964,6 +3056,13 @@ func endpointsSchema() *schema.Schema { Description: descriptions["hbr_endpoint"], }, + "amqp": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["onsproxy_endpoint"], + }, + "onsproxy": { Type: schema.TypeString, Optional: true, @@ -3025,6 +3124,11 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["resourcesharing_endpoint"], }, + "resourcesharing": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, "ga": { Type: schema.TypeString, Optional: true, @@ -3277,6 +3381,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["drds_endpoint"], }, + "polardbx": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["drds_endpoint"], + }, "dds": { Type: schema.TypeString, Optional: true, @@ -3307,6 +3417,12 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["fc_endpoint"], }, + "fc_open": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["fc_endpoint"], + }, "apigateway": { Type: schema.TypeString, Optional: true, @@ -3319,12 +3435,28 @@ func endpointsSchema() *schema.Schema { Default: "", Description: descriptions["datahub_endpoint"], }, + "devops_rdc": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, "mns": { Type: schema.TypeString, Optional: true, Default: "", Description: descriptions["mns_endpoint"], }, + "mns_open": { + Type: schema.TypeString, + Optional: true, + Default: "", + Description: descriptions["mns_endpoint"], + }, + "rocketmq": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, "location": { Type: schema.TypeString, Optional: true, @@ -3539,6 +3671,38 @@ func endpointsToHash(v interface{}) int { return hashcode.String(buf.String()) } +// deprecatedEndpointMap is used to map old service name to new service name +// key: new endpoint key +// value: deprecated endpoint key +var deprecatedEndpointMap = map[string]string{ + "resourcesharing": "ressharing", + "ga": "gaplus", + "dms_enterprise": "dmsenterprise", + "sgw": "hcs_sgw", + "amqp": "onsproxy", + "cassandra": "cds", + "cloudfw": "cloudfirewall", + "sae": "serverless", + "r_kvstore": "redisa", + "ecd": "gwsecd", + "dataworks_public": "dataworkspublic", + "dfs": "alidfs", + "swas_open": "swas", + "quickbi_public": "quickbi", + "gdb": "gds", + "cr": "acr", + "eds_user": "edsuser", + "antiddos_public": "ddosbasic", + "schedulerx2": "edasschedulerx", + "ehpc": "ehs", + "sms": "dysms", + "dbs": "cbs", + "mns_open": "mns", + "servicecatalog": "srvcatalog", + "oceanbasepro": "oceanbase", + "chatbot": "beebot", +} + func getConfigFromProfile(d *schema.ResourceData, ProfileKey string) (interface{}, error) { if providerConfig == nil { From 5637926b8c11acaae6f82215dbca4e66060dbc7a Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Thu, 17 Oct 2024 09:41:19 +0800 Subject: [PATCH 2/2] Redis: Improves the invoking redis api method and supports refreshing credential automatically --- alicloud/connectivity/client.go | 5 + .../data_source_alicloud_kvstore_instances.go | 11 +- ...ource_alicloud_kvstore_audit_log_config.go | 15 +-- .../resource_alicloud_kvstore_instance.go | 70 ++---------- ...resource_alicloud_kvstore_instance_test.go | 16 +-- .../resource_alicloud_redis_tair_instance.go | 92 +++------------ alicloud/service_alicloud_r_kvstore.go | 107 +++--------------- alicloud/service_alicloud_redis_v2.go | 43 +------ 8 files changed, 56 insertions(+), 303 deletions(-) diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index a1d664e2f9a3..4aa3747f5b75 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -2236,6 +2236,11 @@ func (client *AliyunClient) WithRKvstoreClient(do func(*r_kvstore.Client) (inter r_kvstoreConn.AppendUserAgent(Module, client.config.ConfigurationSource) r_kvstoreConn.AppendUserAgent(TerraformTraceId, client.config.TerraformTraceId) client.r_kvstoreConn = r_kvstoreConn + } else { + err := client.r_kvstoreConn.InitWithOptions(client.config.RegionId, client.getSdkConfig(), client.config.getAuthCredential(true)) + if err != nil { + return nil, fmt.Errorf("unable to initialize the Redis client: %#v", err) + } } return do(client.r_kvstoreConn) } diff --git a/alicloud/data_source_alicloud_kvstore_instances.go b/alicloud/data_source_alicloud_kvstore_instances.go index 6d31a408cf61..35f0de7bbbf3 100644 --- a/alicloud/data_source_alicloud_kvstore_instances.go +++ b/alicloud/data_source_alicloud_kvstore_instances.go @@ -7,7 +7,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -437,17 +436,11 @@ func dataSourceAlicloudKvstoreInstancesRead(d *schema.ResourceData, meta interfa } var response map[string]interface{} - conn, err := client.NewRedisaClient() - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_kvstore_audit_log_config.go b/alicloud/resource_alicloud_kvstore_audit_log_config.go index a4d8cd61501a..c9c678c91a28 100644 --- a/alicloud/resource_alicloud_kvstore_audit_log_config.go +++ b/alicloud/resource_alicloud_kvstore_audit_log_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" @@ -53,12 +52,9 @@ func resourceAlicloudKvstoreAuditLogConfig() *schema.Resource { func resourceAlicloudKvstoreAuditLogConfigCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "ModifyAuditLogConfig" request := make(map[string]interface{}) - conn, err := client.NewRedisaClient() - if err != nil { - return WrapError(err) - } if v, ok := d.GetOkExists("db_audit"); ok { request["DbAudit"] = v } @@ -70,7 +66,7 @@ func resourceAlicloudKvstoreAuditLogConfigCreate(d *schema.ResourceData, meta in } 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("2015-01-01"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -123,11 +119,8 @@ func resourceAlicloudKvstoreAuditLogConfigRead(d *schema.ResourceData, meta inte func resourceAlicloudKvstoreAuditLogConfigUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) rKvstoreService := RKvstoreService{client} - conn, err := client.NewRedisaClient() - if err != nil { - return WrapError(err) - } var response map[string]interface{} + var err error update := false request := map[string]interface{}{ "InstanceId": d.Id(), @@ -150,7 +143,7 @@ func resourceAlicloudKvstoreAuditLogConfigUpdate(d *schema.ResourceData, meta in action := "ModifyAuditLogConfig" 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("2015-01-01"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_kvstore_instance.go b/alicloud/resource_alicloud_kvstore_instance.go index 5a61e93412ab..8f8e1a20c747 100644 --- a/alicloud/resource_alicloud_kvstore_instance.go +++ b/alicloud/resource_alicloud_kvstore_instance.go @@ -8,8 +8,6 @@ import ( "strings" "time" - util "github.com/alibabacloud-go/tea-utils/service" - "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" r_kvstore "github.com/aliyun/alibaba-cloud-sdk-go/services/r-kvstore" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -434,12 +432,9 @@ func resourceAliCloudKvstoreInstanceCreate(d *schema.ResourceData, meta interfac client := meta.(*connectivity.AliyunClient) r_kvstoreService := R_kvstoreService{client} var response map[string]interface{} + var err error action := "CreateInstance" request := make(map[string]interface{}) - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } request["RegionId"] = client.RegionId request["NetworkType"] = "CLASSIC" @@ -587,11 +582,9 @@ func resourceAliCloudKvstoreInstanceCreate(d *schema.ResourceData, meta interfac } } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NoCodeRegexRetry(err) { wait() @@ -797,11 +790,8 @@ func resourceAliCloudKvstoreInstanceRead(d *schema.ResourceData, meta interface{ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) r_kvstoreService := R_kvstoreService{client} - conn, err := client.NewRedisaClient() - if err != nil { - return WrapError(err) - } var response map[string]interface{} + var err error d.Partial(true) if d.HasChange("tags") { @@ -904,16 +894,9 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if update { action := "TransformInstanceChargeType" - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) 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("2015-01-01"), StringPointer("AK"), nil, transformInstanceChargeTypeReq, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, transformInstanceChargeTypeReq, false) if err != nil { if NeedRetry(err) { wait() @@ -1441,7 +1424,7 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac action := "ModifyInstanceTDE" 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("2015-01-01"), StringPointer("AK"), nil, modifyInstanceTDERequest, &util.RuntimeOptions{}) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, modifyInstanceTDERequest, false) if err != nil { if NeedRetry(err) { wait() @@ -1480,18 +1463,12 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if removed > 0 { action := "DeleteShardingNode" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request := make(map[string]interface{}) request["InstanceId"] = d.Id() request["ShardCount"] = removed - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, false) if err != nil { if NeedRetry(err) { @@ -1522,19 +1499,13 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if added > 0 { action := "AddShardingNode" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request := make(map[string]interface{}) request["InstanceId"] = d.Id() request["ClientToken"] = buildClientToken(action) request["ShardCount"] = added - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) request["ClientToken"] = buildClientToken(action) if err != nil { if NeedRetry(err) { @@ -1607,16 +1578,9 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if update { action := "ModifyInstanceSpec" - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) 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("2015-01-01"), StringPointer("AK"), nil, modifySlaveReadOnlyCountReq, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, modifySlaveReadOnlyCountReq, false) if err != nil { if IsExpectedErrors(err, []string{"MissingRedisUsedmemoryUnsupportPerfItem", "Task.Conflict"}) || NeedRetry(err) { wait() @@ -1659,16 +1623,9 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if update { action := "ModifyDBInstanceAutoUpgrade" - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) 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("2015-01-01"), StringPointer("AK"), nil, modifyDBInstanceAutoUpgradeReq, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, modifyDBInstanceAutoUpgradeReq, false) if err != nil { if NeedRetry(err) { wait() @@ -1702,16 +1659,9 @@ func resourceAliCloudKvstoreInstanceUpdate(d *schema.ResourceData, meta interfac if update { action := "ModifyInstanceBandwidth" - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) 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("2015-01-01"), StringPointer("AK"), nil, modifyInstanceBandwidthReq, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, modifyInstanceBandwidthReq, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_kvstore_instance_test.go b/alicloud/resource_alicloud_kvstore_instance_test.go index 3b369a003b22..42b9c8aa182a 100644 --- a/alicloud/resource_alicloud_kvstore_instance_test.go +++ b/alicloud/resource_alicloud_kvstore_instance_test.go @@ -6,8 +6,6 @@ import ( "testing" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "strings" @@ -31,12 +29,6 @@ func testSweepKVStoreInstances(region string) error { return fmt.Errorf("error getting Alicloud client: %s", err) } client := rawClient.(*connectivity.AliyunClient) - - conn, err := client.NewRedisaClient() - if err != nil { - return WrapError(err) - } - prefixes := []string{ "tf-testAcc", "tf_testAcc", @@ -53,9 +45,7 @@ func testSweepKVStoreInstances(region string) error { for _, instanceType := range []string{string(KVStoreRedis), string(KVStoreMemcache)} { request["InstanceType"] = instanceType for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { log.Printf("[ERROR] Failed to retrieve VPC in service list: %s", err) return nil @@ -98,7 +88,7 @@ func testSweepKVStoreInstances(region string) error { } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -117,7 +107,7 @@ func testSweepKVStoreInstances(region string) error { } wait = incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_redis_tair_instance.go b/alicloud/resource_alicloud_redis_tair_instance.go index db4f8ad71de8..a4c22edce50d 100644 --- a/alicloud/resource_alicloud_redis_tair_instance.go +++ b/alicloud/resource_alicloud_redis_tair_instance.go @@ -7,7 +7,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" @@ -178,11 +177,8 @@ func resourceAliCloudRedisTairInstanceCreate(d *schema.ResourceData, meta interf action := "CreateTairInstance" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["RegionId"] = client.RegionId request["ClientToken"] = buildClientToken(action) @@ -249,11 +245,9 @@ func resourceAliCloudRedisTairInstanceCreate(d *schema.ResourceData, meta interf if v, ok := d.GetOk("node_type"); ok { request["ShardType"] = convertRedisTairInstanceShardTypeRequest(v.(string)) } - 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("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -374,14 +368,11 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf client := meta.(*connectivity.AliyunClient) var request map[string]interface{} var response map[string]interface{} + var err error var query map[string]interface{} update := false d.Partial(true) action := "ModifyInstanceAttribute" - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -396,11 +387,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -422,10 +411,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "ModifyInstanceSpec" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -455,11 +440,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -481,10 +464,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "ModifyResourceGroup" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -496,11 +475,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -517,10 +494,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "ModifyInstanceMajorVersion" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -533,11 +506,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -559,10 +530,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "ModifySecurityGroupConfiguration" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DBInstanceId"] = d.Id() @@ -572,11 +539,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -593,10 +558,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "TransformInstanceChargeType" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -616,11 +577,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf request["AutoRenewPeriod"] = v } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -637,10 +596,6 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } update = false action = "ModifyInstanceSSL" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = d.Id() @@ -654,11 +609,9 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -688,18 +641,12 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf if removed > 0 { action = "DeleteShardingNode" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["InstanceId"] = d.Id() request["ShardCount"] = removed - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -723,19 +670,13 @@ func resourceAliCloudRedisTairInstanceUpdate(d *schema.ResourceData, meta interf if added > 0 { action = "AddShardingNode" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["InstanceId"] = d.Id() request["ClientToken"] = buildClientToken(action) request["ShardCount"] = added - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -781,19 +722,14 @@ func resourceAliCloudRedisTairInstanceDelete(d *schema.ResourceData, meta interf action := "DeleteInstance" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query["InstanceId"] = d.Id() - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/service_alicloud_r_kvstore.go b/alicloud/service_alicloud_r_kvstore.go index 3dd58845f0ad..d08f3676752a 100644 --- a/alicloud/service_alicloud_r_kvstore.go +++ b/alicloud/service_alicloud_r_kvstore.go @@ -194,20 +194,14 @@ func (s *R_kvstoreService) DescribeSecurityGroupConfiguration(id string) (object func (s *R_kvstoreService) DescribeKvstoreInstance(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstanceAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -272,20 +266,14 @@ func (s *R_kvstoreService) KvstoreInstanceAttributeRefreshFunc(id, attribute str func (s *R_kvstoreService) DescribeKvstoreInstances(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstances" request := map[string]interface{}{ "RegionId": s.client.RegionId, "InstanceIds": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -336,21 +324,15 @@ func (s *R_kvstoreService) KvstoreInstancesStateRefreshFunc(id string, failState func (s *R_kvstoreService) DescribeKvstoreInstanceDeleted(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstances" request := map[string]interface{}{ "RegionId": s.client.RegionId, "InstanceIds": id, "Expired": true, } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -502,20 +484,14 @@ func (s *R_kvstoreService) DescribeBackupPolicy(id string) (object r_kvstore.Des func (s *RKvstoreService) DescribeKvstoreAuditLogConfig(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeAuditLogConfig" request := map[string]interface{}{ "RegionId": s.client.RegionId, "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -542,10 +518,6 @@ func (s *RKvstoreService) DescribeKvstoreAuditLogConfig(id string) (object map[s func (s *RKvstoreService) DescribeInstanceAttribute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstanceAttribute" request := map[string]interface{}{ "InstanceId": id, @@ -554,7 +526,7 @@ func (s *RKvstoreService) DescribeInstanceAttribute(id string) (object map[strin 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -608,20 +580,14 @@ func (s *RKvstoreService) KvstoreAuditLogConfigStateRefreshFunc(id string, failS func (s *RKvstoreService) DescribeInstanceAutoRenewalAttribute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstanceAutoRenewalAttribute" request := map[string]interface{}{ "DBInstanceId": id, "RegionId": s.client.RegionId, } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -655,20 +621,14 @@ func (s *RKvstoreService) DescribeInstanceAutoRenewalAttribute(id string) (objec func (s *RKvstoreService) DescribeInstanceSSL(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstanceSSL" request := map[string]interface{}{ "InstanceId": id, "RegionId": s.client.RegionId, } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -690,20 +650,14 @@ func (s *RKvstoreService) DescribeInstanceSSL(id string) (object map[string]inte func (s *RKvstoreService) DescribeSecurityGroupConfiguration(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeSecurityGroupConfiguration" request := map[string]interface{}{ "InstanceId": id, "RegionId": s.client.RegionId, } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -731,20 +685,14 @@ func (s *RKvstoreService) DescribeSecurityGroupConfiguration(id string) (object func (s *RKvstoreService) DescribeSecurityIps(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeSecurityIps" request := map[string]interface{}{ "InstanceId": id, "RegionId": s.client.RegionId, } - 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("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -777,19 +725,13 @@ func (s *RKvstoreService) DescribeSecurityIps(id string) (object map[string]inte func (s *RKvstoreService) DescribeInstanceTDEStatus(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeInstanceTDEStatus" request := map[string]interface{}{ "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -813,19 +755,13 @@ func (s *RKvstoreService) DescribeInstanceTDEStatus(id string) (object map[strin func (s *RKvstoreService) DescribeEncryptionKey(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeEncryptionKey" request := map[string]interface{}{ "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -850,21 +786,13 @@ func (s *RKvstoreService) DescribeEncryptionKey(id string) (object map[string]in func (s *R_kvstoreService) DescribeKvStoreInstanceNetInfo(id string) (objects []interface{}, err error) { var response map[string]interface{} action := "DescribeDBInstanceNetInfo" - - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } - request := map[string]interface{}{ "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -897,21 +825,12 @@ func (s *R_kvstoreService) DescribeKvStoreInstanceNetInfo(id string) (objects [] func (s *R_kvstoreService) DescribeKvStoreEngineVersion(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeEngineVersion" - - conn, err := s.client.NewRedisaClient() - if err != nil { - return nil, WrapError(err) - } - request := map[string]interface{}{ "InstanceId": 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("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_redis_v2.go b/alicloud/service_alicloud_redis_v2.go index eda588415b2e..ad9140f4d799 100644 --- a/alicloud/service_alicloud_redis_v2.go +++ b/alicloud/service_alicloud_redis_v2.go @@ -5,8 +5,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - rpc "github.com/alibabacloud-go/tea-rpc/client" - 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" @@ -24,19 +22,13 @@ func (s *RedisServiceV2) DescribeRedisTairInstance(id string) (object map[string var response map[string]interface{} var query map[string]interface{} action := "DescribeInstanceAttribute" - conn, err := client.NewRedisClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = id - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -73,19 +65,13 @@ func (s *RedisServiceV2) DescribeDescribeSecurityGroupConfiguration(id string) ( var response map[string]interface{} var query map[string]interface{} action := "DescribeSecurityGroupConfiguration" - conn, err := client.NewRedisClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = id - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -122,19 +108,13 @@ func (s *RedisServiceV2) DescribeDescribeInstanceSSL(id string) (object map[stri var response map[string]interface{} var query map[string]interface{} action := "DescribeInstanceSSL" - conn, err := client.NewRedisClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["InstanceId"] = id - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -186,7 +166,6 @@ func (s *RedisServiceV2) SetResourceTags(d *schema.ResourceData, resourceType st if d.HasChange("tags") { var err error var action string - var conn *rpc.Client client := s.client var request map[string]interface{} var response map[string]interface{} @@ -201,10 +180,6 @@ func (s *RedisServiceV2) SetResourceTags(d *schema.ResourceData, resourceType st } if len(removedTagKeys) > 0 { action = "UntagResources" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) request["ResourceId.1"] = d.Id() @@ -214,11 +189,9 @@ func (s *RedisServiceV2) SetResourceTags(d *schema.ResourceData, resourceType st request[fmt.Sprintf("TagKey.%d", i+1)] = key } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait() @@ -237,10 +210,6 @@ func (s *RedisServiceV2) SetResourceTags(d *schema.ResourceData, resourceType st if len(added) > 0 { action = "TagResources" - conn, err = client.NewRedisClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) request["ResourceId.1"] = d.Id() @@ -253,11 +222,9 @@ func (s *RedisServiceV2) SetResourceTags(d *schema.ResourceData, resourceType st } request["ResourceType"] = resourceType - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("R-kvstore", "2015-01-01", action, query, request, false) if err != nil { if NeedRetry(err) { wait()