Browse Source

由归邪发起的CORE SDK自动发布, BUILD_ID=145, 版本号:0.6.8

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
haowei.yao 8 years ago
parent
commit
0535020f6b

+ 3 - 0
ChangeLog.txt

@@ -1,3 +1,6 @@
+2017-12-29 Version: 0.6.8
+1, Allow the setting of AcceptFormat in the Request.
+
 2017-12-26 Version: 0.6.5
 1, Add video AI service interface.
 

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

@@ -52,7 +52,7 @@ func NewSignerKeyPair(credential *credentials.KeyPairCredential, commonApi func(
 	}
 
 	if credential.SessionExpiration > 0 {
-		if credential.SessionExpiration > 900 && credential.SessionExpiration < 3600 {
+		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)

+ 20 - 4
sdk/client_test.go

@@ -116,10 +116,10 @@ func testSetup() {
 	if err != nil {
 		panic(err)
 	}
-	//err = clientKeyPair.InitWithKeyPair("cn-hangzhou", config.PublicKeyId, config.PrivateKey, 3600)
-	//if err != nil {
-	//	panic(err)
-	//}
+	err = clientKeyPair.InitWithKeyPair("cn-hangzhou", config.PublicKeyId, config.PrivateKey, 3600)
+	if err != nil {
+		panic(err)
+	}
 	err = clientEcs.InitWithEcsInstance("cn-hangzhou", "conan")
 	if err != nil {
 		panic(err)
@@ -493,3 +493,19 @@ func TestRpcGetForRoleArn(t *testing.T) {
 
 	assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
 }
+
+func TestCommonRoaRequestForAcceptXML(t *testing.T) {
+	roaRequest := requests.NewCommonRequest()
+	roaRequest.Product = "Acs"
+	roaRequest.Version = "2015-01-01"
+	roaRequest.ApiName = "GetGlobal"
+	roaRequest.PathPattern = "/"
+	roaRequest.Domain = "acs.aliyuncs.com"
+	roaRequest.AcceptFormat = "XML"
+
+	response, err := client.ProcessCommonRequest(roaRequest)
+
+	assert.Nil(t, err)
+	assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
+	assert.NotNil(t, response.GetHttpContentString())
+}

+ 0 - 35
sdk/config.go

@@ -43,41 +43,6 @@ func (c *Config) WithTimeout(timeout time.Duration) *Config {
 	return c
 }
 
-func (c *Config) WithAutoRetry(isAutoRetry bool) *Config {
-	c.AutoRetry = isAutoRetry
-	return c
-}
-
-func (c *Config) WithMaxRetryTime(maxRetryTime int) *Config {
-	c.MaxRetryTime = maxRetryTime
-	return c
-}
-
-func (c *Config) WithUserAgent(userAgent string) *Config {
-	c.UserAgent = userAgent
-	return c
-}
-
-func (c *Config) WithHttpTransport(httpTransport *http.Transport) *Config {
-	c.HttpTransport = httpTransport
-	return c
-}
-
-func (c *Config) WithEnableAsync(isEnableAsync bool) *Config {
-	c.EnableAsync = isEnableAsync
-	return c
-}
-
-func (c *Config) WithMaxTaskQueueSize(maxTaskQueueSize int) *Config {
-	c.MaxTaskQueueSize = maxTaskQueueSize
-	return c
-}
-
-func (c *Config) WithGoRoutinePoolSize(goRoutinePoolSize int) *Config {
-	c.GoRoutinePoolSize = goRoutinePoolSize
-	return c
-}
-
 func (c *Config) WithDebug(isDebug bool) *Config {
 	c.Debug = isDebug
 	return c

+ 2 - 3
sdk/errors/client_error.go

@@ -14,8 +14,6 @@
 
 package errors
 
-import "fmt"
-
 const (
 	DefaultClientErrorStatus = 400
 	DefaultClientErrorCode   = "SDK.ClientError"
@@ -56,8 +54,9 @@ func NewClientError(errorCode, message string, originErr error) Error {
 func (err *ClientError) Error() string {
 	if err.originError != nil {
 		return err.originError.Error()
+	} else {
+		return ""
 	}
-	return fmt.Sprintf("[%s] %s", err.errorCode, err.message)
 }
 
 func (err *ClientError) OriginError() error {

+ 1 - 3
sdk/errors/server_error.go

@@ -14,8 +14,6 @@
 
 package errors
 
-import "fmt"
-
 type ServerError struct {
 	httpStatus int
 	errorCode  string
@@ -43,7 +41,7 @@ func (err *ServerError) Message() string {
 }
 
 func (err *ServerError) Error() string {
-	return fmt.Sprintf("SDK.ServerError %s %s", err.errorCode, err.message)
+	return "SDK.ServerError"
 }
 
 func (err *ServerError) OriginError() error {

+ 3 - 3
sdk/requests/acs_reqeust.go

@@ -94,7 +94,7 @@ type baseRequest struct {
 	version    string
 	actionName string
 
-	acceptFormat string
+	AcceptFormat string
 
 	QueryParams map[string]string
 	Headers     map[string]string
@@ -144,7 +144,7 @@ func (request *baseRequest) addFormParam(key, value string) {
 }
 
 func (request *baseRequest) GetAcceptFormat() string {
-	return request.acceptFormat
+	return request.AcceptFormat
 }
 
 func (request *baseRequest) GetLocationServiceCode() string {
@@ -199,7 +199,7 @@ func (request *baseRequest) GetContentType() (contentType string, contains bool)
 func defaultBaseRequest() (request *baseRequest) {
 	request = &baseRequest{
 		Scheme:       HTTP,
-		acceptFormat: "JSON",
+		AcceptFormat: "JSON",
 		Method:       GET,
 		QueryParams:  make(map[string]string),
 		Headers: map[string]string{

+ 0 - 6
sdk/responses/response.go

@@ -18,7 +18,6 @@ import (
 	"bytes"
 	"encoding/json"
 	"encoding/xml"
-	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
 	"io/ioutil"
 	"net/http"
 	"strconv"
@@ -26,7 +25,6 @@ import (
 )
 
 type AcsResponse interface {
-	IsSuccess() bool
 	GetHttpStatus() int
 	GetHttpHeaders() map[string][]string
 	GetHttpContentString() string
@@ -40,10 +38,6 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
 	if err != nil {
 		return
 	}
-	if !response.IsSuccess() {
-		err = errors.NewServerError(response.GetHttpStatus(), response.GetOriginHttpResponse().Status, response.GetHttpContentString())
-		return
-	}
 	if strings.ToUpper(format) == "JSON" {
 		err = json.Unmarshal(response.GetHttpContentBytes(), response)
 	} else if strings.ToUpper(format) == "XML" {