From 01dc6b213887c02d539d22882c54abd7fba49f87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:26:38 +0000 Subject: [PATCH] build(deps): bump github.com/alibabacloud-go/darabonba-openapi/v2 Bumps [github.com/alibabacloud-go/darabonba-openapi/v2](https://github.com/alibabacloud-go/darabonba-openapi) from 2.0.6 to 2.0.9. - [Release notes](https://github.com/alibabacloud-go/darabonba-openapi/releases) - [Changelog](https://github.com/alibabacloud-go/darabonba-openapi/blob/master/ChangeLog.txt) - [Commits](https://github.com/alibabacloud-go/darabonba-openapi/compare/v2.0.6...v2.0.9) --- updated-dependencies: - dependency-name: github.com/alibabacloud-go/darabonba-openapi/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 +- go.sum | 8 +- .../provider/semaphore_provider.go | 6 + .../pkg/credentials/provider/v1sdk.go | 29 +- .../pkg/credentials/provider/v2sdk.go | 31 +- .../darabonba-openapi/v2/client/client.go | 660 +++++++++++++----- .../tea-utils/v2/service/service.go | 6 + vendor/modules.txt | 4 +- 8 files changed, 553 insertions(+), 195 deletions(-) diff --git a/go.mod b/go.mod index bd0d7f12..d772bac4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.0.0 github.com/alibabacloud-go/cs-20151215/v3 v3.0.42 github.com/alibabacloud-go/darabonba-openapi v0.2.1 - github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.6 + github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.9 github.com/alibabacloud-go/ram-20150501 v1.0.2 github.com/alibabacloud-go/sts-20150401 v1.1.0 github.com/alibabacloud-go/tea v1.2.2 @@ -29,7 +29,7 @@ require ( require ( github.com/alibabacloud-go/openapi-util v0.1.0 github.com/alibabacloud-go/tea-utils v1.4.5 - github.com/alibabacloud-go/tea-utils/v2 v2.0.5 + github.com/alibabacloud-go/tea-utils/v2 v2.0.6 github.com/go-logr/zapr v1.3.0 github.com/olekukonko/tablewriter v0.0.6-0.20230925090304-df64c4bbad77 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index 83c513a3..de01149b 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/alibabacloud-go/darabonba-openapi v0.1.18/go.mod h1:PB4HffMhJVmAgNKNq github.com/alibabacloud-go/darabonba-openapi v0.2.1 h1:WyzxxKvhdVDlwpAMOHgAiCJ+NXa6g5ZWPFEzaK/ewwY= github.com/alibabacloud-go/darabonba-openapi v0.2.1/go.mod h1:zXOqLbpIqq543oioL9IuuZYOQgHQ5B8/n5OPrnko8aY= github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2/go.mod h1:5JHVmnHvGzR2wNdgaW1zDLQG8kOC4Uec8ubkMogW7OQ= -github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.6 h1:y1K+zKhpWcxso8zqI03CcYuwgyZPFwQdwAQOXAeuOVM= -github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.6/go.mod h1:CzQnh+94WDnJOnKZH5YRyouL+OOcdBnXY5VWAf0McgI= +github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.9 h1:fxMCrZatZfXq5nLcgkmWBXmU3FLC1OR+m/SqVtMqflk= +github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.9/go.mod h1:bb+Io8Sn2RuM3/Rpme6ll86jMyFSrD1bxeV/+v61KeU= github.com/alibabacloud-go/darabonba-string v1.0.0/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= github.com/alibabacloud-go/debug v1.0.0 h1:3eIEQWfay1fB24PQIEzXAswlVJtdQok8f3EVN5VrBnA= @@ -48,8 +48,8 @@ github.com/alibabacloud-go/tea-utils v1.4.5 h1:h0/6Xd2f3bPE4XHTvkpjwxowIwRCJAJOq github.com/alibabacloud-go/tea-utils v1.4.5/go.mod h1:KNcT0oXlZZxOXINnZBs6YvgOd5aYp9U67G+E3R8fcQw= github.com/alibabacloud-go/tea-utils/v2 v2.0.0/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4= github.com/alibabacloud-go/tea-utils/v2 v2.0.4/go.mod h1:sj1PbjPodAVTqGTA3olprfeeqqmwD0A5OQz94o9EuXQ= -github.com/alibabacloud-go/tea-utils/v2 v2.0.5 h1:EUakYEUAwr6L3wLT0vejIw2rc0IA1RSXDwLnIb3f2vU= -github.com/alibabacloud-go/tea-utils/v2 v2.0.5/go.mod h1:dL6vbUT35E4F4bFTHL845eUloqaerYBYPsdWR2/jhe4= +github.com/alibabacloud-go/tea-utils/v2 v2.0.6 h1:ZkmUlhlQbaDC+Eba/GARMPy6hKdCLiSke5RsN5LcyQ0= +github.com/alibabacloud-go/tea-utils/v2 v2.0.6/go.mod h1:qxn986l+q33J5VkialKMqT/TTs3E+U9MJpd001iWQ9I= github.com/alibabacloud-go/tea-xml v1.1.2/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8= github.com/alibabacloud-go/tea-xml v1.1.3 h1:7LYnm+JbOq2B+T/B0fHC4Ies4/FofC4zHzYtqw7dgt0= github.com/alibabacloud-go/tea-xml v1.1.3/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8= diff --git a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/semaphore_provider.go b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/semaphore_provider.go index 47baedcb..9164dd8b 100644 --- a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/semaphore_provider.go +++ b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/semaphore_provider.go @@ -40,3 +40,9 @@ func (o *SemaphoreProviderOptions) applyDefaults() { o.MaxWeight = 1 } } + +func (p *SemaphoreProvider) Stop(ctx context.Context) { + if s, ok := p.cp.(Stopper); ok { + s.Stop(ctx) + } +} diff --git a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v1sdk.go b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v1sdk.go index c85b29a6..fd2981cc 100644 --- a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v1sdk.go +++ b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v1sdk.go @@ -3,23 +3,27 @@ package provider import ( "context" "fmt" + "time" ) type SignerForV1SDK struct { - p CredentialsProvider - Logger Logger + p CredentialsProvider + Logger Logger + credentialRetrievalTimeout time.Duration } type SignerForV1SDKOptions struct { - Logger Logger + Logger Logger + CredentialRetrievalTimeout time.Duration } func NewSignerForV1SDK(p CredentialsProvider, opts SignerForV1SDKOptions) *SignerForV1SDK { opts.applyDefaults() return &SignerForV1SDK{ - p: p, - Logger: opts.Logger, + p: p, + Logger: opts.Logger, + credentialRetrievalTimeout: opts.CredentialRetrievalTimeout, } } @@ -36,7 +40,9 @@ func (s *SignerForV1SDK) GetVersion() string { } func (s *SignerForV1SDK) GetAccessKeyId() (string, error) { - cred, err := s.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), s.credentialRetrievalTimeout) + defer cancel() + cred, err := s.p.Credentials(timeoutCtx) if err != nil { return "", err } @@ -44,7 +50,9 @@ func (s *SignerForV1SDK) GetAccessKeyId() (string, error) { } func (s *SignerForV1SDK) GetExtraParam() map[string]string { - cred, err := s.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), s.credentialRetrievalTimeout) + defer cancel() + cred, err := s.p.Credentials(timeoutCtx) if err != nil { s.logger().Error(err, fmt.Sprintf("get credentials failed: %s", err)) return nil @@ -56,7 +64,9 @@ func (s *SignerForV1SDK) GetExtraParam() map[string]string { } func (s *SignerForV1SDK) Sign(stringToSign, secretSuffix string) string { - cred, err := s.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), s.credentialRetrievalTimeout) + defer cancel() + cred, err := s.p.Credentials(timeoutCtx) if err != nil { s.logger().Error(err, fmt.Sprintf("get credentials failed: %s", err)) return "" @@ -76,4 +86,7 @@ func (o *SignerForV1SDKOptions) applyDefaults() { if o.Logger == nil { o.Logger = defaultLog } + if o.CredentialRetrievalTimeout <= 0 { + o.CredentialRetrievalTimeout = defaultTimeout + } } diff --git a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v2sdk.go b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v2sdk.go index c53f4478..71369599 100644 --- a/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v2sdk.go +++ b/vendor/github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider/v2sdk.go @@ -2,28 +2,36 @@ package provider import ( "context" + "time" ) +var defaultTimeout = time.Minute * 10 + type CredentialForV2SDK struct { - p CredentialsProvider - Logger Logger + p CredentialsProvider + Logger Logger + credentialRetrievalTimeout time.Duration } type CredentialForV2SDKOptions struct { - Logger Logger + Logger Logger + CredentialRetrievalTimeout time.Duration } func NewCredentialForV2SDK(p CredentialsProvider, opts CredentialForV2SDKOptions) *CredentialForV2SDK { opts.applyDefaults() return &CredentialForV2SDK{ - p: p, - Logger: opts.Logger, + p: p, + Logger: opts.Logger, + credentialRetrievalTimeout: opts.CredentialRetrievalTimeout, } } func (c *CredentialForV2SDK) GetAccessKeyId() (*string, error) { - cred, err := c.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), c.credentialRetrievalTimeout) + defer cancel() + cred, err := c.p.Credentials(timeoutCtx) if err != nil { return nil, err } @@ -31,7 +39,9 @@ func (c *CredentialForV2SDK) GetAccessKeyId() (*string, error) { } func (c *CredentialForV2SDK) GetAccessKeySecret() (*string, error) { - cred, err := c.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), c.credentialRetrievalTimeout) + defer cancel() + cred, err := c.p.Credentials(timeoutCtx) if err != nil { return nil, err } @@ -39,7 +49,9 @@ func (c *CredentialForV2SDK) GetAccessKeySecret() (*string, error) { } func (c *CredentialForV2SDK) GetSecurityToken() (*string, error) { - cred, err := c.p.Credentials(context.TODO()) + timeoutCtx, cancel := context.WithTimeout(context.Background(), c.credentialRetrievalTimeout) + defer cancel() + cred, err := c.p.Credentials(timeoutCtx) if err != nil { return nil, err } @@ -65,6 +77,9 @@ func (o *CredentialForV2SDKOptions) applyDefaults() { if o.Logger == nil { o.Logger = defaultLog } + if o.CredentialRetrievalTimeout <= 0 { + o.CredentialRetrievalTimeout = defaultTimeout + } } func stringPointer(s string) *string { diff --git a/vendor/github.com/alibabacloud-go/darabonba-openapi/v2/client/client.go b/vendor/github.com/alibabacloud-go/darabonba-openapi/v2/client/client.go index c747919e..d21b1d15 100644 --- a/vendor/github.com/alibabacloud-go/darabonba-openapi/v2/client/client.go +++ b/vendor/github.com/alibabacloud-go/darabonba-openapi/v2/client/client.go @@ -1,17 +1,18 @@ // This file is auto-generated, don't edit it. Thanks. -/** - * This is for OpenApi SDK - */ +// Description: +// +// This is for OpenApi SDK package client import ( + "io" + spi "github.com/alibabacloud-go/alibabacloud-gateway-spi/client" openapiutil "github.com/alibabacloud-go/openapi-util/service" util "github.com/alibabacloud-go/tea-utils/v2/service" xml "github.com/alibabacloud-go/tea-xml/service" "github.com/alibabacloud-go/tea/tea" credential "github.com/aliyun/credentials-go/credentials" - "io" ) type GlobalParameters struct { @@ -37,67 +38,176 @@ func (s *GlobalParameters) SetQueries(v map[string]*string) *GlobalParameters { return s } -/** - * Model for initing client - */ +// Description: +// +// Model for initing client type Config struct { // accesskey id AccessKeyId *string `json:"accessKeyId,omitempty" xml:"accessKeyId,omitempty"` // accesskey secret AccessKeySecret *string `json:"accessKeySecret,omitempty" xml:"accessKeySecret,omitempty"` // security token + // + // example: + // + // a.txt SecurityToken *string `json:"securityToken,omitempty" xml:"securityToken,omitempty"` + // bearer token + // + // example: + // + // the-bearer-token + BearerToken *string `json:"bearerToken,omitempty" xml:"bearerToken,omitempty"` // http protocol + // + // example: + // + // http Protocol *string `json:"protocol,omitempty" xml:"protocol,omitempty"` // http method + // + // example: + // + // GET Method *string `json:"method,omitempty" xml:"method,omitempty"` // region id + // + // example: + // + // cn-hangzhou RegionId *string `json:"regionId,omitempty" xml:"regionId,omitempty"` // read timeout + // + // example: + // + // 10 ReadTimeout *int `json:"readTimeout,omitempty" xml:"readTimeout,omitempty"` // connect timeout + // + // example: + // + // 10 ConnectTimeout *int `json:"connectTimeout,omitempty" xml:"connectTimeout,omitempty"` // http proxy + // + // example: + // + // http://localhost HttpProxy *string `json:"httpProxy,omitempty" xml:"httpProxy,omitempty"` // https proxy + // + // example: + // + // https://localhost HttpsProxy *string `json:"httpsProxy,omitempty" xml:"httpsProxy,omitempty"` // credential Credential credential.Credential `json:"credential,omitempty" xml:"credential,omitempty"` // endpoint + // + // example: + // + // cs.aliyuncs.com Endpoint *string `json:"endpoint,omitempty" xml:"endpoint,omitempty"` // proxy white list + // + // example: + // + // http://localhost NoProxy *string `json:"noProxy,omitempty" xml:"noProxy,omitempty"` // max idle conns + // + // example: + // + // 3 MaxIdleConns *int `json:"maxIdleConns,omitempty" xml:"maxIdleConns,omitempty"` // network for endpoint + // + // example: + // + // public Network *string `json:"network,omitempty" xml:"network,omitempty"` // user agent + // + // example: + // + // Alibabacloud/1 UserAgent *string `json:"userAgent,omitempty" xml:"userAgent,omitempty"` // suffix for endpoint + // + // example: + // + // aliyun Suffix *string `json:"suffix,omitempty" xml:"suffix,omitempty"` // socks5 proxy Socks5Proxy *string `json:"socks5Proxy,omitempty" xml:"socks5Proxy,omitempty"` // socks5 network + // + // example: + // + // TCP Socks5NetWork *string `json:"socks5NetWork,omitempty" xml:"socks5NetWork,omitempty"` // endpoint type + // + // example: + // + // internal EndpointType *string `json:"endpointType,omitempty" xml:"endpointType,omitempty"` // OpenPlatform endpoint + // + // example: + // + // openplatform.aliyuncs.com OpenPlatformEndpoint *string `json:"openPlatformEndpoint,omitempty" xml:"openPlatformEndpoint,omitempty"` // Deprecated + // // credential type + // + // example: + // + // access_key Type *string `json:"type,omitempty" xml:"type,omitempty"` // Signature Version + // + // example: + // + // v1 SignatureVersion *string `json:"signatureVersion,omitempty" xml:"signatureVersion,omitempty"` // Signature Algorithm + // + // example: + // + // ACS3-HMAC-SHA256 SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty" xml:"signatureAlgorithm,omitempty"` // Global Parameters GlobalParameters *GlobalParameters `json:"globalParameters,omitempty" xml:"globalParameters,omitempty"` // privite key for client certificate + // + // example: + // + // MIIEvQ Key *string `json:"key,omitempty" xml:"key,omitempty"` // client certificate + // + // example: + // + // -----BEGIN CERTIFICATE----- + // + // xxx-----END CERTIFICATE----- Cert *string `json:"cert,omitempty" xml:"cert,omitempty"` // server certificate + // + // example: + // + // -----BEGIN CERTIFICATE----- + // + // xxx-----END CERTIFICATE----- Ca *string `json:"ca,omitempty" xml:"ca,omitempty"` + // disable HTTP/2 + // + // example: + // + // false + DisableHttp2 *bool `json:"disableHttp2,omitempty" xml:"disableHttp2,omitempty"` } func (s Config) String() string { @@ -123,6 +233,11 @@ func (s *Config) SetSecurityToken(v string) *Config { return s } +func (s *Config) SetBearerToken(v string) *Config { + s.BearerToken = &v + return s +} + func (s *Config) SetProtocol(v string) *Config { s.Protocol = &v return s @@ -248,6 +363,11 @@ func (s *Config) SetCa(v string) *Config { return s } +func (s *Config) SetDisableHttp2(v bool) *Config { + s.DisableHttp2 = &v + return s +} + type OpenApiRequest struct { Headers map[string]*string `json:"headers,omitempty" xml:"headers,omitempty"` Query map[string]*string `json:"query,omitempty" xml:"query,omitempty"` @@ -390,12 +510,14 @@ type Client struct { Key *string Cert *string Ca *string + DisableHttp2 *bool } -/** - * Init client with Config - * @param config config contains the necessary information to create a client - */ +// Description: +// +// # Init client with Config +// +// @param config - config contains the necessary information to create a client func NewClient(config *Config) (*Client, error) { client := new(Client) err := client.Init(config) @@ -429,6 +551,16 @@ func (client *Client) Init(config *Config) (_err error) { return _err } + } else if !tea.BoolValue(util.Empty(config.BearerToken)) { + cc := &credential.Config{ + Type: tea.String("bearer"), + BearerToken: config.BearerToken, + } + client.Credential, _err = credential.NewCredential(cc) + if _err != nil { + return _err + } + } else if !tea.BoolValue(util.IsUnset(config.Credential)) { client.Credential = config.Credential } @@ -455,21 +587,31 @@ func (client *Client) Init(config *Config) (_err error) { client.Key = config.Key client.Cert = config.Cert client.Ca = config.Ca + client.DisableHttp2 = config.DisableHttp2 return nil } -/** - * Encapsulate the request and invoke the network - * @param action api name - * @param version product version - * @param protocol http or https - * @param method e.g. GET - * @param authType authorization type e.g. AK - * @param bodyType response body type e.g. String - * @param request object of OpenApiRequest - * @param runtime which controls some details of call api, such as retry times - * @return the response - */ +// Description: +// +// # Encapsulate the request and invoke the network +// +// @param action - api name +// +// @param version - product version +// +// @param protocol - http or https +// +// @param method - e.g. GET +// +// @param authType - authorization type e.g. AK +// +// @param bodyType - response body type e.g. String +// +// @param request - object of OpenApiRequest +// +// @param runtime - which controls some details of call api, such as retry times +// +// @return the response func (client *Client) DoRPCRequest(action *string, version *string, protocol *string, method *string, authType *string, bodyType *string, request *OpenApiRequest, runtime *util.RuntimeOptions) (_result map[string]interface{}, _err error) { _err = tea.Validate(request) if _err != nil { @@ -531,6 +673,20 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st } + extendsHeaders := make(map[string]*string) + extendsQueries := make(map[string]*string) + if !tea.BoolValue(util.IsUnset(runtime.ExtendsParameters)) { + extendsParameters := runtime.ExtendsParameters + if !tea.BoolValue(util.IsUnset(extendsParameters.Headers)) { + extendsHeaders = extendsParameters.Headers + } + + if !tea.BoolValue(util.IsUnset(extendsParameters.Queries)) { + extendsQueries = extendsParameters.Queries + } + + } + request_.Query = tea.Merge(map[string]*string{ "Action": action, "Format": tea.String("json"), @@ -538,6 +694,7 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st "Timestamp": openapiutil.GetTimestamp(), "SignatureNonce": util.GetNonce(), }, globalQueries, + extendsQueries, request.Query) headers, _err := client.GetRpcHeaders() if _err != nil { @@ -551,7 +708,8 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st "x-acs-version": version, "x-acs-action": action, "user-agent": client.GetUserAgent(), - }, globalHeaders) + }, globalHeaders, + extendsHeaders) } else { request_.Headers = tea.Merge(map[string]*string{ "host": client.Endpoint, @@ -559,6 +717,7 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st "x-acs-action": action, "user-agent": client.GetUserAgent(), }, globalHeaders, + extendsHeaders, headers) } @@ -574,40 +733,56 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st } if !tea.BoolValue(util.EqualString(authType, tea.String("Anonymous"))) { - accessKeyId, _err := client.GetAccessKeyId() + credentialType, _err := client.GetType() if _err != nil { return _result, _err } - accessKeySecret, _err := client.GetAccessKeySecret() - if _err != nil { - return _result, _err - } + if tea.BoolValue(util.EqualString(credentialType, tea.String("bearer"))) { + bearerToken, _err := client.GetBearerToken() + if _err != nil { + return _result, _err + } - securityToken, _err := client.GetSecurityToken() - if _err != nil { - return _result, _err - } + request_.Query["BearerToken"] = bearerToken + request_.Query["SignatureType"] = tea.String("BEARERTOKEN") + } else { + accessKeyId, _err := client.GetAccessKeyId() + if _err != nil { + return _result, _err + } - if !tea.BoolValue(util.Empty(securityToken)) { - request_.Query["SecurityToken"] = securityToken - } + accessKeySecret, _err := client.GetAccessKeySecret() + if _err != nil { + return _result, _err + } - request_.Query["SignatureMethod"] = tea.String("HMAC-SHA1") - request_.Query["SignatureVersion"] = tea.String("1.0") - request_.Query["AccessKeyId"] = accessKeyId - var t map[string]interface{} - if !tea.BoolValue(util.IsUnset(request.Body)) { - t, _err = util.AssertAsMap(request.Body) + securityToken, _err := client.GetSecurityToken() if _err != nil { return _result, _err } + if !tea.BoolValue(util.Empty(securityToken)) { + request_.Query["SecurityToken"] = securityToken + } + + request_.Query["SignatureMethod"] = tea.String("HMAC-SHA1") + request_.Query["SignatureVersion"] = tea.String("1.0") + request_.Query["AccessKeyId"] = accessKeyId + var t map[string]interface{} + if !tea.BoolValue(util.IsUnset(request.Body)) { + t, _err = util.AssertAsMap(request.Body) + if _err != nil { + return _result, _err + } + + } + + signedParam := tea.Merge(request_.Query, + openapiutil.Query(t)) + request_.Query["Signature"] = openapiutil.GetRPCSignature(signedParam, request_.Method, accessKeySecret) } - signedParam := tea.Merge(request_.Query, - openapiutil.Query(t)) - request_.Query["Signature"] = openapiutil.GetRPCSignature(signedParam, request_.Method, accessKeySecret) } response_, _err := tea.DoRequest(request_, _runtime) @@ -720,19 +895,29 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st return _resp, _err } -/** - * Encapsulate the request and invoke the network - * @param action api name - * @param version product version - * @param protocol http or https - * @param method e.g. GET - * @param authType authorization type e.g. AK - * @param pathname pathname of every api - * @param bodyType response body type e.g. String - * @param request object of OpenApiRequest - * @param runtime which controls some details of call api, such as retry times - * @return the response - */ +// Description: +// +// # Encapsulate the request and invoke the network +// +// @param action - api name +// +// @param version - product version +// +// @param protocol - http or https +// +// @param method - e.g. GET +// +// @param authType - authorization type e.g. AK +// +// @param pathname - pathname of every api +// +// @param bodyType - response body type e.g. String +// +// @param request - object of OpenApiRequest +// +// @param runtime - which controls some details of call api, such as retry times +// +// @return the response func (client *Client) DoROARequest(action *string, version *string, protocol *string, method *string, authType *string, pathname *string, bodyType *string, request *OpenApiRequest, runtime *util.RuntimeOptions) (_result map[string]interface{}, _err error) { _err = tea.Validate(request) if _err != nil { @@ -794,6 +979,20 @@ func (client *Client) DoROARequest(action *string, version *string, protocol *st } + extendsHeaders := make(map[string]*string) + extendsQueries := make(map[string]*string) + if !tea.BoolValue(util.IsUnset(runtime.ExtendsParameters)) { + extendsParameters := runtime.ExtendsParameters + if !tea.BoolValue(util.IsUnset(extendsParameters.Headers)) { + extendsHeaders = extendsParameters.Headers + } + + if !tea.BoolValue(util.IsUnset(extendsParameters.Queries)) { + extendsQueries = extendsParameters.Queries + } + + } + request_.Headers = tea.Merge(map[string]*string{ "date": util.GetDateUTCString(), "host": client.Endpoint, @@ -805,41 +1004,59 @@ func (client *Client) DoROARequest(action *string, version *string, protocol *st "x-acs-action": action, "user-agent": util.GetUserAgent(client.UserAgent), }, globalHeaders, + extendsHeaders, request.Headers) if !tea.BoolValue(util.IsUnset(request.Body)) { request_.Body = tea.ToReader(util.ToJSONString(request.Body)) request_.Headers["content-type"] = tea.String("application/json; charset=utf-8") } - request_.Query = globalQueries + request_.Query = tea.Merge(globalQueries, + extendsQueries) if !tea.BoolValue(util.IsUnset(request.Query)) { request_.Query = tea.Merge(request_.Query, request.Query) } if !tea.BoolValue(util.EqualString(authType, tea.String("Anonymous"))) { - accessKeyId, _err := client.GetAccessKeyId() + credentialType, _err := client.GetType() if _err != nil { return _result, _err } - accessKeySecret, _err := client.GetAccessKeySecret() - if _err != nil { - return _result, _err - } + if tea.BoolValue(util.EqualString(credentialType, tea.String("bearer"))) { + bearerToken, _err := client.GetBearerToken() + if _err != nil { + return _result, _err + } - securityToken, _err := client.GetSecurityToken() - if _err != nil { - return _result, _err - } + request_.Headers["x-acs-bearer-token"] = bearerToken + request_.Headers["x-acs-signature-type"] = tea.String("BEARERTOKEN") + } else { + accessKeyId, _err := client.GetAccessKeyId() + if _err != nil { + return _result, _err + } - if !tea.BoolValue(util.Empty(securityToken)) { - request_.Headers["x-acs-accesskey-id"] = accessKeyId - request_.Headers["x-acs-security-token"] = securityToken + accessKeySecret, _err := client.GetAccessKeySecret() + if _err != nil { + return _result, _err + } + + securityToken, _err := client.GetSecurityToken() + if _err != nil { + return _result, _err + } + + if !tea.BoolValue(util.Empty(securityToken)) { + request_.Headers["x-acs-accesskey-id"] = accessKeyId + request_.Headers["x-acs-security-token"] = securityToken + } + + stringToSign := openapiutil.GetStringToSign(request_) + request_.Headers["authorization"] = tea.String("acs " + tea.StringValue(accessKeyId) + ":" + tea.StringValue(openapiutil.GetROASignature(stringToSign, accessKeySecret))) } - stringToSign := openapiutil.GetStringToSign(request_) - request_.Headers["authorization"] = tea.String("acs " + tea.StringValue(accessKeyId) + ":" + tea.StringValue(openapiutil.GetROASignature(stringToSign, accessKeySecret))) } response_, _err := tea.DoRequest(request_, _runtime) @@ -961,19 +1178,29 @@ func (client *Client) DoROARequest(action *string, version *string, protocol *st return _resp, _err } -/** - * Encapsulate the request and invoke the network with form body - * @param action api name - * @param version product version - * @param protocol http or https - * @param method e.g. GET - * @param authType authorization type e.g. AK - * @param pathname pathname of every api - * @param bodyType response body type e.g. String - * @param request object of OpenApiRequest - * @param runtime which controls some details of call api, such as retry times - * @return the response - */ +// Description: +// +// # Encapsulate the request and invoke the network with form body +// +// @param action - api name +// +// @param version - product version +// +// @param protocol - http or https +// +// @param method - e.g. GET +// +// @param authType - authorization type e.g. AK +// +// @param pathname - pathname of every api +// +// @param bodyType - response body type e.g. String +// +// @param request - object of OpenApiRequest +// +// @param runtime - which controls some details of call api, such as retry times +// +// @return the response func (client *Client) DoROARequestWithForm(action *string, version *string, protocol *string, method *string, authType *string, pathname *string, bodyType *string, request *OpenApiRequest, runtime *util.RuntimeOptions) (_result map[string]interface{}, _err error) { _err = tea.Validate(request) if _err != nil { @@ -1035,6 +1262,20 @@ func (client *Client) DoROARequestWithForm(action *string, version *string, prot } + extendsHeaders := make(map[string]*string) + extendsQueries := make(map[string]*string) + if !tea.BoolValue(util.IsUnset(runtime.ExtendsParameters)) { + extendsParameters := runtime.ExtendsParameters + if !tea.BoolValue(util.IsUnset(extendsParameters.Headers)) { + extendsHeaders = extendsParameters.Headers + } + + if !tea.BoolValue(util.IsUnset(extendsParameters.Queries)) { + extendsQueries = extendsParameters.Queries + } + + } + request_.Headers = tea.Merge(map[string]*string{ "date": util.GetDateUTCString(), "host": client.Endpoint, @@ -1046,6 +1287,7 @@ func (client *Client) DoROARequestWithForm(action *string, version *string, prot "x-acs-action": action, "user-agent": util.GetUserAgent(client.UserAgent), }, globalHeaders, + extendsHeaders, request.Headers) if !tea.BoolValue(util.IsUnset(request.Body)) { m, _err := util.AssertAsMap(request.Body) @@ -1057,35 +1299,52 @@ func (client *Client) DoROARequestWithForm(action *string, version *string, prot request_.Headers["content-type"] = tea.String("application/x-www-form-urlencoded") } - request_.Query = globalQueries + request_.Query = tea.Merge(globalQueries, + extendsQueries) if !tea.BoolValue(util.IsUnset(request.Query)) { request_.Query = tea.Merge(request_.Query, request.Query) } if !tea.BoolValue(util.EqualString(authType, tea.String("Anonymous"))) { - accessKeyId, _err := client.GetAccessKeyId() + credentialType, _err := client.GetType() if _err != nil { return _result, _err } - accessKeySecret, _err := client.GetAccessKeySecret() - if _err != nil { - return _result, _err - } + if tea.BoolValue(util.EqualString(credentialType, tea.String("bearer"))) { + bearerToken, _err := client.GetBearerToken() + if _err != nil { + return _result, _err + } - securityToken, _err := client.GetSecurityToken() - if _err != nil { - return _result, _err - } + request_.Headers["x-acs-bearer-token"] = bearerToken + request_.Headers["x-acs-signature-type"] = tea.String("BEARERTOKEN") + } else { + accessKeyId, _err := client.GetAccessKeyId() + if _err != nil { + return _result, _err + } - if !tea.BoolValue(util.Empty(securityToken)) { - request_.Headers["x-acs-accesskey-id"] = accessKeyId - request_.Headers["x-acs-security-token"] = securityToken + accessKeySecret, _err := client.GetAccessKeySecret() + if _err != nil { + return _result, _err + } + + securityToken, _err := client.GetSecurityToken() + if _err != nil { + return _result, _err + } + + if !tea.BoolValue(util.Empty(securityToken)) { + request_.Headers["x-acs-accesskey-id"] = accessKeyId + request_.Headers["x-acs-security-token"] = securityToken + } + + stringToSign := openapiutil.GetStringToSign(request_) + request_.Headers["authorization"] = tea.String("acs " + tea.StringValue(accessKeyId) + ":" + tea.StringValue(openapiutil.GetROASignature(stringToSign, accessKeySecret))) } - stringToSign := openapiutil.GetStringToSign(request_) - request_.Headers["authorization"] = tea.String("acs " + tea.StringValue(accessKeyId) + ":" + tea.StringValue(openapiutil.GetROASignature(stringToSign, accessKeySecret))) } response_, _err := tea.DoRequest(request_, _runtime) @@ -1205,18 +1464,27 @@ func (client *Client) DoROARequestWithForm(action *string, version *string, prot return _resp, _err } -/** - * Encapsulate the request and invoke the network - * @param action api name - * @param version product version - * @param protocol http or https - * @param method e.g. GET - * @param authType authorization type e.g. AK - * @param bodyType response body type e.g. String - * @param request object of OpenApiRequest - * @param runtime which controls some details of call api, such as retry times - * @return the response - */ +// Description: +// +// # Encapsulate the request and invoke the network +// +// @param action - api name +// +// @param version - product version +// +// @param protocol - http or https +// +// @param method - e.g. GET +// +// @param authType - authorization type e.g. AK +// +// @param bodyType - response body type e.g. String +// +// @param request - object of OpenApiRequest +// +// @param runtime - which controls some details of call api, such as retry times +// +// @return the response func (client *Client) DoRequest(params *Params, request *OpenApiRequest, runtime *util.RuntimeOptions) (_result map[string]interface{}, _err error) { _err = tea.Validate(params) if _err != nil { @@ -1283,15 +1551,21 @@ func (client *Client) DoRequest(params *Params, request *OpenApiRequest, runtime } extendsHeaders := make(map[string]*string) + extendsQueries := make(map[string]*string) if !tea.BoolValue(util.IsUnset(runtime.ExtendsParameters)) { extendsParameters := runtime.ExtendsParameters if !tea.BoolValue(util.IsUnset(extendsParameters.Headers)) { extendsHeaders = extendsParameters.Headers } + if !tea.BoolValue(util.IsUnset(extendsParameters.Queries)) { + extendsQueries = extendsParameters.Queries + } + } request_.Query = tea.Merge(globalQueries, + extendsQueries, request.Query) // endpoint is setted in product client request_.Headers = tea.Merge(map[string]*string{ @@ -1371,6 +1645,12 @@ func (client *Client) DoRequest(params *Params, request *OpenApiRequest, runtime if tea.BoolValue(util.EqualString(authType, tea.String("bearer"))) { bearerToken := credentialModel.BearerToken request_.Headers["x-acs-bearer-token"] = bearerToken + if tea.BoolValue(util.EqualString(params.Style, tea.String("RPC"))) { + request_.Query["SignatureType"] = tea.String("BEARERTOKEN") + } else { + request_.Headers["x-acs-signature-type"] = tea.String("BEARERTOKEN") + } + } else { accessKeyId := credentialModel.AccessKeyId accessKeySecret := credentialModel.AccessKeySecret @@ -1516,18 +1796,27 @@ func (client *Client) DoRequest(params *Params, request *OpenApiRequest, runtime return _resp, _err } -/** - * Encapsulate the request and invoke the network - * @param action api name - * @param version product version - * @param protocol http or https - * @param method e.g. GET - * @param authType authorization type e.g. AK - * @param bodyType response body type e.g. String - * @param request object of OpenApiRequest - * @param runtime which controls some details of call api, such as retry times - * @return the response - */ +// Description: +// +// # Encapsulate the request and invoke the network +// +// @param action - api name +// +// @param version - product version +// +// @param protocol - http or https +// +// @param method - e.g. GET +// +// @param authType - authorization type e.g. AK +// +// @param bodyType - response body type e.g. String +// +// @param request - object of OpenApiRequest +// +// @param runtime - which controls some details of call api, such as retry times +// +// @return the response func (client *Client) Execute(params *Params, request *OpenApiRequest, runtime *util.RuntimeOptions) (_result map[string]interface{}, _err error) { _err = tea.Validate(params) if _err != nil { @@ -1562,7 +1851,8 @@ func (client *Client) Execute(params *Params, request *OpenApiRequest, runtime * "policy": tea.StringValue(util.DefaultString(runtime.BackoffPolicy, tea.String("no"))), "period": tea.IntValue(util.DefaultNumber(runtime.BackoffPeriod, tea.Int(1))), }, - "ignoreSSL": tea.BoolValue(runtime.IgnoreSSL), + "ignoreSSL": tea.BoolValue(runtime.IgnoreSSL), + "disableHttp2": DefaultAny(client.DisableHttp2, tea.Bool(false)), } _resp := make(map[string]interface{}) @@ -1596,11 +1886,27 @@ func (client *Client) Execute(params *Params, request *OpenApiRequest, runtime * } + extendsHeaders := make(map[string]*string) + extendsQueries := make(map[string]*string) + if !tea.BoolValue(util.IsUnset(runtime.ExtendsParameters)) { + extendsParameters := runtime.ExtendsParameters + if !tea.BoolValue(util.IsUnset(extendsParameters.Headers)) { + extendsHeaders = extendsParameters.Headers + } + + if !tea.BoolValue(util.IsUnset(extendsParameters.Queries)) { + extendsQueries = extendsParameters.Queries + } + + } + requestContext := &spi.InterceptorContextRequest{ Headers: tea.Merge(globalHeaders, + extendsHeaders, request.Headers, headers), Query: tea.Merge(globalQueries, + extendsQueries, request.Query), Body: request.Body, Stream: request.Stream, @@ -1726,20 +2032,22 @@ func (client *Client) CallApi(params *Params, request *OpenApiRequest, runtime * } -/** - * Get user agent - * @return user agent - */ +// Description: +// +// # Get user agent +// +// @return user agent func (client *Client) GetUserAgent() (_result *string) { userAgent := util.GetUserAgent(client.UserAgent) _result = userAgent return _result } -/** - * Get accesskey id by using credential - * @return accesskey id - */ +// Description: +// +// # Get accesskey id by using credential +// +// @return accesskey id func (client *Client) GetAccessKeyId() (_result *string, _err error) { if tea.BoolValue(util.IsUnset(client.Credential)) { _result = tea.String("") @@ -1755,10 +2063,11 @@ func (client *Client) GetAccessKeyId() (_result *string, _err error) { return _result, _err } -/** - * Get accesskey secret by using credential - * @return accesskey secret - */ +// Description: +// +// # Get accesskey secret by using credential +// +// @return accesskey secret func (client *Client) GetAccessKeySecret() (_result *string, _err error) { if tea.BoolValue(util.IsUnset(client.Credential)) { _result = tea.String("") @@ -1774,10 +2083,11 @@ func (client *Client) GetAccessKeySecret() (_result *string, _err error) { return _result, _err } -/** - * Get security token by using credential - * @return security token - */ +// Description: +// +// # Get security token by using credential +// +// @return security token func (client *Client) GetSecurityToken() (_result *string, _err error) { if tea.BoolValue(util.IsUnset(client.Credential)) { _result = tea.String("") @@ -1793,10 +2103,11 @@ func (client *Client) GetSecurityToken() (_result *string, _err error) { return _result, _err } -/** - * Get bearer token by credential - * @return bearer token - */ +// Description: +// +// # Get bearer token by credential +// +// @return bearer token func (client *Client) GetBearerToken() (_result *string, _err error) { if tea.BoolValue(util.IsUnset(client.Credential)) { _result = tea.String("") @@ -1808,10 +2119,11 @@ func (client *Client) GetBearerToken() (_result *string, _err error) { return _result, _err } -/** - * Get credential type by credential - * @return credential type e.g. access_key - */ +// Description: +// +// # Get credential type by credential +// +// @return credential type e.g. access_key func (client *Client) GetType() (_result *string, _err error) { if tea.BoolValue(util.IsUnset(client.Credential)) { _result = tea.String("") @@ -1823,12 +2135,15 @@ func (client *Client) GetType() (_result *string, _err error) { return _result, _err } -/** - * If inputValue is not null, return it or return defaultValue - * @param inputValue users input value - * @param defaultValue default value - * @return the final result - */ +// Description: +// +// # If inputValue is not null, return it or return defaultValue +// +// @param inputValue - users input value +// +// @param defaultValue - default value +// +// @return the final result func DefaultAny(inputValue interface{}, defaultValue interface{}) (_result interface{}) { if tea.BoolValue(util.IsUnset(inputValue)) { _result = defaultValue @@ -1839,10 +2154,11 @@ func DefaultAny(inputValue interface{}, defaultValue interface{}) (_result inter return _result } -/** - * If the endpointRule and config.endpoint are empty, throw error - * @param config config contains the necessary information to create a client - */ +// Description: +// +// # If the endpointRule and config.endpoint are empty, throw error +// +// @param config - config contains the necessary information to create a client func (client *Client) CheckConfig(config *Config) (_err error) { if tea.BoolValue(util.Empty(client.EndpointRule)) && tea.BoolValue(util.Empty(config.Endpoint)) { _err = tea.NewSDKError(map[string]interface{}{ @@ -1855,27 +2171,29 @@ func (client *Client) CheckConfig(config *Config) (_err error) { return _err } -/** - * set gateway client - * @param spi. - */ +// Description: +// +// set gateway client +// +// @param spi - . func (client *Client) SetGatewayClient(spi spi.ClientInterface) (_err error) { client.Spi = spi return _err } -/** - * set RPC header for debug - * @param headers headers for debug, this header can be used only once. - */ +// Description: +// +// set RPC header for debug +// +// @param headers - headers for debug, this header can be used only once. func (client *Client) SetRpcHeaders(headers map[string]*string) (_err error) { client.Headers = headers return _err } -/** - * get RPC header for debug - */ +// Description: +// +// get RPC header for debug func (client *Client) GetRpcHeaders() (_result map[string]*string, _err error) { headers := client.Headers client.Headers = nil diff --git a/vendor/github.com/alibabacloud-go/tea-utils/v2/service/service.go b/vendor/github.com/alibabacloud-go/tea-utils/v2/service/service.go index 1714dcc0..3a323f10 100644 --- a/vendor/github.com/alibabacloud-go/tea-utils/v2/service/service.go +++ b/vendor/github.com/alibabacloud-go/tea-utils/v2/service/service.go @@ -26,6 +26,7 @@ var defaultUserAgent = fmt.Sprintf("AlibabaCloud (%s; %s) Golang/%s Core/%s TeaD type ExtendsParameters struct { Headers map[string]*string `json:"headers,omitempty" xml:"headers,omitempty"` + Queries map[string]*string `json:"queries,omitempty" xml:"queries,omitempty"` } func (s ExtendsParameters) String() string { @@ -41,6 +42,11 @@ func (s *ExtendsParameters) SetHeaders(v map[string]*string) *ExtendsParameters return s } +func (s *ExtendsParameters) SetQueries(v map[string]*string) *ExtendsParameters { + s.Queries = v + return s +} + type RuntimeOptions struct { Autoretry *bool `json:"autoretry" xml:"autoretry"` IgnoreSSL *bool `json:"ignoreSSL" xml:"ignoreSSL"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 9ed9cb7e..1aef34d9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -15,7 +15,7 @@ github.com/alibabacloud-go/cs-20151215/v3/client # github.com/alibabacloud-go/darabonba-openapi v0.2.1 ## explicit; go 1.14 github.com/alibabacloud-go/darabonba-openapi/client -# github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.6 +# github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.9 ## explicit; go 1.14 github.com/alibabacloud-go/darabonba-openapi/v2/client # github.com/alibabacloud-go/debug v1.0.0 @@ -40,7 +40,7 @@ github.com/alibabacloud-go/tea/utils # github.com/alibabacloud-go/tea-utils v1.4.5 ## explicit; go 1.14 github.com/alibabacloud-go/tea-utils/service -# github.com/alibabacloud-go/tea-utils/v2 v2.0.5 +# github.com/alibabacloud-go/tea-utils/v2 v2.0.6 ## explicit; go 1.14 github.com/alibabacloud-go/tea-utils/v2/service # github.com/alibabacloud-go/tea-xml v1.1.3