浏览代码

1. support 4 types of sts auth
2. complete integration test cases
3. bugfixes

Signed-off-by: gaort <rutong.grt@alibaba-inc.com>

gaort 7 年之前
父节点
当前提交
990717cf00

+ 20 - 18
integration/ecs_test.go

@@ -56,8 +56,8 @@ func TestEcsInstance(t *testing.T) {
 	// wait
 	waitForEcsInstance(t, ecsClient, instanceId, EcsInstanceStatusStopped, 600)
 
-	// delete all test instance
-	//deleteAllTestEcsInstance(t, ecsClient)
+	//delete all test instance
+	deleteAllTestEcsInstance(t, ecsClient)
 }
 
 func getDemoEcsInstanceAttributes(t *testing.T, client *ecs.Client) *ecs.DescribeInstanceAttributeResponse {
@@ -124,24 +124,30 @@ func deleteAllTestEcsInstance(t *testing.T, client *ecs.Client) {
 	response, err := client.DescribeInstances(request)
 	assertErrorNil(t, err, "Failed to list all ecs instances ")
 	assert.Equal(t, 200, response.GetHttpStatus(), response.GetHttpContentString())
-	fmt.Printf("success! TotalCount = %s\n", response.TotalCount)
+	fmt.Printf("success! TotalCount = %s\n", strconv.Itoa(response.TotalCount))
 
 	for _, instanceInfo := range response.Instances.Instance {
 		if strings.HasPrefix(instanceInfo.InstanceName, InstanceNamePrefix) {
-			fmt.Printf("found undeleted ecs instance(%s), status=%s, try to delete it.\n",
-				instanceInfo.Status, instanceInfo.InstanceId)
-			if instanceInfo.Status == EcsInstanceStatusRunning {
-				// stop
-				stopEcsInstance(t, client, instanceInfo.InstanceId)
-			} else if instanceInfo.Status == EcsInstanceStatusStopped {
-				// delete
-				deleteEcsInstance(t, client, instanceInfo.InstanceId)
-				// wait
-				waitForEcsInstance(t, client, instanceInfo.InstanceId, EcsInstanceStatusDeleted, 600)
+			createTime, err := strconv.ParseInt(instanceInfo.InstanceName[26:len(instanceInfo.InstanceName)], 10, 64)
+			assertErrorNil(t, err, "Parse instance create time failed: "+instanceInfo.InstanceName)
+			if (time.Now().Unix() - createTime) < (5 * 60) {
+				fmt.Printf("found undeleted ecs instance(%s) but created in 5 minutes, try to delete next time\n",instanceInfo.InstanceName)
+				return
+			}else{
+				fmt.Printf("found undeleted ecs instance(%s), status=%s, try to delete it.\n",
+					instanceInfo.Status, instanceInfo.InstanceId)
+				if instanceInfo.Status == EcsInstanceStatusRunning {
+					// stop
+					stopEcsInstance(t, client, instanceInfo.InstanceId)
+				} else if instanceInfo.Status == EcsInstanceStatusStopped {
+					// delete
+					deleteEcsInstance(t, client, instanceInfo.InstanceId)
+					// wait
+					waitForEcsInstance(t, client, instanceInfo.InstanceId, EcsInstanceStatusDeleted, 600)
+				}
 			}
 		}
 	}
-
 }
 
 func waitForEcsInstance(t *testing.T, client *ecs.Client, instanceId string, targetStatus string, timeout int) {
@@ -152,10 +158,6 @@ func waitForEcsInstance(t *testing.T, client *ecs.Client, instanceId string, tar
 		request := ecs.CreateDescribeInstanceAttributeRequest()
 		request.InstanceId = instanceId
 		response, err := client.DescribeInstanceAttribute(request)
-		response.GetHttpStatus()
-		response.GetHttpHeaders()
-		response.GetHttpContentBytes()
-		response.GetHttpContentString()
 
 		if targetStatus == EcsInstanceStatusDeleted {
 			if response.GetHttpStatus() == 404 || response.Status == EcsInstanceStatusDeleted {

+ 19 - 6
integration/rds_test.go

@@ -8,6 +8,8 @@ import (
 	"strings"
 	"testing"
 	"time"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
 )
 
 const (
@@ -22,8 +24,13 @@ const (
 func TestRdsInstance(t *testing.T) {
 
 	// init client
-	config := getConfigFromEnv()
-	rdsClient, err := rds.NewClientWithAccessKey("cn-hangzhou", config.AccessKeyId, config.AccessKeySecret)
+	testConfig := getConfigFromEnv()
+	credential := &credentials.BaseCredential{
+		AccessKeyId:     testConfig.AccessKeyId,
+		AccessKeySecret: testConfig.AccessKeySecret,
+	}
+	clientConfig := sdk.NewConfig().WithTimeout(30 * time.Second)
+	rdsClient, err := rds.NewClientWithOptions("cn-hangzhou", clientConfig, credential)
 	assertErrorNil(t, err, "Failed to init client")
 	fmt.Printf("Init client success\n")
 
@@ -41,7 +48,7 @@ func TestRdsInstance(t *testing.T) {
 
 	deleteDBInstance(t, rdsClient, dbInstanceId)
 
-	//deleteAllTestRdsInstance(t, rdsClient)
+	deleteAllTestRdsInstance(t, rdsClient)
 }
 
 func createDBInstance(t *testing.T, client *rds.Client) (rdsInstanceId string) {
@@ -171,11 +178,17 @@ func deleteAllTestRdsInstance(t *testing.T, client *rds.Client) {
 	fmt.Printf("found %s instances\n", strconv.Itoa(listResponse.TotalRecordCount))
 	for _, instance := range listResponse.Items.DBInstance {
 		if strings.HasPrefix(instance.DBInstanceDescription, InstanceNamePrefix) {
-			fmt.Printf("found test instance(%s), trying to delte it\n", instance.DBInstanceId)
-			deleteDBInstance(t, client, instance.DBInstanceId)
+			createTime, err := strconv.ParseInt(instance.DBInstanceDescription[len(InstanceNamePrefix):], 10, 64)
+			assertErrorNil(t, err, "Parse instance create time failed: "+instance.DBInstanceDescription)
+			if (time.Now().Unix() - createTime) < (5 * 60) {
+				fmt.Printf("found undeleted rds instance(%s) but created in 5 minutes, try to delete next time\n", instance.DBInstanceDescription)
+				return
+			} else {
+				fmt.Printf("found rds test instance(%s), trying to delte it\n", instance.DBInstanceId)
+				deleteDBInstance(t, client, instance.DBInstanceId)
+			}
 		}
 	}
-
 }
 
 func getSingleInstanceStatusFromDescribeDBInstanceAttributeResponse(response *rds.DescribeDBInstanceAttributeResponse) string {

+ 16 - 9
integration/slb_test.go

@@ -44,7 +44,7 @@ func TestSlbInstance(t *testing.T) {
 	stopSlbInstance(t, slbClient, instanceId)
 
 	// delete all test instance
-	//deleteAllTestSlbInstance(t, slbClient)
+	deleteAllTestSlbInstance(t, slbClient)
 }
 
 func createSlbInstance(t *testing.T, client *slb.Client) (instanceId string) {
@@ -128,18 +128,25 @@ func deleteAllTestSlbInstance(t *testing.T, client *slb.Client) {
 	response, err := client.DescribeLoadBalancers(request)
 	assertErrorNil(t, err, "Failed to list all slb instances")
 	assert.Equal(t, 200, response.GetHttpStatus(), response.GetHttpContentString())
-	fmt.Printf("success(%d)! TotalCount = %s\n", response.GetHttpStatus(), response.TotalCount)
+	fmt.Printf("success(%d)! TotalCount = %s\n", response.GetHttpStatus(), strconv.Itoa(response.TotalCount))
 
 	for _, slbInstanceInfo := range response.LoadBalancers.LoadBalancer {
 		if strings.HasPrefix(slbInstanceInfo.LoadBalancerName, InstanceNamePrefix) {
-			fmt.Printf("found undeleted slb instance(%s), status=%s, try to delete it.\n",
-				slbInstanceInfo.LoadBalancerId, slbInstanceInfo.LoadBalancerStatus)
-			if slbInstanceInfo.LoadBalancerStatus != SlbInstanceStopped {
-				// stop
-				stopSlbInstance(t, client, slbInstanceInfo.LoadBalancerId)
+			createTime, err := strconv.ParseInt(slbInstanceInfo.LoadBalancerName[len(InstanceNamePrefix):], 10, 64)
+			assertErrorNil(t, err, "Parse instance create time failed: "+slbInstanceInfo.LoadBalancerName)
+			if (time.Now().Unix() - createTime) < (5 * 60) {
+				fmt.Printf("found undeleted slb instance(%s) but created in 5 minutes, try to delete next time\n", slbInstanceInfo.LoadBalancerName)
+				return
+			} else {
+				fmt.Printf("found undeleted slb instance(%s), status=%s, try to delete it.\n",
+					slbInstanceInfo.LoadBalancerId, slbInstanceInfo.LoadBalancerStatus)
+				if slbInstanceInfo.LoadBalancerStatus != SlbInstanceStopped {
+					// stop
+					stopSlbInstance(t, client, slbInstanceInfo.LoadBalancerId)
+				}
+				// delete
+				deleteSlbInstance(t, client, slbInstanceInfo.LoadBalancerId)
 			}
-			// delete
-			deleteSlbInstance(t, client, slbInstanceInfo.LoadBalancerId)
 		}
 	}
 }

+ 1 - 1
integration/utils.go

@@ -43,4 +43,4 @@ func assertErrorNil(t *testing.T, err error, message string) {
 	if err != nil {
 		fmt.Fprintf(os.Stderr, message+": %v\n", err)
 	}
-}
+}

+ 3 - 3
sdk/auth/credentials/base_credential.go

@@ -5,9 +5,9 @@ type BaseCredential struct {
 	AccessKeySecret string
 }
 
-func NewBaseCredential(AccessKeyId, AccessKeySecret string) *BaseCredential {
+func NewBaseCredential(accessKeyId, accessKeySecret string) *BaseCredential {
 	return &BaseCredential{
-		AccessKeyId:     AccessKeyId,
-		AccessKeySecret: AccessKeySecret,
+		AccessKeyId:     accessKeyId,
+		AccessKeySecret: accessKeySecret,
 	}
 }

+ 4 - 4
sdk/auth/credentials/rsa_key_pair_credential.go

@@ -6,10 +6,10 @@ type RsaKeyPairCredential struct {
 	SessionExpiration int
 }
 
-func NewRsaKeyPairCredential(PrivateKey, PublicKeyId string, SessionExpiration int) *RsaKeyPairCredential {
+func NewRsaKeyPairCredential(privateKey, publicKeyId string, sessionExpiration int) *RsaKeyPairCredential {
 	return &RsaKeyPairCredential{
-		PrivateKey:        PrivateKey,
-		PublicKeyId:       PublicKeyId,
-		SessionExpiration: SessionExpiration,
+		PrivateKey:        privateKey,
+		PublicKeyId:       publicKeyId,
+		SessionExpiration: sessionExpiration,
 	}
 }

+ 6 - 6
sdk/auth/credentials/sts_credential.go

@@ -1,15 +1,15 @@
 package credentials
 
-type StsCredential struct {
+type StsTokenCredential struct {
 	AccessKeyId       string
 	AccessKeySecret   string
 	AccessKeyStsToken string
 }
 
-func NewStsCredential(AccessKeyId, AccessKeySecret, AccessKeyStsToken string) *StsCredential {
-	return &StsCredential{
-		AccessKeyId:       AccessKeyId,
-		AccessKeySecret:   AccessKeySecret,
-		AccessKeyStsToken: AccessKeyStsToken,
+func NewStsTokenCredential(accessKeyId, accessKeySecret, accessKeyStsToken string) *StsTokenCredential {
+	return &StsTokenCredential{
+		AccessKeyId:       accessKeyId,
+		AccessKeySecret:   accessKeySecret,
+		AccessKeyStsToken: accessKeyStsToken,
 	}
 }

+ 6 - 6
sdk/auth/credentials/sts_role_arn_credential.go

@@ -8,12 +8,12 @@ type StsRoleArnCredential struct {
 	RoleSessionExpiration int
 }
 
-func NewStsRoleArnCredential(AccessKeyId, AccessKeySecret, RoleArn, RoleSessionName string, RoleSessionExpiration int) *StsRoleArnCredential {
+func NewStsRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName string, roleSessionExpiration int) *StsRoleArnCredential {
 	return &StsRoleArnCredential{
-		AccessKeyId:           AccessKeyId,
-		AccessKeySecret:       AccessKeySecret,
-		RoleArn:               RoleArn,
-		RoleSessionName:       RoleSessionName,
-		RoleSessionExpiration: RoleSessionExpiration,
+		AccessKeyId:           accessKeyId,
+		AccessKeySecret:       accessKeySecret,
+		RoleArn:               roleArn,
+		RoleSessionName:       roleSessionName,
+		RoleSessionExpiration: roleSessionExpiration,
 	}
 }

+ 2 - 2
sdk/auth/credentials/sts_role_name_on_ecs_credential.go

@@ -4,8 +4,8 @@ type StsRoleNameOnEcsCredential struct {
 	RoleName string
 }
 
-func NewStsRoleNameOnEcsCredential(RoleName string) *StsRoleNameOnEcsCredential {
+func NewStsRoleNameOnEcsCredential(roleName string) *StsRoleNameOnEcsCredential {
 	return &StsRoleNameOnEcsCredential{
-		RoleName: RoleName,
+		RoleName: roleName,
 	}
 }

+ 5 - 5
sdk/auth/signer.go

@@ -40,7 +40,7 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
 		{
 			signer, err = signers.NewSignerV1(instance)
 		}
-	case *credentials.StsCredential:
+	case *credentials.StsTokenCredential:
 		{
 			signer, err = signers.NewSignerSts(instance)
 		}
@@ -57,8 +57,8 @@ func NewSignerWithCredential(credential Credential, commonApi func(request *requ
 			signer, err = signers.NewSignereEcsInstance(instance, commonApi)
 		}
 	default:
-		message := fmt.Sprintf(errors.UnsupportedCredentialMessage, reflect.TypeOf(credential))
-		err = errors.NewClientError(errors.UnsupportedCredentialCode, message, nil)
+		message := fmt.Sprintf(errors.UnsupportedCredentialErrorMessage, reflect.TypeOf(credential))
+		err = errors.NewClientError(errors.UnsupportedCredentialErrorCode, message, nil)
 	}
 	return
 }
@@ -74,8 +74,8 @@ func Sign(request requests.AcsRequest, signer Signer, regionId string) (err erro
 			signRpcRequest(request, signer, regionId)
 		}
 	default:
-		message := fmt.Sprintf(errors.UnknownRequestTypeMessage, reflect.TypeOf(request))
-		err = errors.NewClientError(errors.UnknownRequestTypeCode, message, nil)
+		message := fmt.Sprintf(errors.UnknownRequestTypeErrorMessage, reflect.TypeOf(request))
+		err = errors.NewClientError(errors.UnknownRequestTypeErrorCode, message, nil)
 	}
 
 	return

+ 1 - 1
sdk/auth/signers/signer_key_pair.go

@@ -55,7 +55,7 @@ func NewSignerKeyPair(credential *credentials.RsaKeyPairCredential, commonApi fu
 		if credential.SessionExpiration >= 900 && credential.SessionExpiration <= 3600 {
 			signer.credentialExpiration = credential.SessionExpiration
 		} else {
-			err = errors.NewClientError(errors.InvalidParamCode, "Key Pair session duration should be in the range of 15min - 1Hr", nil)
+			err = errors.NewClientError(errors.InvalidParamErrorCode, "Key Pair session duration should be in the range of 15min - 1Hr", nil)
 		}
 	} else {
 		signer.credentialExpiration = defaultDurationSeconds

+ 2 - 2
sdk/auth/signers/signer_sts.go

@@ -19,10 +19,10 @@ import (
 )
 
 type SignerSts struct {
-	credential *credentials.StsCredential
+	credential *credentials.StsTokenCredential
 }
 
-func NewSignerSts(credential *credentials.StsCredential) (*SignerSts, error) {
+func NewSignerSts(credential *credentials.StsTokenCredential) (*SignerSts, error) {
 	return &SignerSts{
 		credential: credential,
 	}, nil

+ 6 - 7
sdk/client.go

@@ -96,7 +96,7 @@ func (client *Client) InitWithAccessKey(regionId, accessKeyId, accessKeySecret s
 
 func (client *Client) InitWithSecurityToken(regionId, accessKeyId, accessKeySecret, securityToken string) (err error) {
 	config := client.InitClientConfig()
-	credential := &credentials.StsCredential{
+	credential := &credentials.StsTokenCredential{
 		AccessKeyId:       accessKeyId,
 		AccessKeySecret:   accessKeySecret,
 		AccessKeyStsToken: securityToken,
@@ -134,12 +134,11 @@ func (client *Client) InitWithStsRoleNameOnEcs(regionId, roleName string) (err e
 }
 
 func (client *Client) InitClientConfig() (config *Config) {
-	config = NewConfig()
 	if client.config != nil {
-		config = client.config
+		return client.config
+	}else{
+		return NewConfig()
 	}
-
-	return
 }
 
 func (client *Client) DoAction(request requests.AcsRequest, response responses.AcsResponse) (err error) {
@@ -264,9 +263,9 @@ func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (clie
 	return
 }
 
-func NewClientWithSecurityToken(regionId, accessKeyId, accessKeySecret, securityToken string) (client *Client, err error) {
+func NewClientWithStsToken(regionId, accessKeyId, accessKeySecret, accessKeyStsToken string) (client *Client, err error) {
 	client = &Client{}
-	err = client.InitWithSecurityToken(regionId, accessKeyId, accessKeySecret, accessKeySecret)
+	err = client.InitWithSecurityToken(regionId, accessKeyId, accessKeySecret, accessKeyStsToken)
 	return
 }
 

+ 2 - 2
sdk/client_test.go

@@ -141,7 +141,7 @@ func testSetup() {
 		panic(err)
 	}
 
-	stsCredential := credentials.NewStsCredential(testConfig.StsAk, testConfig.StsSecret, testConfig.StsToken)
+	stsCredential := credentials.NewStsTokenCredential(testConfig.StsAk, testConfig.StsSecret, testConfig.StsToken)
 	clientSts, err = NewClientWithOptions("cn-hangzhou", clientConfig, stsCredential)
 	if err != nil {
 		panic(err)
@@ -161,7 +161,7 @@ func TestRoaGet(t *testing.T) {
 
 	response := &responses.BaseResponse{}
 	err := client.DoAction(request, response)
-	assert.Nil(t, err, err.Error())
+	assert.Nil(t, err)
 	assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
 	assert.NotNil(t, response.GetHttpContentString())
 

+ 2 - 2
sdk/endpoints/resolver.go

@@ -44,8 +44,8 @@ func Resolve(param *ResolveParam) (endpoint string, err error) {
 	}
 
 	// not support
-	errorMsg := fmt.Sprintf(errors.CanNotResolveEndpointMessage, param, ResolveEndpointUserGuideLink)
-	err = errors.NewClientError(errors.CanNotResolveEndpointCode, errorMsg, nil)
+	errorMsg := fmt.Sprintf(errors.CanNotResolveEndpointErrorMessage, param, ResolveEndpointUserGuideLink)
+	err = errors.NewClientError(errors.CanNotResolveEndpointErrorCode, errorMsg, nil)
 	return
 }
 

+ 20 - 13
sdk/errors/client_error.go

@@ -20,26 +20,29 @@ const (
 	DefaultClientErrorStatus = 400
 	DefaultClientErrorCode   = "SDK.ClientError"
 
-	UnsupportedCredentialCode    = "SDK.UnsupportedCredential"
-	UnsupportedCredentialMessage = "Specified credential (type = %s) is not supported, please check"
+	UnsupportedCredentialErrorCode    = "SDK.UnsupportedCredential"
+	UnsupportedCredentialErrorMessage = "Specified credential (type = %s) is not supported, please check"
 
-	CanNotResolveEndpointCode    = "SDK.CanNotResolveEndpoint"
-	CanNotResolveEndpointMessage = "Can not resolve endpoint(param = %s), please check the user guide\n %s"
+	CanNotResolveEndpointErrorCode    = "SDK.CanNotResolveEndpoint"
+	CanNotResolveEndpointErrorMessage = "Can not resolve endpoint(param = %s), please check the user guide\n %s"
 
-	UnsupportedParamPositionCode    = "SDK.UnsupportedParamPosition"
-	UnsupportedParamPositionMessage = "Specified param position (%s) is not supported, please upgrade sdk and retry"
+	UnsupportedParamPositionErrorCode    = "SDK.UnsupportedParamPosition"
+	UnsupportedParamPositionErrorMessage = "Specified param position (%s) is not supported, please upgrade sdk and retry"
 
 	AsyncFunctionNotEnabledCode    = "SDK.AsyncFunctionNotEnabled"
 	AsyncFunctionNotEnabledMessage = "Async function is not enabled in client, please invoke 'client.EnableAsync' function"
 
-	UnknownRequestTypeCode    = "SDK.UnknownRequestType"
-	UnknownRequestTypeMessage = "Unknown Request Type: %s"
+	UnknownRequestTypeErrorCode    = "SDK.UnknownRequestType"
+	UnknownRequestTypeErrorMessage = "Unknown Request Type: %s"
 
-	MissingParamCode = "SDK.MissingParam"
-	InvalidParamCode = "SDK.InvalidParam"
+	MissingParamErrorCode = "SDK.MissingParam"
+	InvalidParamErrorCode = "SDK.InvalidParam"
 
-	JsonUnmarshalCode    = "SDK.JsonUnmarshalError"
-	JsonUnmarshalMessage = "Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString()"
+	JsonUnmarshalErrorCode    = "SDK.JsonUnmarshalError"
+	JsonUnmarshalErrorMessage = "Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString()"
+
+	TimeoutErrorCode    = "SDK.TimeoutError"
+	TimeoutErrorMessage = "The request timed out %s times(%s for retry), perhaps we should have the threshold raised a little?"
 )
 
 type ClientError struct {
@@ -59,7 +62,7 @@ func NewClientError(errorCode, message string, originErr error) Error {
 func (err *ClientError) Error() string {
 	clientErrMsg := fmt.Sprintf("[%s] %s", err.errorCode, err.message)
 	if err.originError != nil {
-		return clientErrMsg + "\noriginal error:\n" + err.originError.Error()
+		return clientErrMsg + "\ncaused by:\n" + err.originError.Error()
 	}
 	return clientErrMsg
 }
@@ -83,3 +86,7 @@ func (err *ClientError) ErrorCode() string {
 func (err *ClientError) Message() string {
 	return err.message
 }
+
+func (err *ClientError) String() string {
+	return err.Error()
+}

+ 2 - 2
sdk/requests/acs_reqeust.go

@@ -279,8 +279,8 @@ func addParam(request AcsRequest, position, name, value string) (err error) {
 		case Body:
 			request.addFormParam(name, value)
 		default:
-			errMsg := fmt.Sprintf(errors.UnsupportedParamPositionMessage, position)
-			err = errors.NewClientError(errors.UnsupportedParamPositionCode, errMsg, nil)
+			errMsg := fmt.Sprintf(errors.UnsupportedParamPositionErrorMessage, position)
+			err = errors.NewClientError(errors.UnsupportedParamPositionErrorCode, errMsg, nil)
 		}
 	}
 	return

+ 3 - 3
sdk/requests/common_request.go

@@ -31,13 +31,13 @@ func NewCommonRequest() (request *CommonRequest) {
 
 func (request *CommonRequest) TransToAcsRequest() {
 	if len(request.Version) == 0 {
-		errors.NewClientError(errors.MissingParamCode, "Common request [version] is required", nil)
+		errors.NewClientError(errors.MissingParamErrorCode, "Common request [version] is required", nil)
 	}
 	if len(request.ApiName) == 0 && len(request.PathPattern) == 0 {
-		errors.NewClientError(errors.MissingParamCode, "At least one of [ApiName] and [PathPattern] should has a value", nil)
+		errors.NewClientError(errors.MissingParamErrorCode, "At least one of [ApiName] and [PathPattern] should has a value", nil)
 	}
 	if len(request.Domain) == 0 && len(request.Product) == 0 {
-		errors.NewClientError(errors.MissingParamCode, "At least one of [Domain] and [Product] should has a value", nil)
+		errors.NewClientError(errors.MissingParamErrorCode, "At least one of [Domain] and [Product] should has a value", nil)
 	}
 
 	if len(request.PathPattern) > 0 {

+ 1 - 1
sdk/responses/response.go

@@ -51,7 +51,7 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
 		initJsonParserOnce()
 		err = jsonParser.Unmarshal(response.GetHttpContentBytes(), response)
 		if err != nil {
-			err = errors.NewClientError(errors.JsonUnmarshalCode, errors.JsonUnmarshalMessage, err)
+			err = errors.NewClientError(errors.JsonUnmarshalErrorCode, errors.JsonUnmarshalErrorMessage, err)
 		}
 	} else if strings.ToUpper(format) == "XML" {
 		err = xml.Unmarshal(response.GetHttpContentBytes(), response)