@darabonba/python-generator 1.2.8 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +30 -0
- package/ChangeLog.md +12 -0
- package/README-CN.md +0 -3
- package/README.md +0 -3
- package/package.json +1 -1
- package/src/generator.js +23 -0
- package/src/langs/common/combinator.js +2 -0
- package/src/langs/python/combinator.js +39 -7
- package/src/langs/python2/combinator.js +32 -0
- package/src/resolver/base.js +14 -4
- package/tests/expected/python2/complex/tea_python_tests/client.py +12 -0
- package/tests/expected/python2/complex/tea_python_tests/models.py +66 -1
- package/tests/expected/python2/typedef/setup.py +85 -0
- package/tests/expected/python2/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/python2/typedef/tea_python_tests/client.py +38 -0
- package/tests/expected/python2/typedef/tea_python_tests/models.py +35 -0
- package/tests/expected/python3/complex/tea_python_tests/client.py +12 -0
- package/tests/expected/python3/complex/tea_python_tests/models.py +70 -0
- package/tests/expected/python3/typedef/setup.py +77 -0
- package/tests/expected/python3/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/python3/typedef/tea_python_tests/client.py +72 -0
- package/tests/expected/python3/typedef/tea_python_tests/models.py +39 -0
- package/tests/fixtures/complex/main.dara +13 -0
- package/tests/fixtures/typedef/.libraries.json +3 -0
- package/tests/fixtures/typedef/Darafile +61 -0
- package/tests/fixtures/typedef/libraries/alibabacloud-OSS-0.0.1/Darafile +40 -0
- package/tests/fixtures/typedef/libraries/alibabacloud-OSS-0.0.1/oss.dara +6 -0
- package/tests/fixtures/typedef/main.dara +38 -0
- package/tests/python2.tests.js +42 -0
- package/tests/python3.tests.js +42 -0
- package/.travis.yml +0 -9
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [12.x, 14.x, 16.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v2
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
- run: npm install
|
|
29
|
+
- run: npm run ci
|
|
30
|
+
- run: npm run test
|
package/ChangeLog.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ChangeLog
|
|
2
2
|
|
|
3
|
+
## 1.2.11 - 2022-07-11
|
|
4
|
+
|
|
5
|
+
* Support complex list(`array-in-array`).
|
|
6
|
+
|
|
7
|
+
## 1.2.10 - 2022-05-31
|
|
8
|
+
|
|
9
|
+
* Fix import package for typedef.
|
|
10
|
+
|
|
11
|
+
## 1.2.9 - 2022-05-31
|
|
12
|
+
|
|
13
|
+
* Support Typedef.
|
|
14
|
+
|
|
3
15
|
## 1.2.8 - 2020-03-17
|
|
4
16
|
|
|
5
17
|
* Improve TeaModel to avoid serialization exception.
|
package/README-CN.md
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
# Darabonba Python 生成器
|
|
4
4
|
|
|
5
5
|
[![NPM version][npm-image]][npm-url]
|
|
6
|
-
[![build status][travis-image]][travis-url]
|
|
7
6
|
[![codecov][cov-image]][cov-url]
|
|
8
7
|
[![David deps][david-image]][david-url]
|
|
9
8
|
[![npm download][download-image]][download-url]
|
|
10
9
|
|
|
11
10
|
[npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
|
|
12
11
|
[npm-url]: https://npmjs.org/package/@darabonba/python-generator
|
|
13
|
-
[travis-image]: https://img.shields.io/travis/aliyun/darabonba-python-generator.svg?style=flat-square
|
|
14
|
-
[travis-url]: https://travis-ci.org/aliyun/darabonba-python-generator
|
|
15
12
|
[cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
|
|
16
13
|
[cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
|
|
17
14
|
[david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
|
package/README.md
CHANGED
|
@@ -3,15 +3,12 @@ English | [简体中文](/README-CN.md)
|
|
|
3
3
|
# Darabonba Python Generator
|
|
4
4
|
|
|
5
5
|
[![NPM version][npm-image]][npm-url]
|
|
6
|
-
[![build status][travis-image]][travis-url]
|
|
7
6
|
[![codecov][cov-image]][cov-url]
|
|
8
7
|
[![David deps][david-image]][david-url]
|
|
9
8
|
[![npm download][download-image]][download-url]
|
|
10
9
|
|
|
11
10
|
[npm-image]: https://img.shields.io/npm/v/@darabonba/python-generator.svg?style=flat-square
|
|
12
11
|
[npm-url]: https://npmjs.org/package/@darabonba/python-generator
|
|
13
|
-
[travis-image]: https://img.shields.io/travis/aliyun/darabonba-python-generator.svg?style=flat-square
|
|
14
|
-
[travis-url]: https://travis-ci.org/aliyun/darabonba-python-generator
|
|
15
12
|
[cov-image]: https://codecov.io/gh/aliyun/darabonba-python-generator/branch/master/graph/badge.svg
|
|
16
13
|
[cov-url]: https://codecov.io/gh/aliyun/darabonba-python-generator
|
|
17
14
|
[david-image]: https://img.shields.io/david/aliyun/darabonba-python-generator.svg?style=flat-square
|
package/package.json
CHANGED
package/src/generator.js
CHANGED
|
@@ -14,11 +14,18 @@ class Generator {
|
|
|
14
14
|
throw new Error('`option.outputDir` should not empty');
|
|
15
15
|
}
|
|
16
16
|
this.lang = lang;
|
|
17
|
+
this.typedef = meta[lang] && meta[lang].typedef ? meta[lang].typedef : {};
|
|
17
18
|
this.initConfig(meta);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
visit(ast) {
|
|
21
22
|
this.imports = this.resolveImports(ast);
|
|
23
|
+
this.imports.typedef = this.typedef;
|
|
24
|
+
Object.keys(this.typedef).forEach((def) => {
|
|
25
|
+
if (this.typedef[def].package && !this.imports.requirePackage.includes(this.typedef[def].package)) {
|
|
26
|
+
this.imports.requirePackage.push(this.typedef[def].package);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
22
29
|
const objects = [];
|
|
23
30
|
|
|
24
31
|
// combine client code
|
|
@@ -120,6 +127,7 @@ class Generator {
|
|
|
120
127
|
let thirdPackageModel = {};
|
|
121
128
|
let thirdPackageClient = {};
|
|
122
129
|
let thirdPackageClientAlias = {};
|
|
130
|
+
let importsTypedef = {};
|
|
123
131
|
|
|
124
132
|
if (imports.length > 0) {
|
|
125
133
|
const lockPath = path.join(this.config.pkgDir, '.libraries.json');
|
|
@@ -158,6 +166,20 @@ class Generator {
|
|
|
158
166
|
modelDir = daraMeta[this.lang].modelDirName
|
|
159
167
|
? daraMeta[this.lang].modelDirName
|
|
160
168
|
: this.config.model.dir;
|
|
169
|
+
if (daraMeta[this.lang].typedef) {
|
|
170
|
+
importsTypedef[aliasId] = {};
|
|
171
|
+
const moduleTypedef = daraMeta[this.lang].typedef;
|
|
172
|
+
Object.keys(moduleTypedef || {}).forEach((types) => {
|
|
173
|
+
if (!importsTypedef[aliasId][types]) {
|
|
174
|
+
importsTypedef[aliasId][types] = {};
|
|
175
|
+
}
|
|
176
|
+
importsTypedef[aliasId][types].import = moduleTypedef[types].import;
|
|
177
|
+
importsTypedef[aliasId][types].type = moduleTypedef[types].type;
|
|
178
|
+
if (moduleTypedef[types].package && !requirePackage.includes(moduleTypedef[types].package)) {
|
|
179
|
+
requirePackage.push(moduleTypedef[types].package);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
161
183
|
} else {
|
|
162
184
|
packageName = daraMeta.name;
|
|
163
185
|
clientName = this.config.clientName;
|
|
@@ -197,6 +219,7 @@ class Generator {
|
|
|
197
219
|
thirdPackageClient,
|
|
198
220
|
thirdPackageClientAlias,
|
|
199
221
|
thirdPackageModel,
|
|
222
|
+
importsTypedef,
|
|
200
223
|
};
|
|
201
224
|
}
|
|
202
225
|
}
|
|
@@ -36,6 +36,8 @@ class BaseCombinator {
|
|
|
36
36
|
this.thirdPackageClient = imports.thirdPackageClient;
|
|
37
37
|
this.thirdPackageClientAlias = imports.thirdPackageClientAlias;
|
|
38
38
|
this.thirdPackageModel = imports.thirdPackageModel;
|
|
39
|
+
this.typedef = imports.typedef;
|
|
40
|
+
this.importsTypedef = imports.importsTypedef;
|
|
39
41
|
|
|
40
42
|
_config(this.config);
|
|
41
43
|
}
|
|
@@ -202,6 +202,38 @@ class Combinator extends CombinatorBase {
|
|
|
202
202
|
return resultName;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
addTypedefInclude(typeName) {
|
|
206
|
+
let accessPath = typeName.split('.');
|
|
207
|
+
let importName = '';
|
|
208
|
+
let fromName = '';
|
|
209
|
+
let typedefModule = {};
|
|
210
|
+
if (accessPath.length === 2) {
|
|
211
|
+
if (this.importsTypedef[accessPath[0]] && this.importsTypedef[accessPath[0]][accessPath[1]]) {
|
|
212
|
+
typedefModule = this.importsTypedef[accessPath[0]][accessPath[1]];
|
|
213
|
+
}
|
|
214
|
+
} else if (accessPath.length === 1 && this.typedef[accessPath[0]]) {
|
|
215
|
+
typedefModule = this.typedef[accessPath[0]];
|
|
216
|
+
}
|
|
217
|
+
if (typedefModule.import || typedefModule.package) {
|
|
218
|
+
if (typedefModule.import) {
|
|
219
|
+
fromName = typedefModule.import;
|
|
220
|
+
}
|
|
221
|
+
if (typedefModule.type) {
|
|
222
|
+
importName = typedefModule.type;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let existResult = this.includeList.some(item => item.import === importName && item.from === fromName);
|
|
227
|
+
if (!existResult) {
|
|
228
|
+
this.includeList.push({
|
|
229
|
+
'from': fromName,
|
|
230
|
+
'import': importName,
|
|
231
|
+
'alias': '',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return typedefModule.type || typeName;
|
|
235
|
+
}
|
|
236
|
+
|
|
205
237
|
simpleImport(imp, from = null) {
|
|
206
238
|
let existResult = this.includeList.some(item => {
|
|
207
239
|
if (item.import === imp && item.from === from) {
|
|
@@ -213,7 +245,7 @@ class Combinator extends CombinatorBase {
|
|
|
213
245
|
from: from,
|
|
214
246
|
import: imp
|
|
215
247
|
});
|
|
216
|
-
}
|
|
248
|
+
}
|
|
217
249
|
}
|
|
218
250
|
|
|
219
251
|
combine(objectArr = []) {
|
|
@@ -402,7 +434,7 @@ class Combinator extends CombinatorBase {
|
|
|
402
434
|
} else if (obj.objectType === 'model' || !this.config.typeMap[obj] && !this.thirdPackageNamespace[obj]) {
|
|
403
435
|
if (_type(obj) === target) {
|
|
404
436
|
return true;
|
|
405
|
-
}
|
|
437
|
+
}
|
|
406
438
|
}
|
|
407
439
|
return false;
|
|
408
440
|
}
|
|
@@ -916,7 +948,7 @@ class Combinator extends CombinatorBase {
|
|
|
916
948
|
this.levelDown();
|
|
917
949
|
}
|
|
918
950
|
|
|
919
|
-
emitNotes(emitter, notes) {}
|
|
951
|
+
emitNotes(emitter, notes) { }
|
|
920
952
|
|
|
921
953
|
emitConstruct(emitter, construct, props, isModule = false) {
|
|
922
954
|
if (construct.params.length + props.length > 0) {
|
|
@@ -950,7 +982,7 @@ class Combinator extends CombinatorBase {
|
|
|
950
982
|
} else {
|
|
951
983
|
emitter.emitln(`${_name(prop.name)}: ${typeHints} = None,`, this.level);
|
|
952
984
|
}
|
|
953
|
-
|
|
985
|
+
|
|
954
986
|
}
|
|
955
987
|
});
|
|
956
988
|
}
|
|
@@ -1200,7 +1232,7 @@ class Combinator extends CombinatorBase {
|
|
|
1200
1232
|
let importList = this.includeList.filter(node => !node.from && node.import);
|
|
1201
1233
|
let aliasList = this.includeList.filter(node => node.from && node.alias);
|
|
1202
1234
|
let list = this.includeList.filter(node => node.from && !node.alias);
|
|
1203
|
-
|
|
1235
|
+
|
|
1204
1236
|
let from = {};
|
|
1205
1237
|
let fromList = [];
|
|
1206
1238
|
|
|
@@ -1489,7 +1521,7 @@ class Combinator extends CombinatorBase {
|
|
|
1489
1521
|
if (item instanceof AnnotationItem) {
|
|
1490
1522
|
if (item.mode === 'single') {
|
|
1491
1523
|
emit.emit(`# ${item.content}`, this.level);
|
|
1492
|
-
}
|
|
1524
|
+
}
|
|
1493
1525
|
tmp.push(emit.output);
|
|
1494
1526
|
return true;
|
|
1495
1527
|
}
|
|
@@ -1761,7 +1793,7 @@ class Combinator extends CombinatorBase {
|
|
|
1761
1793
|
const quote = this._adaptedQuotes(behavior.key, emitter);
|
|
1762
1794
|
emitter.emit(`${emit.output}[${quote}${behavior.key}${quote}] = `, this.level);
|
|
1763
1795
|
}
|
|
1764
|
-
|
|
1796
|
+
|
|
1765
1797
|
this.grammerValue(emitter, behavior.value);
|
|
1766
1798
|
emitter.emitln('');
|
|
1767
1799
|
}
|
|
@@ -198,6 +198,38 @@ class Combinator extends CombinatorBase {
|
|
|
198
198
|
return resultName;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
addTypedefInclude(typeName) {
|
|
202
|
+
let accessPath = typeName.split('.');
|
|
203
|
+
let importName = '';
|
|
204
|
+
let fromName = '';
|
|
205
|
+
let typedefModule = {};
|
|
206
|
+
if (accessPath.length === 2) {
|
|
207
|
+
if (this.importsTypedef[accessPath[0]] && this.importsTypedef[accessPath[0]][accessPath[1]]) {
|
|
208
|
+
typedefModule = this.importsTypedef[accessPath[0]][accessPath[1]];
|
|
209
|
+
}
|
|
210
|
+
} else if (accessPath.length === 1 && this.typedef[accessPath[0]]) {
|
|
211
|
+
typedefModule = this.typedef[accessPath[0]];
|
|
212
|
+
}
|
|
213
|
+
if (typedefModule.import || typedefModule.package) {
|
|
214
|
+
if (typedefModule.import) {
|
|
215
|
+
fromName = typedefModule.import;
|
|
216
|
+
}
|
|
217
|
+
if (typedefModule.type) {
|
|
218
|
+
importName = typedefModule.type;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let existResult = this.includeList.some(item => item.import === importName && item.from === fromName);
|
|
223
|
+
if (!existResult) {
|
|
224
|
+
this.includeList.push({
|
|
225
|
+
'from': fromName,
|
|
226
|
+
'import': importName,
|
|
227
|
+
'alias': '',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return typedefModule.type || typeName;
|
|
231
|
+
}
|
|
232
|
+
|
|
201
233
|
combine(objectArr = []) {
|
|
202
234
|
super.combine(objectArr);
|
|
203
235
|
this.config.dir = this.config.outputDir + '/' + this.config.package + '/';
|
package/src/resolver/base.js
CHANGED
|
@@ -153,7 +153,7 @@ class BaseResolver {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
resolveType(typeNode, sourceNode, prop) {
|
|
156
|
-
let typeInfo = {objectType: 'module'};
|
|
156
|
+
let typeInfo = { objectType: 'module' };
|
|
157
157
|
if (typeNode.idType) {
|
|
158
158
|
if (typeNode.idType === 'model') {
|
|
159
159
|
typeInfo['objectType'] = 'model';
|
|
@@ -162,6 +162,9 @@ class BaseResolver {
|
|
|
162
162
|
} else if (typeNode.idType === 'module') {
|
|
163
163
|
typeInfo['lexeme'] = this.combinator.addInclude(typeNode.lexeme);
|
|
164
164
|
return typeInfo;
|
|
165
|
+
} else if (typeNode.idType === 'typedef') {
|
|
166
|
+
typeInfo['lexeme'] = this.combinator.addTypedefInclude(typeNode.lexeme);
|
|
167
|
+
return typeInfo;
|
|
165
168
|
} else if (typeNode.idType === 'builtin_model') {
|
|
166
169
|
typeInfo['objectType'] = 'builtin_model';
|
|
167
170
|
return this.combinator.addInclude(typeNode.lexeme);
|
|
@@ -169,7 +172,7 @@ class BaseResolver {
|
|
|
169
172
|
debug.stack(typeNode, sourceNode);
|
|
170
173
|
} else if (typeNode.type) {
|
|
171
174
|
if (typeNode.type === 'fieldType') {
|
|
172
|
-
return this.resolveType(typeNode.fieldType, typeNode);
|
|
175
|
+
return this.resolveType(typeNode.fieldType, typeNode, prop);
|
|
173
176
|
} else if (typeNode.type === 'modelBody') {
|
|
174
177
|
// is sub model
|
|
175
178
|
typeInfo['objectType'] = 'model';
|
|
@@ -213,6 +216,13 @@ class BaseResolver {
|
|
|
213
216
|
typeInfo['objectType'] = 'model';
|
|
214
217
|
typeInfo['lexeme'] = this.combinator.addModelInclude(tmp.join('.'));
|
|
215
218
|
return typeInfo;
|
|
219
|
+
} else if (typeNode.type === 'moduleTypedef') {
|
|
220
|
+
let tmp = [];
|
|
221
|
+
typeNode.path.forEach(item => {
|
|
222
|
+
tmp.push(item.lexeme);
|
|
223
|
+
});
|
|
224
|
+
typeInfo['lexeme'] = this.combinator.addTypedefInclude(tmp.join('.'));
|
|
225
|
+
return typeInfo;
|
|
216
226
|
} else if (typeNode.type === 'subModel') {
|
|
217
227
|
let tmp = [];
|
|
218
228
|
typeNode.path.forEach(item => {
|
|
@@ -229,14 +239,14 @@ class BaseResolver {
|
|
|
229
239
|
let itemType;
|
|
230
240
|
if (sourceNode.fieldItemType.type === 'modelBody') {
|
|
231
241
|
typeInfo['objectType'] = 'model';
|
|
232
|
-
typeInfo['lexeme'] = this.combinator.addModelInclude(sourceNode.itemType);
|
|
242
|
+
typeInfo['lexeme'] = this.combinator.addModelInclude(sourceNode.itemType ? sourceNode.itemType : prop);
|
|
233
243
|
itemType = typeInfo;
|
|
234
244
|
} else if (sourceNode.fieldItemType.idType === 'model') {
|
|
235
245
|
typeInfo['objectType'] = 'model';
|
|
236
246
|
typeInfo['lexeme'] = this.combinator.addModelInclude(sourceNode.fieldItemType.lexeme);
|
|
237
247
|
itemType = typeInfo;
|
|
238
248
|
} else {
|
|
239
|
-
itemType = this.resolveType(sourceNode.fieldItemType, sourceNode);
|
|
249
|
+
itemType = this.resolveType(sourceNode.fieldItemType, sourceNode, sourceNode.itemType ? sourceNode.itemType : prop);
|
|
240
250
|
}
|
|
241
251
|
const arrayType = {
|
|
242
252
|
lexeme: 'array',
|
|
@@ -163,6 +163,18 @@ class Client(SourceClient):
|
|
|
163
163
|
'1'
|
|
164
164
|
]
|
|
165
165
|
|
|
166
|
+
@staticmethod
|
|
167
|
+
def array_2():
|
|
168
|
+
temp = source_models.Config()
|
|
169
|
+
any_arr = [
|
|
170
|
+
temp
|
|
171
|
+
]
|
|
172
|
+
return [
|
|
173
|
+
[
|
|
174
|
+
any_arr
|
|
175
|
+
]
|
|
176
|
+
]
|
|
177
|
+
|
|
166
178
|
def template_string(self):
|
|
167
179
|
return '/%s' % TeaConverter.to_unicode(self._protocol)
|
|
168
180
|
|
|
@@ -89,8 +89,38 @@ class ComplexRequestPart(TeaModel):
|
|
|
89
89
|
return self
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
class ComplexRequestComplexList(TeaModel):
|
|
93
|
+
def __init__(self, name=None, code=None):
|
|
94
|
+
self.name = name # type: str
|
|
95
|
+
self.code = code # type: int
|
|
96
|
+
|
|
97
|
+
def validate(self):
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
def to_map(self):
|
|
101
|
+
_map = super(ComplexRequestComplexList, self).to_map()
|
|
102
|
+
if _map is not None:
|
|
103
|
+
return _map
|
|
104
|
+
|
|
105
|
+
result = dict()
|
|
106
|
+
if self.name is not None:
|
|
107
|
+
result['Name'] = self.name
|
|
108
|
+
if self.code is not None:
|
|
109
|
+
result['Code'] = self.code
|
|
110
|
+
return result
|
|
111
|
+
|
|
112
|
+
def from_map(self, m=None):
|
|
113
|
+
m = m or dict()
|
|
114
|
+
if m.get('Name') is not None:
|
|
115
|
+
self.name = m.get('Name')
|
|
116
|
+
if m.get('Code') is not None:
|
|
117
|
+
self.code = m.get('Code')
|
|
118
|
+
return self
|
|
119
|
+
|
|
120
|
+
|
|
92
121
|
class ComplexRequest(TeaModel):
|
|
93
|
-
def __init__(self, access_key=None, body=None, strs=None, header=None, num=None, configs=None, part=None
|
|
122
|
+
def __init__(self, access_key=None, body=None, strs=None, header=None, num=None, configs=None, part=None,
|
|
123
|
+
complex_list=None, complex_list_1=None):
|
|
94
124
|
self.access_key = access_key # type: str
|
|
95
125
|
# Body
|
|
96
126
|
self.body = body # type: READABLE
|
|
@@ -102,6 +132,8 @@ class ComplexRequest(TeaModel):
|
|
|
102
132
|
self.configs = configs # type: ComplexRequestConfigs
|
|
103
133
|
# Part
|
|
104
134
|
self.part = part # type: list[ComplexRequestPart]
|
|
135
|
+
self.complex_list = complex_list # type: list[list[list[ComplexRequestComplexList]]]
|
|
136
|
+
self.complex_list_1 = complex_list_1 # type: list[list[dict[str, str]]]
|
|
105
137
|
|
|
106
138
|
def validate(self):
|
|
107
139
|
self.validate_required(self.access_key, 'access_key')
|
|
@@ -118,6 +150,14 @@ class ComplexRequest(TeaModel):
|
|
|
118
150
|
for k in self.part:
|
|
119
151
|
if k:
|
|
120
152
|
k.validate()
|
|
153
|
+
self.validate_required(self.complex_list, 'complex_list')
|
|
154
|
+
if self.complex_list:
|
|
155
|
+
for k in self.complex_list:
|
|
156
|
+
for k1 in k:
|
|
157
|
+
for k2 in k1:
|
|
158
|
+
if k2:
|
|
159
|
+
k2.validate()
|
|
160
|
+
self.validate_required(self.complex_list_1, 'complex_list_1')
|
|
121
161
|
|
|
122
162
|
def to_map(self):
|
|
123
163
|
_map = super(ComplexRequest, self).to_map()
|
|
@@ -141,6 +181,18 @@ class ComplexRequest(TeaModel):
|
|
|
141
181
|
if self.part is not None:
|
|
142
182
|
for k in self.part:
|
|
143
183
|
result['Part'].append(k.to_map() if k else None)
|
|
184
|
+
result['complexList'] = []
|
|
185
|
+
if self.complex_list is not None:
|
|
186
|
+
for k in self.complex_list:
|
|
187
|
+
l1 = []
|
|
188
|
+
for k1 in k:
|
|
189
|
+
l2 = []
|
|
190
|
+
for k2 in k1:
|
|
191
|
+
l2.append(k2.to_map() if k2 else None)
|
|
192
|
+
l1.append(l2)
|
|
193
|
+
result['complexList'].append(l1)
|
|
194
|
+
if self.complex_list_1 is not None:
|
|
195
|
+
result['complexList1'] = self.complex_list_1
|
|
144
196
|
return result
|
|
145
197
|
|
|
146
198
|
def from_map(self, m=None):
|
|
@@ -164,6 +216,19 @@ class ComplexRequest(TeaModel):
|
|
|
164
216
|
for k in m.get('Part'):
|
|
165
217
|
temp_model = ComplexRequestPart()
|
|
166
218
|
self.part.append(temp_model.from_map(k))
|
|
219
|
+
self.complex_list = []
|
|
220
|
+
if m.get('complexList') is not None:
|
|
221
|
+
for k in m.get('complexList'):
|
|
222
|
+
l1 = []
|
|
223
|
+
for k1 in k:
|
|
224
|
+
l2 = []
|
|
225
|
+
for k2 in k1:
|
|
226
|
+
temp_model = ComplexRequestComplexList()
|
|
227
|
+
l2.append(temp_model.from_map(k2))
|
|
228
|
+
l1.append(l2)
|
|
229
|
+
self.complex_list.append(l1)
|
|
230
|
+
if m.get('complexList1') is not None:
|
|
231
|
+
self.complex_list_1 = m.get('complexList1')
|
|
167
232
|
return self
|
|
168
233
|
|
|
169
234
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
or more contributor license agreements. See the NOTICE file
|
|
5
|
+
distributed with this work for additional information
|
|
6
|
+
regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
to you under the Apache License, Version 2.0 (the
|
|
8
|
+
"License"); you may not use this file except in compliance
|
|
9
|
+
with the License. You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing,
|
|
14
|
+
software distributed under the License is distributed on an
|
|
15
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, either express or implied. See the License for the
|
|
17
|
+
specific language governing permissions and limitations
|
|
18
|
+
under the License.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
from setuptools import setup, find_packages
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
setup module for tea_python_tests.
|
|
27
|
+
|
|
28
|
+
Created on 28/05/2022
|
|
29
|
+
|
|
30
|
+
@author: Alibaba
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
PACKAGE = "tea_python_tests"
|
|
34
|
+
NAME = "tea_python_tests" or "alibabacloud-package"
|
|
35
|
+
DESCRIPTION = "Generate setup.py"
|
|
36
|
+
AUTHOR = "Alibaba"
|
|
37
|
+
AUTHOR_EMAIL = "sdk-team@alibabacloud.com"
|
|
38
|
+
URL = "https://github.com/"
|
|
39
|
+
VERSION = __import__(PACKAGE).__version__
|
|
40
|
+
REQUIRES = [
|
|
41
|
+
"requests>=2.21.0, <3.0.0",
|
|
42
|
+
"alibabacloud-tea-py2>=0.0.4, <1.0.0"
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
LONG_DESCRIPTION = ''
|
|
46
|
+
|
|
47
|
+
if os.path.exists('./README.md'):
|
|
48
|
+
if sys.version_info.major == 2:
|
|
49
|
+
with open("README.md") as fp:
|
|
50
|
+
LONG_DESCRIPTION = fp.read()
|
|
51
|
+
else:
|
|
52
|
+
with open("README.md", encoding="utf-8") as fp:
|
|
53
|
+
LONG_DESCRIPTION = fp.read()
|
|
54
|
+
|
|
55
|
+
setup(
|
|
56
|
+
name=NAME,
|
|
57
|
+
version=VERSION,
|
|
58
|
+
description=DESCRIPTION,
|
|
59
|
+
long_description=LONG_DESCRIPTION,
|
|
60
|
+
long_description_content_type='text/markdown',
|
|
61
|
+
author=AUTHOR,
|
|
62
|
+
author_email=AUTHOR_EMAIL,
|
|
63
|
+
license="Apache License 2.0",
|
|
64
|
+
url=URL,
|
|
65
|
+
keywords=["tea","python","tests"],
|
|
66
|
+
packages=find_packages(exclude=["tests*"]),
|
|
67
|
+
include_package_data=True,
|
|
68
|
+
platforms="any",
|
|
69
|
+
install_requires=REQUIRES,
|
|
70
|
+
classifiers=(
|
|
71
|
+
"Development Status :: 4 - Beta",
|
|
72
|
+
"Intended Audience :: Developers",
|
|
73
|
+
"License :: OSI Approved :: Apache Software License",
|
|
74
|
+
"Programming Language :: Python",
|
|
75
|
+
"Programming Language :: Python :: 2",
|
|
76
|
+
"Programming Language :: Python :: 2.7",
|
|
77
|
+
"Programming Language :: Python :: 3",
|
|
78
|
+
"Programming Language :: Python :: 3.4",
|
|
79
|
+
"Programming Language :: Python :: 3.5",
|
|
80
|
+
"Programming Language :: Python :: 3.6",
|
|
81
|
+
"Programming Language :: Python :: 3.7",
|
|
82
|
+
"Programming Language :: Python :: 3.8",
|
|
83
|
+
"Topic :: Software Development"
|
|
84
|
+
)
|
|
85
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from __future__ import unicode_literals
|
|
4
|
+
|
|
5
|
+
from requests import Request
|
|
6
|
+
from Tea.model import TeaModel
|
|
7
|
+
from Source.source_client import SourceClient
|
|
8
|
+
|
|
9
|
+
from tea_python_tests import models as main_models
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Client(object):
|
|
13
|
+
_vid = None # type: Request
|
|
14
|
+
_model = None # type: TeaModel
|
|
15
|
+
|
|
16
|
+
def __init__(self, request, model):
|
|
17
|
+
self._vid = request
|
|
18
|
+
self._model = model
|
|
19
|
+
|
|
20
|
+
def main(self, test_1, test_2):
|
|
21
|
+
oss = SourceClient(test_1)
|
|
22
|
+
m = main_models.M(
|
|
23
|
+
a=test_1,
|
|
24
|
+
b=test_2
|
|
25
|
+
)
|
|
26
|
+
self._vid = test_1
|
|
27
|
+
self._model = test_2
|
|
28
|
+
|
|
29
|
+
def test_http_request(self, req):
|
|
30
|
+
return self.test_http_request_with('test', req)
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def test_http_request_with(method, req):
|
|
34
|
+
raise Exception('Un-implemented')
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def test_http_header(method, headers):
|
|
38
|
+
raise Exception('Un-implemented')
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from Tea.model import TeaModel
|
|
4
|
+
from requests import Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class M(TeaModel):
|
|
8
|
+
def __init__(self, a=None, b=None):
|
|
9
|
+
self.a = a # type: Request
|
|
10
|
+
self.b = b # type: TeaModel
|
|
11
|
+
|
|
12
|
+
def validate(self):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
def to_map(self):
|
|
16
|
+
_map = super(M, self).to_map()
|
|
17
|
+
if _map is not None:
|
|
18
|
+
return _map
|
|
19
|
+
|
|
20
|
+
result = dict()
|
|
21
|
+
if self.a is not None:
|
|
22
|
+
result['a'] = self.a
|
|
23
|
+
if self.b is not None:
|
|
24
|
+
result['b'] = self.b
|
|
25
|
+
return result
|
|
26
|
+
|
|
27
|
+
def from_map(self, m=None):
|
|
28
|
+
m = m or dict()
|
|
29
|
+
if m.get('a') is not None:
|
|
30
|
+
self.a = m.get('a')
|
|
31
|
+
if m.get('b') is not None:
|
|
32
|
+
self.b = m.get('b')
|
|
33
|
+
return self
|
|
34
|
+
|
|
35
|
+
|
|
@@ -337,6 +337,18 @@ class Client(SourceClient):
|
|
|
337
337
|
'1'
|
|
338
338
|
]
|
|
339
339
|
|
|
340
|
+
@staticmethod
|
|
341
|
+
def array_2() -> List[List[Any]]:
|
|
342
|
+
temp = source_models.Config()
|
|
343
|
+
any_arr = [
|
|
344
|
+
temp
|
|
345
|
+
]
|
|
346
|
+
return [
|
|
347
|
+
[
|
|
348
|
+
any_arr
|
|
349
|
+
]
|
|
350
|
+
]
|
|
351
|
+
|
|
340
352
|
def template_string(self) -> str:
|
|
341
353
|
return f'/{self._protocol}'
|
|
342
354
|
|
|
@@ -101,6 +101,39 @@ class ComplexRequestPart(TeaModel):
|
|
|
101
101
|
return self
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
class ComplexRequestComplexList(TeaModel):
|
|
105
|
+
def __init__(
|
|
106
|
+
self,
|
|
107
|
+
name: str = None,
|
|
108
|
+
code: int = None,
|
|
109
|
+
):
|
|
110
|
+
self.name = name
|
|
111
|
+
self.code = code
|
|
112
|
+
|
|
113
|
+
def validate(self):
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
def to_map(self):
|
|
117
|
+
_map = super().to_map()
|
|
118
|
+
if _map is not None:
|
|
119
|
+
return _map
|
|
120
|
+
|
|
121
|
+
result = dict()
|
|
122
|
+
if self.name is not None:
|
|
123
|
+
result['Name'] = self.name
|
|
124
|
+
if self.code is not None:
|
|
125
|
+
result['Code'] = self.code
|
|
126
|
+
return result
|
|
127
|
+
|
|
128
|
+
def from_map(self, m: dict = None):
|
|
129
|
+
m = m or dict()
|
|
130
|
+
if m.get('Name') is not None:
|
|
131
|
+
self.name = m.get('Name')
|
|
132
|
+
if m.get('Code') is not None:
|
|
133
|
+
self.code = m.get('Code')
|
|
134
|
+
return self
|
|
135
|
+
|
|
136
|
+
|
|
104
137
|
class ComplexRequest(TeaModel):
|
|
105
138
|
def __init__(
|
|
106
139
|
self,
|
|
@@ -111,6 +144,8 @@ class ComplexRequest(TeaModel):
|
|
|
111
144
|
num: int = None,
|
|
112
145
|
configs: ComplexRequestConfigs = None,
|
|
113
146
|
part: List[ComplexRequestPart] = None,
|
|
147
|
+
complex_list: List[List[List[ComplexRequestComplexList]]] = None,
|
|
148
|
+
complex_list_1: List[List[Dict[str, str]]] = None,
|
|
114
149
|
):
|
|
115
150
|
self.access_key = access_key
|
|
116
151
|
# Body
|
|
@@ -123,6 +158,8 @@ class ComplexRequest(TeaModel):
|
|
|
123
158
|
self.configs = configs
|
|
124
159
|
# Part
|
|
125
160
|
self.part = part
|
|
161
|
+
self.complex_list = complex_list
|
|
162
|
+
self.complex_list_1 = complex_list_1
|
|
126
163
|
|
|
127
164
|
def validate(self):
|
|
128
165
|
self.validate_required(self.access_key, 'access_key')
|
|
@@ -139,6 +176,14 @@ class ComplexRequest(TeaModel):
|
|
|
139
176
|
for k in self.part:
|
|
140
177
|
if k:
|
|
141
178
|
k.validate()
|
|
179
|
+
self.validate_required(self.complex_list, 'complex_list')
|
|
180
|
+
if self.complex_list:
|
|
181
|
+
for k in self.complex_list:
|
|
182
|
+
for k1 in k:
|
|
183
|
+
for k2 in k1:
|
|
184
|
+
if k2:
|
|
185
|
+
k2.validate()
|
|
186
|
+
self.validate_required(self.complex_list_1, 'complex_list_1')
|
|
142
187
|
|
|
143
188
|
def to_map(self):
|
|
144
189
|
_map = super().to_map()
|
|
@@ -162,6 +207,18 @@ class ComplexRequest(TeaModel):
|
|
|
162
207
|
if self.part is not None:
|
|
163
208
|
for k in self.part:
|
|
164
209
|
result['Part'].append(k.to_map() if k else None)
|
|
210
|
+
result['complexList'] = []
|
|
211
|
+
if self.complex_list is not None:
|
|
212
|
+
for k in self.complex_list:
|
|
213
|
+
l1 = []
|
|
214
|
+
for k1 in k:
|
|
215
|
+
l2 = []
|
|
216
|
+
for k2 in k1:
|
|
217
|
+
l2.append(k2.to_map() if k2 else None)
|
|
218
|
+
l1.append(l2)
|
|
219
|
+
result['complexList'].append(l1)
|
|
220
|
+
if self.complex_list_1 is not None:
|
|
221
|
+
result['complexList1'] = self.complex_list_1
|
|
165
222
|
return result
|
|
166
223
|
|
|
167
224
|
def from_map(self, m: dict = None):
|
|
@@ -185,6 +242,19 @@ class ComplexRequest(TeaModel):
|
|
|
185
242
|
for k in m.get('Part'):
|
|
186
243
|
temp_model = ComplexRequestPart()
|
|
187
244
|
self.part.append(temp_model.from_map(k))
|
|
245
|
+
self.complex_list = []
|
|
246
|
+
if m.get('complexList') is not None:
|
|
247
|
+
for k in m.get('complexList'):
|
|
248
|
+
l1 = []
|
|
249
|
+
for k1 in k:
|
|
250
|
+
l2 = []
|
|
251
|
+
for k2 in k1:
|
|
252
|
+
temp_model = ComplexRequestComplexList()
|
|
253
|
+
l2.append(temp_model.from_map(k2))
|
|
254
|
+
l1.append(l2)
|
|
255
|
+
self.complex_list.append(l1)
|
|
256
|
+
if m.get('complexList1') is not None:
|
|
257
|
+
self.complex_list_1 = m.get('complexList1')
|
|
188
258
|
return self
|
|
189
259
|
|
|
190
260
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
or more contributor license agreements. See the NOTICE file
|
|
5
|
+
distributed with this work for additional information
|
|
6
|
+
regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
to you under the Apache License, Version 2.0 (the
|
|
8
|
+
"License"); you may not use this file except in compliance
|
|
9
|
+
with the License. You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing,
|
|
14
|
+
software distributed under the License is distributed on an
|
|
15
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, either express or implied. See the License for the
|
|
17
|
+
specific language governing permissions and limitations
|
|
18
|
+
under the License.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
from setuptools import setup, find_packages
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
setup module for tea_python_tests.
|
|
26
|
+
|
|
27
|
+
Created on 28/05/2022
|
|
28
|
+
|
|
29
|
+
@author: Alibaba
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
PACKAGE = "tea_python_tests"
|
|
33
|
+
NAME = "tea_python_tests" or "alibabacloud-package"
|
|
34
|
+
DESCRIPTION = "Generate setup.py"
|
|
35
|
+
AUTHOR = "Alibaba"
|
|
36
|
+
AUTHOR_EMAIL = "sdk-team@alibabacloud.com"
|
|
37
|
+
URL = "https://github.com/"
|
|
38
|
+
VERSION = __import__(PACKAGE).__version__
|
|
39
|
+
REQUIRES = [
|
|
40
|
+
"requests>=2.21.0, <3.0.0",
|
|
41
|
+
"alibabacloud-tea>=0.2.9, <1.0.0"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
LONG_DESCRIPTION = ''
|
|
45
|
+
if os.path.exists('./README.md'):
|
|
46
|
+
with open("README.md", encoding='utf-8') as fp:
|
|
47
|
+
LONG_DESCRIPTION = fp.read()
|
|
48
|
+
|
|
49
|
+
setup(
|
|
50
|
+
name=NAME,
|
|
51
|
+
version=VERSION,
|
|
52
|
+
description=DESCRIPTION,
|
|
53
|
+
long_description=LONG_DESCRIPTION,
|
|
54
|
+
long_description_content_type='text/markdown',
|
|
55
|
+
author=AUTHOR,
|
|
56
|
+
author_email=AUTHOR_EMAIL,
|
|
57
|
+
license="Apache License 2.0",
|
|
58
|
+
url=URL,
|
|
59
|
+
keywords=["tea","python","tests"],
|
|
60
|
+
packages=find_packages(exclude=["tests*"]),
|
|
61
|
+
include_package_data=True,
|
|
62
|
+
platforms="any",
|
|
63
|
+
install_requires=REQUIRES,
|
|
64
|
+
python_requires=">=3.6",
|
|
65
|
+
classifiers=(
|
|
66
|
+
"Development Status :: 4 - Beta",
|
|
67
|
+
"Intended Audience :: Developers",
|
|
68
|
+
"License :: OSI Approved :: Apache Software License",
|
|
69
|
+
"Programming Language :: Python",
|
|
70
|
+
"Programming Language :: Python :: 3",
|
|
71
|
+
"Programming Language :: Python :: 3.6",
|
|
72
|
+
'Programming Language :: Python :: 3.7',
|
|
73
|
+
'Programming Language :: Python :: 3.8',
|
|
74
|
+
'Programming Language :: Python :: 3.9',
|
|
75
|
+
"Topic :: Software Development"
|
|
76
|
+
)
|
|
77
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from requests import Request, Response
|
|
4
|
+
from Tea.model import TeaModel
|
|
5
|
+
from Source.source_client import SourceClient
|
|
6
|
+
|
|
7
|
+
from tea_python_tests import models as main_models
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Client:
|
|
11
|
+
_vid: Request = None
|
|
12
|
+
_model: TeaModel = None
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
request: Request,
|
|
17
|
+
model: TeaModel,
|
|
18
|
+
):
|
|
19
|
+
self._vid = request
|
|
20
|
+
self._model = model
|
|
21
|
+
|
|
22
|
+
def main(
|
|
23
|
+
self,
|
|
24
|
+
test_1: Request,
|
|
25
|
+
test_2: TeaModel,
|
|
26
|
+
) -> None:
|
|
27
|
+
oss = SourceClient(test_1)
|
|
28
|
+
m = main_models.M(
|
|
29
|
+
a=test_1,
|
|
30
|
+
b=test_2
|
|
31
|
+
)
|
|
32
|
+
self._vid = test_1
|
|
33
|
+
self._model = test_2
|
|
34
|
+
|
|
35
|
+
async def main_async(
|
|
36
|
+
self,
|
|
37
|
+
test_1: Request,
|
|
38
|
+
test_2: TeaModel,
|
|
39
|
+
) -> None:
|
|
40
|
+
oss = SourceClient(test_1)
|
|
41
|
+
m = main_models.M(
|
|
42
|
+
a=test_1,
|
|
43
|
+
b=test_2
|
|
44
|
+
)
|
|
45
|
+
self._vid = test_1
|
|
46
|
+
self._model = test_2
|
|
47
|
+
|
|
48
|
+
def test_http_request(
|
|
49
|
+
self,
|
|
50
|
+
req: Request,
|
|
51
|
+
) -> Response:
|
|
52
|
+
return self.test_http_request_with('test', req)
|
|
53
|
+
|
|
54
|
+
async def test_http_request_async(
|
|
55
|
+
self,
|
|
56
|
+
req: Request,
|
|
57
|
+
) -> Response:
|
|
58
|
+
return self.test_http_request_with('test', req)
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def test_http_request_with(
|
|
62
|
+
method: str,
|
|
63
|
+
req: Request,
|
|
64
|
+
) -> Response:
|
|
65
|
+
raise Exception('Un-implemented')
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def test_http_header(
|
|
69
|
+
method: str,
|
|
70
|
+
headers: Dict[str, Any],
|
|
71
|
+
) -> Response:
|
|
72
|
+
raise Exception('Un-implemented')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from Tea.model import TeaModel
|
|
4
|
+
from requests import Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class M(TeaModel):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
a: Request = None,
|
|
11
|
+
b: TeaModel = None,
|
|
12
|
+
):
|
|
13
|
+
self.a = a
|
|
14
|
+
self.b = b
|
|
15
|
+
|
|
16
|
+
def validate(self):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
def to_map(self):
|
|
20
|
+
_map = super().to_map()
|
|
21
|
+
if _map is not None:
|
|
22
|
+
return _map
|
|
23
|
+
|
|
24
|
+
result = dict()
|
|
25
|
+
if self.a is not None:
|
|
26
|
+
result['a'] = self.a
|
|
27
|
+
if self.b is not None:
|
|
28
|
+
result['b'] = self.b
|
|
29
|
+
return result
|
|
30
|
+
|
|
31
|
+
def from_map(self, m: dict = None):
|
|
32
|
+
m = m or dict()
|
|
33
|
+
if m.get('a') is not None:
|
|
34
|
+
self.a = m.get('a')
|
|
35
|
+
if m.get('b') is not None:
|
|
36
|
+
self.b = m.get('b')
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
|
|
@@ -29,6 +29,13 @@ model ComplexRequest = {
|
|
|
29
29
|
partNumber?: string(description='PartNumber', name='PartNumber')
|
|
30
30
|
}
|
|
31
31
|
](description='Part', name='Part'),
|
|
32
|
+
complexList: [[[
|
|
33
|
+
{
|
|
34
|
+
name?: string(name='Name'),
|
|
35
|
+
code?: int32(name='Code'),
|
|
36
|
+
}
|
|
37
|
+
]]](name='complexList'),
|
|
38
|
+
complexList1: [[map[string]string]],
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
async function hello(request: object, strs: [ string ]): [ string ] {
|
|
@@ -138,6 +145,12 @@ static function array1(): [ string ] {
|
|
|
138
145
|
return ["1"];
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
static function array2(): [[ any ]] {
|
|
149
|
+
var temp = new Source.Config{};
|
|
150
|
+
var anyArr : [Source.Config] = [temp];
|
|
151
|
+
return [[anyArr]];
|
|
152
|
+
}
|
|
153
|
+
|
|
141
154
|
async function TemplateString(): string {
|
|
142
155
|
return `/${@protocol}`;
|
|
143
156
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scope": "darabonba",
|
|
3
|
+
"name": "main",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "./main.dara",
|
|
6
|
+
"libraries": {
|
|
7
|
+
"OSS": "alibabacloud:OSS:*"
|
|
8
|
+
},
|
|
9
|
+
"python": {
|
|
10
|
+
"package": "tea_python_tests",
|
|
11
|
+
"clientName": "client",
|
|
12
|
+
"typedef": {
|
|
13
|
+
"HttpResponse": {
|
|
14
|
+
"import": "requests",
|
|
15
|
+
"type": "Response",
|
|
16
|
+
"package": "requests:2.21.0"
|
|
17
|
+
},
|
|
18
|
+
"HttpHeader": {
|
|
19
|
+
"import": null,
|
|
20
|
+
"type": "Dict[str, Any]",
|
|
21
|
+
"package": null
|
|
22
|
+
},
|
|
23
|
+
"TeaModel": {
|
|
24
|
+
"import": "Tea.model",
|
|
25
|
+
"type": "TeaModel",
|
|
26
|
+
"package": "alibabacloud-tea:0.2.9"
|
|
27
|
+
},
|
|
28
|
+
"TeaException": {
|
|
29
|
+
"import": "Tea.exceptions",
|
|
30
|
+
"type": "TeaException",
|
|
31
|
+
"package": "alibabacloud-tea:0.2.9"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"python2": {
|
|
36
|
+
"package": "tea_python_tests",
|
|
37
|
+
"clientName": "client",
|
|
38
|
+
"typedef": {
|
|
39
|
+
"HttpResponse": {
|
|
40
|
+
"import": "requests",
|
|
41
|
+
"type": "Response",
|
|
42
|
+
"package": "requests:2.21.0"
|
|
43
|
+
},
|
|
44
|
+
"HttpHeader": {
|
|
45
|
+
"import": null,
|
|
46
|
+
"type": "Dict[str, Any]",
|
|
47
|
+
"package": null
|
|
48
|
+
},
|
|
49
|
+
"TeaModel": {
|
|
50
|
+
"import": "Tea.model",
|
|
51
|
+
"type": "TeaModel",
|
|
52
|
+
"package": "alibabacloud-tea-py2:0.0.4"
|
|
53
|
+
},
|
|
54
|
+
"TeaException": {
|
|
55
|
+
"import": "Tea.exceptions",
|
|
56
|
+
"type": "TeaException",
|
|
57
|
+
"package": "alibabacloud-tea-py2:0.0.4"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "OSS",
|
|
3
|
+
"main": "./oss.dara",
|
|
4
|
+
"libraries": {},
|
|
5
|
+
"releases": {
|
|
6
|
+
"go": "github.com/aliyun/darabonba-go-generator"
|
|
7
|
+
},
|
|
8
|
+
"python": {
|
|
9
|
+
"package": "Source",
|
|
10
|
+
"clientName": "source_client",
|
|
11
|
+
"typedef": {
|
|
12
|
+
"HttpRequest": {
|
|
13
|
+
"import": "requests",
|
|
14
|
+
"type": "Request",
|
|
15
|
+
"package": "requests:2.21.0"
|
|
16
|
+
},
|
|
17
|
+
"HttpHeader": {
|
|
18
|
+
"import": null,
|
|
19
|
+
"type": "Dict[str, Any]",
|
|
20
|
+
"package": null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"python2": {
|
|
25
|
+
"package": "Source",
|
|
26
|
+
"clientName": "source_client",
|
|
27
|
+
"typedef": {
|
|
28
|
+
"HttpRequest": {
|
|
29
|
+
"import": "requests",
|
|
30
|
+
"type": "Request",
|
|
31
|
+
"package": "requests:2.21.0"
|
|
32
|
+
},
|
|
33
|
+
"HttpHeader": {
|
|
34
|
+
"import": null,
|
|
35
|
+
"type": "Dict[str, Any]",
|
|
36
|
+
"package": null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import OSS
|
|
2
|
+
|
|
3
|
+
typedef HttpResponse;
|
|
4
|
+
typedef HttpHeader;
|
|
5
|
+
typedef TeaModel;
|
|
6
|
+
// useless
|
|
7
|
+
typedef TeaException;
|
|
8
|
+
|
|
9
|
+
type @vid=OSS.HttpRequest;
|
|
10
|
+
type @model=TeaModel;
|
|
11
|
+
|
|
12
|
+
init(request: OSS.HttpRequest, model: TeaModel){
|
|
13
|
+
@vid = request;
|
|
14
|
+
@model = model;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model M {
|
|
18
|
+
a?: OSS.HttpRequest,
|
|
19
|
+
b?: TeaModel
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function main(test1: OSS.HttpRequest, test2: TeaModel) : void {
|
|
23
|
+
var oss = new OSS(test1);
|
|
24
|
+
var m = new M {
|
|
25
|
+
a = test1,
|
|
26
|
+
b = test2
|
|
27
|
+
};
|
|
28
|
+
@vid = test1;
|
|
29
|
+
@model = test2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function testHttpRequest(req: OSS.HttpRequest): HttpResponse {
|
|
33
|
+
return testHttpRequestWith("test", req);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static function testHttpRequestWith(method: string, req: OSS.HttpRequest): HttpResponse
|
|
37
|
+
|
|
38
|
+
static function testHttpHeader(method: string, headers: HttpHeader): HttpResponse
|
package/tests/python2.tests.js
CHANGED
|
@@ -228,4 +228,46 @@ describe('Python Generator', function () {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
|
+
it('typedef should ok', function () {
|
|
232
|
+
check('typedef', [
|
|
233
|
+
'tea_python_tests/client.py',
|
|
234
|
+
'tea_python_tests/models.py'
|
|
235
|
+
],
|
|
236
|
+
{
|
|
237
|
+
python2: {
|
|
238
|
+
package: 'tea_python_tests',
|
|
239
|
+
clientName: 'client',
|
|
240
|
+
packageInfo: {
|
|
241
|
+
name: 'tea_python_tests',
|
|
242
|
+
desc: 'Generate setup.py',
|
|
243
|
+
github: 'https://github.com/',
|
|
244
|
+
author: 'Alibaba',
|
|
245
|
+
email: 'sdk-team@alibabacloud.com'
|
|
246
|
+
},
|
|
247
|
+
typedef: {
|
|
248
|
+
HttpResponse: {
|
|
249
|
+
import: 'requests',
|
|
250
|
+
type: 'Response',
|
|
251
|
+
package: 'requests:2.21.0'
|
|
252
|
+
},
|
|
253
|
+
HttpHeader: {
|
|
254
|
+
import: null,
|
|
255
|
+
type: 'Dict[str, Any]',
|
|
256
|
+
package: null
|
|
257
|
+
},
|
|
258
|
+
TeaModel: {
|
|
259
|
+
import: 'Tea.model',
|
|
260
|
+
type: 'TeaModel',
|
|
261
|
+
package: 'alibabacloud-tea-py2:0.0.4'
|
|
262
|
+
},
|
|
263
|
+
TeaException: {
|
|
264
|
+
import: 'Tea.exceptions',
|
|
265
|
+
type: 'TeaException',
|
|
266
|
+
package: 'alibabacloud-tea-py2:0.0.4'
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
});
|
|
272
|
+
});
|
|
231
273
|
});
|
package/tests/python3.tests.js
CHANGED
|
@@ -228,4 +228,46 @@ describe('Python Generator', function () {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
|
+
|
|
232
|
+
it('typedef should ok', function () {
|
|
233
|
+
check('typedef', [
|
|
234
|
+
'tea_python_tests/client.py',
|
|
235
|
+
'tea_python_tests/models.py'
|
|
236
|
+
],
|
|
237
|
+
{
|
|
238
|
+
python: {
|
|
239
|
+
package: 'tea_python_tests',
|
|
240
|
+
clientName: 'client',
|
|
241
|
+
packageInfo: {
|
|
242
|
+
name: 'tea_python_tests',
|
|
243
|
+
desc: 'Generate setup.py',
|
|
244
|
+
github: 'https://github.com/',
|
|
245
|
+
author: 'Alibaba',
|
|
246
|
+
email: 'sdk-team@alibabacloud.com'
|
|
247
|
+
},
|
|
248
|
+
typedef: {
|
|
249
|
+
HttpResponse: {
|
|
250
|
+
import: 'requests',
|
|
251
|
+
type: 'Response',
|
|
252
|
+
package: 'requests:2.21.0'
|
|
253
|
+
},
|
|
254
|
+
HttpHeader: {
|
|
255
|
+
import: null,
|
|
256
|
+
type: 'Dict[str, Any]',
|
|
257
|
+
package: null
|
|
258
|
+
},
|
|
259
|
+
TeaModel: {
|
|
260
|
+
import: 'Tea.model',
|
|
261
|
+
type: 'TeaModel',
|
|
262
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
263
|
+
},
|
|
264
|
+
TeaException: {
|
|
265
|
+
import: 'Tea.exceptions',
|
|
266
|
+
type: 'TeaException',
|
|
267
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
231
273
|
});
|