@autorest/python 6.0.0-rc.1 → 6.0.0
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/ChangeLog.md +19 -2
- package/autorest/codegen/models/paging_operation.py +15 -1
- package/autorest/codegen/serializers/builder_serializer.py +25 -2
- package/autorest/codegen/templates/serialization.py.jinja2 +3 -3
- package/autorest/codegen/templates/setup.py.jinja2 +1 -1
- package/autorest/preprocess/__init__.py +24 -4
- package/package.json +2 -2
package/ChangeLog.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 2022-06-24 - 6.0.0
|
|
4
|
+
|
|
5
|
+
| Library | Min Version |
|
|
6
|
+
| ----------------------------------------------------------------------- | ----------- |
|
|
7
|
+
| `@autorest/core` | `3.8.1` |
|
|
8
|
+
| `@autorest/modelerfour` | `4.23.5` |
|
|
9
|
+
| `azure-core` dep of generated code | `1.24.0` |
|
|
10
|
+
| `isodate` dep of generated code | `0.6.1` |
|
|
11
|
+
| `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
|
|
12
|
+
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
13
|
+
|
|
14
|
+
**Breaking Changes**
|
|
15
|
+
|
|
16
|
+
- Don't generate paging variables `maxpagesize` for DPG generations. Users should pass in `maxpagesize` to the `by_page` method of their
|
|
17
|
+
pager #1320
|
|
18
|
+
|
|
3
19
|
### 2022-06-17 - 6.0.0-rc.1
|
|
4
20
|
|
|
5
21
|
| Library | Min Version |
|
|
@@ -7,7 +23,8 @@
|
|
|
7
23
|
| `@autorest/core` | `3.8.1` |
|
|
8
24
|
| `@autorest/modelerfour` | `4.23.5` |
|
|
9
25
|
| `azure-core` dep of generated code | `1.24.0` |
|
|
10
|
-
| `
|
|
26
|
+
| `isodate` dep of generated code | `0.6.1` |
|
|
27
|
+
| `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
|
|
11
28
|
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
12
29
|
|
|
13
30
|
**Breaking Changes**
|
|
@@ -15,7 +32,7 @@
|
|
|
15
32
|
- Default to generating DPG SDKs with `--version-tolerant` now defaulting to `true`. For a list of flag default changes, please
|
|
16
33
|
see [here](https://github.com/Azure/autorest.python/issues/1186) #1304
|
|
17
34
|
- Only generate Python3 SDKs #1297
|
|
18
|
-
- Don't reformat initial query parameters into the next link #1297
|
|
35
|
+
- Don't reformat initial query parameters into the next link. However, we do append `api-version` parameters if they are not present in the next link #1297 #1309
|
|
19
36
|
- Don't generate operations with more than two body types. SDK authors need to implement this operation themselves #1300
|
|
20
37
|
|
|
21
38
|
**New Features**
|
|
@@ -140,7 +140,21 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
140
140
|
file_import.merge(
|
|
141
141
|
self.get_request_builder_import(self.next_request_builder, async_mode)
|
|
142
142
|
)
|
|
143
|
-
|
|
143
|
+
elif "api-version" in [
|
|
144
|
+
p.rest_api_name for p in self.code_model.client.parameters
|
|
145
|
+
]:
|
|
146
|
+
file_import.add_submodule_import(
|
|
147
|
+
"urllib.parse", "urlparse", ImportType.STDLIB
|
|
148
|
+
)
|
|
149
|
+
file_import.add_submodule_import(
|
|
150
|
+
"urllib.parse", "urljoin", ImportType.STDLIB
|
|
151
|
+
)
|
|
152
|
+
file_import.add_submodule_import(
|
|
153
|
+
"urllib.parse", "parse_qs", ImportType.STDLIB
|
|
154
|
+
)
|
|
155
|
+
file_import.add_submodule_import(
|
|
156
|
+
"azure.core.utils", "case_insensitive_dict", ImportType.AZURECORE
|
|
157
|
+
)
|
|
144
158
|
return file_import
|
|
145
159
|
|
|
146
160
|
|
|
@@ -1133,15 +1133,38 @@ class _PagingOperationSerializer(
|
|
|
1133
1133
|
template_url = "next_link"
|
|
1134
1134
|
|
|
1135
1135
|
request_builder = builder.next_request_builder or builder.request_builder
|
|
1136
|
-
if builder.next_request_builder
|
|
1136
|
+
if builder.next_request_builder:
|
|
1137
1137
|
return self._call_request_builder_helper(
|
|
1138
1138
|
builder,
|
|
1139
1139
|
request_builder,
|
|
1140
1140
|
template_url=template_url,
|
|
1141
1141
|
is_next_request=True,
|
|
1142
1142
|
)
|
|
1143
|
-
retval
|
|
1143
|
+
retval: List[str] = []
|
|
1144
|
+
query_str = ""
|
|
1145
|
+
next_link_str = "next_link"
|
|
1146
|
+
try:
|
|
1147
|
+
api_version_param = next(
|
|
1148
|
+
p
|
|
1149
|
+
for p in self.code_model.client.parameters
|
|
1150
|
+
if p.rest_api_name == "api-version"
|
|
1151
|
+
)
|
|
1152
|
+
retval.append("# make call to next link with the client's api-version")
|
|
1153
|
+
retval.append("_parsed_next_link = urlparse(next_link)")
|
|
1154
|
+
retval.append(
|
|
1155
|
+
"_next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query))"
|
|
1156
|
+
)
|
|
1157
|
+
retval.append(
|
|
1158
|
+
f'_next_request_params["api-version"] = {api_version_param.full_client_name}'
|
|
1159
|
+
)
|
|
1160
|
+
query_str = ", params=_next_request_params"
|
|
1161
|
+
next_link_str = "urljoin(next_link, _parsed_next_link.path)"
|
|
1162
|
+
except StopIteration:
|
|
1163
|
+
pass
|
|
1164
|
+
|
|
1165
|
+
retval.append(f'request = HttpRequest("GET", {next_link_str}{query_str})')
|
|
1144
1166
|
retval.extend(self._postprocess_http_request(builder, "request.url"))
|
|
1167
|
+
|
|
1145
1168
|
return retval
|
|
1146
1169
|
|
|
1147
1170
|
def _prepare_request_callback(self, builder: PagingOperationType) -> List[str]:
|
|
@@ -106,7 +106,7 @@ class RawDeserializer:
|
|
|
106
106
|
except NameError:
|
|
107
107
|
pass
|
|
108
108
|
|
|
109
|
-
return ET.fromstring(data_as_str)
|
|
109
|
+
return ET.fromstring(data_as_str) # nosec
|
|
110
110
|
except ET.ParseError:
|
|
111
111
|
# It might be because the server has an issue, and returned JSON with
|
|
112
112
|
# content-type XML....
|
|
@@ -831,7 +831,7 @@ class Serializer(object):
|
|
|
831
831
|
return custom_serializer(data)
|
|
832
832
|
if data_type == 'str':
|
|
833
833
|
return cls.serialize_unicode(data)
|
|
834
|
-
return eval(data_type)(data)
|
|
834
|
+
return eval(data_type)(data) # nosec
|
|
835
835
|
|
|
836
836
|
@classmethod
|
|
837
837
|
def serialize_unicode(cls, data):
|
|
@@ -1765,7 +1765,7 @@ class Deserializer(object):
|
|
|
1765
1765
|
|
|
1766
1766
|
if data_type == 'str':
|
|
1767
1767
|
return self.deserialize_unicode(attr)
|
|
1768
|
-
return eval(data_type)(attr)
|
|
1768
|
+
return eval(data_type)(attr) # nosec
|
|
1769
1769
|
|
|
1770
1770
|
@staticmethod
|
|
1771
1771
|
def deserialize_unicode(data):
|
|
@@ -12,6 +12,16 @@ from .python_mappings import PadType
|
|
|
12
12
|
from .. import YamlUpdatePlugin
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
def _remove_paging_maxpagesize(yaml_data: Dict[str, Any]) -> None:
|
|
16
|
+
# we don't expose maxpagesize for version tolerant generation
|
|
17
|
+
# users should be passing this into `by_page`
|
|
18
|
+
yaml_data["parameters"] = [
|
|
19
|
+
p
|
|
20
|
+
for p in yaml_data.get("parameters", [])
|
|
21
|
+
if p["restApiName"].lower() not in ["maxpagesize", "$maxpagesize"]
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
15
25
|
def update_description(
|
|
16
26
|
description: Optional[str], default_description: str = ""
|
|
17
27
|
) -> str:
|
|
@@ -85,6 +95,10 @@ def update_paging_response(yaml_data: Dict[str, Any]) -> None:
|
|
|
85
95
|
class PreProcessPlugin(YamlUpdatePlugin):
|
|
86
96
|
"""Add Python naming information."""
|
|
87
97
|
|
|
98
|
+
@property
|
|
99
|
+
def version_tolerant(self) -> bool:
|
|
100
|
+
return bool(self._autorestapi.get_boolean_value("version-tolerant", True))
|
|
101
|
+
|
|
88
102
|
def get_operation_updater(
|
|
89
103
|
self, yaml_data: Dict[str, Any]
|
|
90
104
|
) -> Callable[[Dict[str, Any]], None]:
|
|
@@ -144,13 +158,16 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
144
158
|
def update_lro_paging_operation(self, yaml_data: Dict[str, Any]) -> None:
|
|
145
159
|
self.update_lro_operation(yaml_data)
|
|
146
160
|
self.update_paging_operation(yaml_data)
|
|
161
|
+
yaml_data["discriminator"] = "lropaging"
|
|
147
162
|
for response in yaml_data.get("responses", []):
|
|
148
163
|
response["discriminator"] = "lropaging"
|
|
164
|
+
for overload in yaml_data.get("overloads", []):
|
|
165
|
+
self.update_lro_paging_operation(overload)
|
|
149
166
|
|
|
150
167
|
def update_lro_operation(self, yaml_data: Dict[str, Any]) -> None:
|
|
151
168
|
self.update_operation(yaml_data)
|
|
152
169
|
self._update_lro_operation_helper(yaml_data)
|
|
153
|
-
for overload in yaml_data
|
|
170
|
+
for overload in yaml_data.get("overloads", []):
|
|
154
171
|
self._update_lro_operation_helper(overload)
|
|
155
172
|
|
|
156
173
|
def update_paging_operation(self, yaml_data: Dict[str, Any]) -> None:
|
|
@@ -164,15 +181,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
164
181
|
if yaml_data.get("nextOperation")
|
|
165
182
|
else yaml_data["responses"][0]
|
|
166
183
|
)
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
if self.version_tolerant:
|
|
185
|
+
# if we're in version tolerant, hide the paging model
|
|
169
186
|
returned_response_object["type"]["isPublic"] = False
|
|
187
|
+
_remove_paging_maxpagesize(yaml_data)
|
|
170
188
|
item_type = next(
|
|
171
189
|
p["type"]["elementType"]
|
|
172
190
|
for p in returned_response_object["type"]["properties"]
|
|
173
|
-
if p["restApiName"] == yaml_data
|
|
191
|
+
if p["restApiName"] == (yaml_data.get("itemName") or "value")
|
|
174
192
|
)
|
|
175
193
|
if yaml_data.get("nextOperation"):
|
|
194
|
+
if self.version_tolerant:
|
|
195
|
+
_remove_paging_maxpagesize(yaml_data["nextOperation"])
|
|
176
196
|
yaml_data["nextOperation"]["groupName"] = pad_reserved_words(
|
|
177
197
|
yaml_data["nextOperation"]["groupName"], PadType.OPERATION_GROUP
|
|
178
198
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "node run-python3.js prepare.py",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@autorest/system-requirements": "~1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@microsoft.azure/autorest.testserver": "^3.3.
|
|
30
|
+
"@microsoft.azure/autorest.testserver": "^3.3.31"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"autorest/**/*.py",
|