@autorest/python 5.9.1 → 5.9.2
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 +13 -0
- package/autorest/codegen/models/code_model.py +1 -8
- package/autorest/codegen/models/lro_operation.py +0 -2
- package/autorest/codegen/models/operation.py +0 -1
- package/autorest/codegen/models/paging_operation.py +0 -1
- package/autorest/codegen/models/request_builder.py +4 -2
- package/autorest/codegen/models/request_builder_parameter_list.py +6 -2
- package/autorest/codegen/serializers/builder_serializer.py +6 -13
- package/autorest/codegen/templates/operation.py.jinja2 +1 -1
- package/autorest/codegen/templates/setup.py.jinja2 +1 -1
- package/package.json +2 -2
package/ChangeLog.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
### 2021-10-05 - 5.9.2
|
|
4
|
+
|
|
5
|
+
| Library | Min Version
|
|
6
|
+
| --------------- | -------
|
|
7
|
+
|`@autorest/core` | `3.6.2`
|
|
8
|
+
|`@autorest/modelerfour` | `4.19.1`
|
|
9
|
+
|`azure-core` dep of generated code | `1.19.0`
|
|
10
|
+
|`msrest` dep of generated code | `0.6.21`
|
|
11
|
+
|`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
|
|
12
|
+
|
|
13
|
+
**New Features**
|
|
14
|
+
- Updating generated code for `azure-core` release `1.19.0`.
|
|
15
|
+
|
|
3
16
|
### 2021-09-27 - 5.9.1
|
|
4
17
|
|
|
5
18
|
| Library | Min Version
|
|
@@ -349,14 +349,7 @@ class CodeModel: # pylint: disable=too-many-instance-attributes
|
|
|
349
349
|
|
|
350
350
|
@property
|
|
351
351
|
def need_request_converter(self) -> bool:
|
|
352
|
-
|
|
353
|
-
return False
|
|
354
|
-
if not self.options["version_tolerant"]:
|
|
355
|
-
return True
|
|
356
|
-
for og in self.operation_groups:
|
|
357
|
-
if any(o for o in og.operations if o.use_pipeline_transport):
|
|
358
|
-
return True
|
|
359
|
-
return False
|
|
352
|
+
return self.options["show_operations"] and not self.options["version_tolerant"]
|
|
360
353
|
|
|
361
354
|
@property
|
|
362
355
|
def need_format_url(self) -> bool:
|
|
@@ -45,7 +45,6 @@ class LROOperation(Operation):
|
|
|
45
45
|
)
|
|
46
46
|
self.lro_options = yaml_data.get("extensions", {}).get("x-ms-long-running-operation-options", {})
|
|
47
47
|
self.name = "begin_" + self.name
|
|
48
|
-
self.use_pipeline_transport = True
|
|
49
48
|
|
|
50
49
|
@property
|
|
51
50
|
def lro_response(self) -> Optional[SchemaResponse]:
|
|
@@ -91,7 +90,6 @@ class LROOperation(Operation):
|
|
|
91
90
|
want_tracing=False,
|
|
92
91
|
)
|
|
93
92
|
operation.request_builder = self.request_builder
|
|
94
|
-
operation.use_pipeline_transport = True
|
|
95
93
|
return operation
|
|
96
94
|
|
|
97
95
|
@property
|
|
@@ -52,7 +52,6 @@ class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-ma
|
|
|
52
52
|
self.want_tracing = want_tracing
|
|
53
53
|
self._request_builder: Optional[RequestBuilder] = None
|
|
54
54
|
self.deprecated = False
|
|
55
|
-
self.use_pipeline_transport = False
|
|
56
55
|
|
|
57
56
|
@property
|
|
58
57
|
def python_name(self) -> str:
|
|
@@ -51,7 +51,6 @@ class PagingOperation(Operation):
|
|
|
51
51
|
self.operation_name: str = yaml_data["extensions"]["x-ms-pageable"].get("operationName")
|
|
52
52
|
self.next_operation: Optional[Operation] = None
|
|
53
53
|
self.override_success_response_to_200 = override_success_response_to_200
|
|
54
|
-
self.use_pipeline_transport = True
|
|
55
54
|
|
|
56
55
|
def _get_response(self) -> SchemaResponse:
|
|
57
56
|
response = self.responses[0]
|
|
@@ -101,7 +101,9 @@ class RequestBuilder(BaseBuilder):
|
|
|
101
101
|
create_parameters(yaml_data, RequestBuilderParameter.from_yaml)
|
|
102
102
|
)
|
|
103
103
|
parameter_list = RequestBuilderParameterList(parameters + multiple_media_type_parameters)
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
schema_requests = [SchemaRequest.from_yaml(yaml) for yaml in yaml_data["requests"]]
|
|
106
|
+
parameter_list.add_body_kwargs(schema_requests)
|
|
105
107
|
|
|
106
108
|
request_builder_class = cls(
|
|
107
109
|
yaml_data=yaml_data,
|
|
@@ -109,7 +111,7 @@ class RequestBuilder(BaseBuilder):
|
|
|
109
111
|
url=first_request["protocol"]["http"]["path"],
|
|
110
112
|
method=first_request["protocol"]["http"]["method"].upper(),
|
|
111
113
|
multipart=first_request["protocol"]["http"].get("multipart", False),
|
|
112
|
-
schema_requests=
|
|
114
|
+
schema_requests=schema_requests,
|
|
113
115
|
parameters=parameter_list,
|
|
114
116
|
description=yaml_data["language"]["python"]["description"],
|
|
115
117
|
responses=[SchemaResponse.from_yaml(yaml) for yaml in yaml_data.get("responses", [])],
|
|
@@ -11,6 +11,7 @@ from .parameter import ParameterLocation, Parameter
|
|
|
11
11
|
from .primitive_schemas import IOSchema, AnySchema
|
|
12
12
|
from .dictionary_schema import DictionarySchema
|
|
13
13
|
from .base_schema import BaseSchema
|
|
14
|
+
from .schema_request import SchemaRequest
|
|
14
15
|
|
|
15
16
|
T = TypeVar('T')
|
|
16
17
|
OrderedSet = Dict[T, None]
|
|
@@ -32,7 +33,7 @@ class RequestBuilderParameterList(ParameterList):
|
|
|
32
33
|
self.body_kwarg_names[name] = None
|
|
33
34
|
parameter.serialized_name = name
|
|
34
35
|
|
|
35
|
-
def add_body_kwargs(self) -> None:
|
|
36
|
+
def add_body_kwargs(self, schema_requests: List[SchemaRequest]) -> None:
|
|
36
37
|
try:
|
|
37
38
|
body_kwargs_added = []
|
|
38
39
|
body_method_param = next(
|
|
@@ -71,7 +72,10 @@ class RequestBuilderParameterList(ParameterList):
|
|
|
71
72
|
data_kwarg.description
|
|
72
73
|
)
|
|
73
74
|
body_kwargs_added.append(data_kwarg)
|
|
74
|
-
if
|
|
75
|
+
if (
|
|
76
|
+
any(sr for sr in schema_requests if not sr.is_stream_request) and
|
|
77
|
+
any([ct for ct in self.content_types if "json" in ct])
|
|
78
|
+
):
|
|
75
79
|
json_kwarg = copy(body_method_param)
|
|
76
80
|
self._change_body_param_name(json_kwarg, "json")
|
|
77
81
|
json_kwarg.description = (
|
|
@@ -776,7 +776,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
776
776
|
template_url = template_url or f"self.{builder.name}.metadata['url']"
|
|
777
777
|
retval.append(f" template_url={template_url},")
|
|
778
778
|
retval.append(f")")
|
|
779
|
-
if not self.code_model.options["version_tolerant"]
|
|
779
|
+
if not self.code_model.options["version_tolerant"]:
|
|
780
780
|
pass_files = ""
|
|
781
781
|
if "files" in builder.body_kwargs_to_pass_to_request_builder:
|
|
782
782
|
pass_files = ", files"
|
|
@@ -795,7 +795,6 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
795
795
|
|
|
796
796
|
def response_headers_and_deserialization(
|
|
797
797
|
self,
|
|
798
|
-
builder: BuilderType,
|
|
799
798
|
response: SchemaResponse,
|
|
800
799
|
) -> List[str]:
|
|
801
800
|
retval: List[str] = [
|
|
@@ -820,14 +819,8 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
820
819
|
else:
|
|
821
820
|
is_xml = any(["xml" in ct for ct in response.media_types])
|
|
822
821
|
deserialized_value = ""
|
|
823
|
-
if is_xml
|
|
824
|
-
|
|
825
|
-
elif builder.use_pipeline_transport:
|
|
826
|
-
deserialized_value = "_loads(response.body())"
|
|
827
|
-
else:
|
|
828
|
-
deserialized_value = "response.json()"
|
|
829
|
-
response_body = "response.body()" if builder.use_pipeline_transport else "response.content"
|
|
830
|
-
retval.append(f"if {response_body}:")
|
|
822
|
+
deserialized_value = "ET.fromstring(response.text())" if is_xml else "response.json()"
|
|
823
|
+
retval.append(f"if response.content:")
|
|
831
824
|
retval.append(f" deserialized = {deserialized_value}")
|
|
832
825
|
retval.append("else:")
|
|
833
826
|
retval.append(" deserialized = None")
|
|
@@ -870,12 +863,12 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
870
863
|
retval.append(f"if response.status_code == {status_code}:")
|
|
871
864
|
retval.extend([
|
|
872
865
|
f" {line}"
|
|
873
|
-
for line in self.response_headers_and_deserialization(
|
|
866
|
+
for line in self.response_headers_and_deserialization(response)
|
|
874
867
|
])
|
|
875
868
|
retval.append("")
|
|
876
869
|
else:
|
|
877
870
|
retval.extend(self.response_headers_and_deserialization(
|
|
878
|
-
builder
|
|
871
|
+
builder.responses[0]
|
|
879
872
|
))
|
|
880
873
|
retval.append("")
|
|
881
874
|
retval.append("if cls:")
|
|
@@ -1258,7 +1251,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
|
|
|
1258
1251
|
retval.append(" response = pipeline_response.http_response")
|
|
1259
1252
|
retval.extend([
|
|
1260
1253
|
f" {line}"
|
|
1261
|
-
for line in self.response_headers_and_deserialization(builder
|
|
1254
|
+
for line in self.response_headers_and_deserialization(builder.lro_response)
|
|
1262
1255
|
])
|
|
1263
1256
|
retval.append(" if cls:")
|
|
1264
1257
|
retval.append(" return cls(pipeline_response, {}, {})".format(
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
19
19
|
{% endif %}
|
|
20
20
|
{{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }}
|
|
21
|
-
pipeline_response = {{ keywords.await }}self._client.
|
|
21
|
+
pipeline_response = {{ keywords.await }}self._client._pipeline.run(request, {{ stream_request_parameter }}, **kwargs)
|
|
22
22
|
{{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
|
|
23
23
|
{{ operation.python_name }}.metadata = {'url': {{ keywords.escape_str(request_builder.url) }}} # type: ignore
|
|
@@ -16,7 +16,7 @@ VERSION = "{{ code_model.options.get('package_version', '0.0.0') }}"
|
|
|
16
16
|
# prerequisite: setuptools
|
|
17
17
|
# http://pypi.python.org/pypi/setuptools
|
|
18
18
|
|
|
19
|
-
REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.
|
|
19
|
+
REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.19.0"{{ azure_mgmt_core_import }}]
|
|
20
20
|
|
|
21
21
|
setup(
|
|
22
22
|
name=NAME,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.2",
|
|
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
|
"@azure-tools/extension": "~3.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@microsoft.azure/autorest.testserver": "^3.0.
|
|
30
|
+
"@microsoft.azure/autorest.testserver": "^3.0.41"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"autorest/**/*.py",
|