Skip to content

Commit

Permalink
feat: support extends query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
yndu13 committed Jul 5, 2024
1 parent b1ed2f3 commit 40b9e85
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 1 deletion.
4 changes: 4 additions & 0 deletions csharp/core/Models/ExtendsParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class ExtendsParameters : TeaModel {
[Validation(Required=false)]
public Dictionary<string, string> Headers { get; set; }

[NameInMap("queries")]
[Validation(Required=false)]
public Dictionary<string, string> Queries { get; set; }

}

}
4 changes: 4 additions & 0 deletions csharp/tests/Models/RuntimeObjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public void Test_RuntimeObject()
extendsParameters.Headers = new Dictionary<string, string>{
{"key", "value"},
};
extendsParameters.Queries = new Dictionary<string, string>{
{"key", "value"},
};
runtime.ExtendsParameters = extendsParameters;

Assert.NotNull(runtime);
Expand All @@ -57,6 +60,7 @@ public void Test_RuntimeObject()
Assert.False(runtime.KeepAlive);
Assert.NotNull(runtime.ExtendsParameters);
Assert.Equal("value", runtime.ExtendsParameters.Headers["key"]);
Assert.Equal("value", runtime.ExtendsParameters.Queries["key"]);
}
}
}
6 changes: 6 additions & 0 deletions golang/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"`
Expand Down
2 changes: 2 additions & 0 deletions golang/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func Test_SetFunc(t *testing.T) {
SetSocks5Proxy("sock5proxy").
SetKeepAlive(false).
SetExtendsParameters(new(ExtendsParameters).SetHeaders(map[string]*string{
"key": tea.String("value")}).SetQueries(map[string]*string{
"key": tea.String("value"),
}))
utils.AssertEqual(t, true, tea.BoolValue(runtime.Autoretry))
Expand All @@ -51,6 +52,7 @@ func Test_SetFunc(t *testing.T) {
utils.AssertEqual(t, "sock5proxy", tea.StringValue(runtime.Socks5Proxy))
utils.AssertEqual(t, false, tea.BoolValue(runtime.KeepAlive))
utils.AssertEqual(t, "value", tea.StringValue(runtime.ExtendsParameters.Headers["key"]))
utils.AssertEqual(t, "value", tea.StringValue(runtime.ExtendsParameters.Queries["key"]))
runtime.GoString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class ExtendsParameters extends TeaModel {
@NameInMap("headers")
public java.util.Map<String, String> headers;

@NameInMap("queries")
public java.util.Map<String, String> queries;

public static ExtendsParameters build(java.util.Map<String, ?> map) throws Exception {
ExtendsParameters self = new ExtendsParameters();
return TeaModel.build(map, self);
Expand All @@ -20,4 +23,12 @@ public java.util.Map<String, String> getHeaders() {
return this.headers;
}

public ExtendsParameters setQueries(java.util.Map<String, String> queries) {
this.queries = queries;
return this;
}
public java.util.Map<String, String> getQueries() {
return this.queries;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public void setAndGetTest() throws Exception {

Map<String, String> headers = new HashMap<String, String>();
headers.put("key", "value");
Map<String, String> queries = new HashMap<String, String>();
queries.put("key", "value");
Map<String, Object> extendsParameters = new HashMap<String, Object>();
extendsParameters.put("headers", headers);
extendsParameters.put("queries", queries);
map.put("extendsParameters", extendsParameters);

RuntimeOptions opts = RuntimeOptions.build(map);
Expand All @@ -49,5 +52,6 @@ public void setAndGetTest() throws Exception {
Assert.assertEquals(300, (int) opts.maxIdleConns);
Assert.assertEquals(true, opts.keepAlive);
Assert.assertEquals("value", opts.extendsParameters.headers.get("key"));
Assert.assertEquals("value", opts.extendsParameters.queries.get("key"));
}
}
1 change: 1 addition & 0 deletions main.tea
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
model ExtendsParameters {
headers?: map[string]string,
queries?: map[string]string,
}

/**
Expand Down
8 changes: 8 additions & 0 deletions php/src/Utils/ExtendsParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public function toMap() {
if (null !== $this->headers) {
$res['headers'] = $this->headers;
}
if (null !== $this->queries) {
$res['queries'] = $this->queries;
}
return $res;
}
/**
Expand All @@ -23,8 +26,13 @@ public static function fromMap($map = []) {
if(isset($map['headers'])){
$model->headers = $map['headers'];
}
if(isset($map['queries'])){
$model->queries = $map['queries'];
}
return $model;
}
public $headers;

public $queries;

}
2 changes: 2 additions & 0 deletions php/tests/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public function testRuntimeOptions()
"keepAlive" => true,
"extendsParameters" => new ExtendsParameters([
"headers" => ['key' => 'value'],
"queries" => ['key' => 'value'],
]),
]);
$this->assertEquals(false, $opts->autoretry);
Expand All @@ -437,6 +438,7 @@ public function testRuntimeOptions()
$this->assertEquals(300, $opts->maxIdleConns);
$this->assertEquals(true, $opts->keepAlive);
$this->assertEquals('value', $opts->extendsParameters->headers['key']);
$this->assertEquals('value', $opts->extendsParameters->queries['key']);
}

private function convert($body, &$content)
Expand Down
13 changes: 12 additions & 1 deletion python/alibabacloud_tea_util/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class ExtendsParameters(TeaModel):
def __init__(
self,
headers: Dict[str, str] = None,
queries: Dict[str, str] = None,
):
self.headers = headers
self.queries = queries

def validate(self):
pass
Expand All @@ -22,12 +24,16 @@ def to_map(self):
result = dict()
if self.headers is not None:
result['headers'] = self.headers
if self.queries is not None:
result['queries'] = self.queries
return result

def from_map(self, m: dict = None):
m = m or dict()
if m.get('headers') is not None:
self.headers = m.get('headers')
if m.get('queries') is not None:
self.queries = m.get('queries')
return self


Expand Down Expand Up @@ -97,9 +103,14 @@ def __init__(
self.extends_parameters = extends_parameters

def validate(self):
pass
if self.extends_parameters:
self.extends_parameters.validate()

def to_map(self):
_map = super().to_map()
if _map is not None:
return _map

result = dict()
if self.autoretry is not None:
result['autoretry'] = self.autoretry
Expand Down
8 changes: 8 additions & 0 deletions python/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_init(self):

extends_parameters = ExtendsParameters(
headers={'key': 'value'},
queries={'key': 'value'},
)
extends_parameters.validate()
self.assertIsNotNone(extends_parameters.headers)
Expand Down Expand Up @@ -55,6 +56,7 @@ def test_init(self):
self.assertEqual('test', option.socks_5net_work)
self.assertEqual(False, option.keep_alive)
self.assertEqual('value', option.extends_parameters.headers['key'])
self.assertEqual('value', option.extends_parameters.queries['key'])

def test_to_map(self):
option = RuntimeOptions(
Expand All @@ -78,6 +80,7 @@ def test_to_map(self):
keep_alive=False,
extends_parameters=ExtendsParameters(
headers={'key': 'value'},
queries={'key': 'value'},
),
)
result = option.to_map()
Expand All @@ -100,6 +103,7 @@ def test_to_map(self):
self.assertEqual('test', result.get('socks5NetWork'))
self.assertEqual(False, result.get('keepAlive'))
self.assertEqual('value', result.get('extendsParameters').get('headers').get('key'))
self.assertEqual('value', result.get('extendsParameters').get('queries').get('key'))

def test_from_map(self):
option = RuntimeOptions()
Expand All @@ -126,6 +130,9 @@ def test_from_map(self):
'headers': {
'key': 'value',
},
'queries': {
'key': 'value',
},
},
}
option.from_map(dic)
Expand All @@ -148,3 +155,4 @@ def test_from_map(self):
self.assertEqual('test', option.socks_5net_work)
self.assertEqual(False, option.keep_alive)
self.assertEqual('value', option.extends_parameters.headers['key'])
self.assertEqual('value', option.extends_parameters.queries['key'])
8 changes: 8 additions & 0 deletions swift/Sources/TeaUtils/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Tea
public class ExtendsParameters : Tea.TeaModel {
public var headers: [String: String]?

public var queries: [String: String]?

public override init() {
super.init()
}
Expand All @@ -21,13 +23,19 @@ public class ExtendsParameters : Tea.TeaModel {
if self.headers != nil {
map["headers"] = self.headers!
}
if self.queries != nil {
map["queries"] = self.queries!
}
return map
}

public override func fromMap(_ dict: [String: Any]) -> Void {
if dict.keys.contains("headers") {
self.headers = dict["headers"] as! [String: String]
}
if dict.keys.contains("queries") {
self.queries = dict["queries"] as! [String: String]
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions swift/Tests/TeaUtilsTests/TeaUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ final class ClientTests: XCTestCase {
"headers": [
"key": "value"
],
"queries": [
"key": "value"
],
],
]
)
Expand All @@ -482,6 +485,7 @@ final class ClientTests: XCTestCase {
XCTAssertEqual(300, opts.maxIdleConns)
XCTAssertEqual(true, opts.keepAlive)
XCTAssertEqual("value", opts.extendsParameters!.headers!["key"])
XCTAssertEqual("value", opts.extendsParameters!.queries!["key"])
}

}
3 changes: 3 additions & 0 deletions ts/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ const DEFAULT_USER_AGENT = `AlibabaCloud (${platform()}; ${arch()}) Node.js/${pr

export class ExtendsParameters extends $tea.Model {
headers?: { [key: string]: string };
queries?: { [key: string]: string };
static names(): { [key: string]: string } {
return {
headers: 'headers',
queries: 'queries',
};
}

static types(): { [key: string]: any } {
return {
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
};
}

Expand Down
4 changes: 4 additions & 0 deletions ts/test/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ describe('Tea Util', function () {
extendsParameters: {
headers: {
key: 'value',
},
queries: {
key: 'value',
}
},
}
Expand All @@ -159,6 +162,7 @@ describe('Tea Util', function () {
assert.ok(opts.maxIdleConns === 300);
assert.ok(opts.keepAlive === true);
assert.ok(opts.extendsParameters.headers['key'] === 'value');
assert.ok(opts.extendsParameters.queries['key'] === 'value');
});

it('stringifyMapValue', function () {
Expand Down

0 comments on commit 40b9e85

Please sign in to comment.