Skip to content

Commit 3c87ba7

Browse files
committed
feat: support signature version v4
1 parent 0777ba8 commit 3c87ba7

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

client/client.go

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st
723723
"x-acs-action": action,
724724
"user-agent": client.GetUserAgent(),
725725
}, globalHeaders,
726-
extendsHeaders)
726+
extendsHeaders,
727+
request.Headers)
727728
} else {
728729
request_.Headers = tea.Merge(map[string]*string{
729730
"host": client.Endpoint,
@@ -732,6 +733,7 @@ func (client *Client) DoRPCRequest(action *string, version *string, protocol *st
732733
"user-agent": client.GetUserAgent(),
733734
}, globalHeaders,
734735
extendsHeaders,
736+
request.Headers,
735737
headers)
736738
}
737739

@@ -2029,33 +2031,44 @@ func (client *Client) CallApi(params *Params, request *OpenApiRequest, runtime *
20292031
return _result, _err
20302032
}
20312033

2032-
if tea.BoolValue(util.IsUnset(client.SignatureAlgorithm)) || !tea.BoolValue(util.EqualString(client.SignatureAlgorithm, tea.String("v2"))) {
2033-
_result = make(map[string]interface{})
2034-
_body, _err := client.DoRequest(params, request, runtime)
2035-
if _err != nil {
2034+
if tea.BoolValue(util.IsUnset(client.SignatureVersion)) || !tea.BoolValue(util.EqualString(client.SignatureVersion, tea.String("v4"))) {
2035+
if tea.BoolValue(util.IsUnset(client.SignatureAlgorithm)) || !tea.BoolValue(util.EqualString(client.SignatureAlgorithm, tea.String("v2"))) {
2036+
_result = make(map[string]interface{})
2037+
_body, _err := client.DoRequest(params, request, runtime)
2038+
if _err != nil {
2039+
return _result, _err
2040+
}
2041+
_result = _body
20362042
return _result, _err
2037-
}
2038-
_result = _body
2039-
return _result, _err
2040-
} else if tea.BoolValue(util.EqualString(params.Style, tea.String("ROA"))) && tea.BoolValue(util.EqualString(params.ReqBodyType, tea.String("json"))) {
2041-
_result = make(map[string]interface{})
2042-
_body, _err := client.DoROARequest(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.Pathname, params.BodyType, request, runtime)
2043-
if _err != nil {
2043+
} else if tea.BoolValue(util.EqualString(params.Style, tea.String("ROA"))) && tea.BoolValue(util.EqualString(params.ReqBodyType, tea.String("json"))) {
2044+
_result = make(map[string]interface{})
2045+
_body, _err := client.DoROARequest(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.Pathname, params.BodyType, request, runtime)
2046+
if _err != nil {
2047+
return _result, _err
2048+
}
2049+
_result = _body
20442050
return _result, _err
2045-
}
2046-
_result = _body
2047-
return _result, _err
2048-
} else if tea.BoolValue(util.EqualString(params.Style, tea.String("ROA"))) {
2049-
_result = make(map[string]interface{})
2050-
_body, _err := client.DoROARequestWithForm(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.Pathname, params.BodyType, request, runtime)
2051-
if _err != nil {
2051+
} else if tea.BoolValue(util.EqualString(params.Style, tea.String("ROA"))) {
2052+
_result = make(map[string]interface{})
2053+
_body, _err := client.DoROARequestWithForm(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.Pathname, params.BodyType, request, runtime)
2054+
if _err != nil {
2055+
return _result, _err
2056+
}
2057+
_result = _body
2058+
return _result, _err
2059+
} else {
2060+
_result = make(map[string]interface{})
2061+
_body, _err := client.DoRPCRequest(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.BodyType, request, runtime)
2062+
if _err != nil {
2063+
return _result, _err
2064+
}
2065+
_result = _body
20522066
return _result, _err
20532067
}
2054-
_result = _body
2055-
return _result, _err
2068+
20562069
} else {
20572070
_result = make(map[string]interface{})
2058-
_body, _err := client.DoRPCRequest(params.Action, params.Version, params.Protocol, params.Method, params.AuthType, params.BodyType, request, runtime)
2071+
_body, _err := client.Execute(params, request, runtime)
20592072
if _err != nil {
20602073
return _result, _err
20612074
}

0 commit comments

Comments
 (0)