@autorest/python 5.17.0 → 6.0.0-rc.1
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 +63 -1
- package/README.md +9 -0
- package/autorest/codegen/__init__.py +24 -30
- package/autorest/codegen/models/base_builder.py +17 -6
- package/autorest/codegen/models/base_type.py +6 -0
- package/autorest/codegen/models/client.py +9 -6
- package/autorest/codegen/models/code_model.py +20 -14
- package/autorest/codegen/models/dictionary_type.py +16 -1
- package/autorest/codegen/models/imports.py +57 -2
- package/autorest/codegen/models/list_type.py +16 -1
- package/autorest/codegen/models/lro_operation.py +4 -6
- package/autorest/codegen/models/lro_paging_operation.py +3 -9
- package/autorest/codegen/models/model_type.py +34 -16
- package/autorest/codegen/models/operation.py +47 -79
- package/autorest/codegen/models/operation_group.py +10 -9
- package/autorest/codegen/models/paging_operation.py +4 -6
- package/autorest/codegen/models/parameter.py +3 -7
- package/autorest/codegen/models/parameter_list.py +26 -35
- package/autorest/codegen/models/property.py +14 -0
- package/autorest/codegen/models/request_builder.py +32 -43
- package/autorest/codegen/serializers/__init__.py +12 -50
- package/autorest/codegen/serializers/builder_serializer.py +136 -49
- package/autorest/codegen/serializers/client_serializer.py +23 -32
- package/autorest/codegen/serializers/general_serializer.py +12 -12
- package/autorest/codegen/serializers/import_serializer.py +11 -22
- package/autorest/codegen/serializers/metadata_serializer.py +0 -2
- package/autorest/codegen/serializers/{model_base_serializer.py → model_serializer.py} +58 -44
- package/autorest/codegen/serializers/operation_groups_serializer.py +3 -7
- package/autorest/codegen/serializers/operations_init_serializer.py +2 -23
- package/autorest/codegen/serializers/patch_serializer.py +1 -3
- package/autorest/codegen/serializers/request_builders_serializer.py +2 -5
- package/autorest/codegen/serializers/utils.py +3 -4
- package/autorest/codegen/templates/client.py.jinja2 +6 -3
- package/autorest/codegen/templates/config.py.jinja2 +2 -2
- package/autorest/codegen/templates/metadata.json.jinja2 +4 -4
- package/autorest/codegen/templates/model.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +5 -12
- package/autorest/codegen/templates/operation_group.py.jinja2 +16 -3
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +2 -8
- package/autorest/codegen/templates/operation_tools.jinja2 +3 -1
- package/autorest/codegen/templates/patch.py.jinja2 +1 -2
- package/autorest/codegen/templates/request_builder.py.jinja2 +0 -7
- package/autorest/codegen/templates/request_builders.py.jinja2 +1 -4
- package/autorest/codegen/templates/rest_init.py.jinja2 +3 -8
- package/autorest/codegen/templates/serialization.py.jinja2 +2006 -0
- package/autorest/codegen/templates/setup.py.jinja2 +4 -0
- package/autorest/codegen/templates/vendor.py.jinja2 +10 -0
- package/autorest/m4reformatter/__init__.py +82 -58
- package/autorest/multiapi/models/client.py +12 -2
- package/autorest/multiapi/serializers/__init__.py +17 -8
- package/autorest/multiapi/serializers/import_serializer.py +4 -8
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +1 -1
- package/autorest/preprocess/__init__.py +1 -0
- package/package.json +2 -2
- package/autorest/codegen/serializers/model_generic_serializer.py +0 -32
- package/autorest/codegen/serializers/model_python3_serializer.py +0 -72
|
@@ -22,8 +22,8 @@ class {{ code_model.client.name }}Configuration(Configuration): # pylint: disab
|
|
|
22
22
|
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
|
|
23
23
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
24
24
|
super({{ code_model.client.name }}Configuration, self).__init__(**kwargs)
|
|
25
|
-
{% if code_model.config.parameters.kwargs_to_pop
|
|
26
|
-
{{ op_tools.serialize(serializer.pop_kwargs_from_signature(
|
|
25
|
+
{% if code_model.config.parameters.kwargs_to_pop %}
|
|
26
|
+
{{ op_tools.serialize(serializer.pop_kwargs_from_signature()) | indent(8) }}
|
|
27
27
|
{% endif %}
|
|
28
28
|
{% if serializer.check_required_parameters() %}
|
|
29
29
|
{{ op_tools.serialize(serializer.check_required_parameters()) | indent(8) -}}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sync": {
|
|
21
21
|
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
22
22
|
{{ gp.client_name | tojson }}: {
|
|
23
|
-
"signature": {{ gp.method_signature(
|
|
23
|
+
"signature": {{ gp.method_signature(async_mode=False) | tojson }},
|
|
24
24
|
"description": {{ gp.description | tojson }},
|
|
25
25
|
"docstring_type": {{ gp.docstring_type(async_mode=False) | tojson }},
|
|
26
26
|
"required": {{ (not gp.optional) | tojson }}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"async": {
|
|
31
31
|
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
32
32
|
{{ gp.client_name | tojson }}: {
|
|
33
|
-
"signature": {{ (gp.method_signature(
|
|
33
|
+
"signature": {{ (gp.method_signature(async_mode=True)) | tojson }},
|
|
34
34
|
"description": {{ gp.description | tojson }},
|
|
35
35
|
"docstring_type": {{ gp.docstring_type(async_mode=True) | tojson }},
|
|
36
36
|
"required": {{ (not gp.optional) | tojson }}
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
{% if not client.has_parameterized_host %}
|
|
55
55
|
"base_url": {
|
|
56
|
-
"signature": {{ client.parameters.host.method_signature(
|
|
56
|
+
"signature": {{ client.parameters.host.method_signature(async_mode=False) | tojson }},
|
|
57
57
|
"description": "Service URL",
|
|
58
58
|
"docstring_type": "str",
|
|
59
59
|
"required": false
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
{% if not client.has_parameterized_host %}
|
|
77
77
|
"base_url": {
|
|
78
|
-
"signature": {{ client.parameters.host.method_signature(
|
|
78
|
+
"signature": {{ client.parameters.host.method_signature(async_mode=True) | tojson }},
|
|
79
79
|
"description": "Service URL",
|
|
80
80
|
"docstring_type": "str",
|
|
81
81
|
"required": false
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
{% if model.discriminated_subtypes %}
|
|
46
46
|
|
|
47
47
|
_subtype_map = {
|
|
48
|
-
'{{ model.discriminator.client_name }}': {{ str(model.
|
|
48
|
+
'{{ model.discriminator.client_name }}': {{ str(model.discriminated_subtypes_name_mapping) }}
|
|
49
49
|
}
|
|
50
50
|
{% endif %}
|
|
51
51
|
{% if model.xml_map_content %}
|
|
@@ -3,21 +3,14 @@
|
|
|
3
3
|
{{ code_model.options['license_header'] }}
|
|
4
4
|
{% macro iterate_models_py3() %}
|
|
5
5
|
{% for schema in schemas %}
|
|
6
|
-
from .{{ code_model.
|
|
6
|
+
from .{{ code_model.models_filename }} import {{ schema }}
|
|
7
7
|
{% endfor %}
|
|
8
8
|
{% endmacro %}
|
|
9
|
-
|
|
10
9
|
{% if schemas %}
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{{ iterate_models_py3() | indent-}}
|
|
16
|
-
except (SyntaxError, ImportError):
|
|
17
|
-
{% for schema in schemas %}
|
|
18
|
-
from .{{ code_model.get_models_filename(is_python3_file=False) }} import {{ schema }} # type: ignore
|
|
19
|
-
{% endfor %}
|
|
20
|
-
{% endif %}
|
|
10
|
+
|
|
11
|
+
{% for schema in schemas %}
|
|
12
|
+
from .{{ code_model.models_filename }} import {{ schema }}
|
|
13
|
+
{% endfor %}
|
|
21
14
|
{% endif %}
|
|
22
15
|
{% if enums %}
|
|
23
16
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
{% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
|
|
2
|
-
{% set base_class = ("(" + operation_group.base_class
|
|
2
|
+
{% set base_class = ("(" + operation_group.base_class + ")") if operation_group.base_class else "" %}
|
|
3
|
+
{% macro check_abstract_methods() %}
|
|
4
|
+
{% if operation_group.has_abstract_operations %}
|
|
5
|
+
raise_if_not_implemented(self.__class__, [
|
|
6
|
+
{% for operation in operation_group.operations if operation.abstract %}
|
|
7
|
+
'{{operation.name}}',
|
|
8
|
+
{% endfor %}
|
|
9
|
+
])
|
|
10
|
+
{% endif %}
|
|
11
|
+
{% endmacro %}
|
|
3
12
|
class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
4
13
|
{% if not operation_group.is_mixin %}
|
|
5
14
|
"""
|
|
@@ -11,7 +20,7 @@ class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
|
11
20
|
:attr:`{{ operation_group.property_name }}` attribute.
|
|
12
21
|
"""
|
|
13
22
|
|
|
14
|
-
{% if code_model.public_model_types and code_model.options["models_mode"]
|
|
23
|
+
{% if code_model.public_model_types and code_model.options["models_mode"]%}
|
|
15
24
|
models = _models
|
|
16
25
|
|
|
17
26
|
{% endif %}
|
|
@@ -21,9 +30,13 @@ class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
|
21
30
|
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
22
31
|
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
23
32
|
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
33
|
+
{{ check_abstract_methods() }}
|
|
34
|
+
{% elif operation_group.has_abstract_operations %}
|
|
24
35
|
|
|
36
|
+
def __init__(self){{ return_none_type_annotation }}:
|
|
37
|
+
{{ check_abstract_methods() }}
|
|
25
38
|
{% endif %}
|
|
26
|
-
{% for operation in operation_group.operations %}
|
|
39
|
+
{% for operation in operation_group.operations if not operation.abstract %}
|
|
27
40
|
|
|
28
41
|
{% set request_builder = operation.request_builder %}
|
|
29
42
|
{% set operation_serializer = get_operation_serializer(operation) %}
|
|
@@ -7,19 +7,13 @@
|
|
|
7
7
|
{{ imports }}
|
|
8
8
|
|
|
9
9
|
{% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
|
|
10
|
-
{{ op_tools.declare_serializer(code_model) }}
|
|
11
|
-
{%- if not is_python3_file %}
|
|
12
|
-
# fmt: off
|
|
13
|
-
{% endif %}
|
|
10
|
+
{{ op_tools.declare_serializer(code_model, request_builders) }}
|
|
14
11
|
{% for operation_group in operation_groups %}
|
|
15
|
-
{% for request_builder in
|
|
12
|
+
{% for request_builder in request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
|
|
16
13
|
|
|
17
14
|
{% include "request_builder.py.jinja2" %}
|
|
18
15
|
{% endfor %}
|
|
19
16
|
{% endfor %}
|
|
20
|
-
{% if not is_python3_file %}
|
|
21
|
-
# fmt: on
|
|
22
|
-
{% endif %}
|
|
23
17
|
{% endif %}
|
|
24
18
|
{% for operation_group in operation_groups %}
|
|
25
19
|
{% include "operation_group.py.jinja2" %}
|
|
@@ -50,11 +50,13 @@ Example:
|
|
|
50
50
|
{% endif %}
|
|
51
51
|
{% endfor %}{% endmacro %}
|
|
52
52
|
|
|
53
|
-
{% macro declare_serializer(code_model) %}
|
|
53
|
+
{% macro declare_serializer(code_model, request_builders) %}
|
|
54
|
+
{% if request_builders %}
|
|
54
55
|
_SERIALIZER = Serializer()
|
|
55
56
|
{% if not code_model.options["client_side_validation"] %}
|
|
56
57
|
_SERIALIZER.client_side_validation = False
|
|
57
58
|
{% endif %}
|
|
59
|
+
{% endif %}
|
|
58
60
|
{% endmacro %}
|
|
59
61
|
|
|
60
62
|
{% macro generate_overloads(operation_serializer, operation) %}
|
|
@@ -8,8 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python
|
|
|
8
8
|
"""
|
|
9
9
|
{{ imports }}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
__all__{{ type_annotation if is_python3_file else "" }} = []{{ "" if is_python3_file else (" # type" + type_annotation) }} # Add all objects you want publicly available to users at this package level
|
|
11
|
+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
|
|
13
12
|
|
|
14
13
|
def patch_sdk():
|
|
15
14
|
"""Do not remove from this file.
|
|
@@ -5,12 +5,6 @@
|
|
|
5
5
|
{{ op_tools.description(request_builder, request_builder_serializer) | indent }}
|
|
6
6
|
{% endif %}
|
|
7
7
|
{% if not request_builder.is_overload %}
|
|
8
|
-
{% if request_builder.abstract %}
|
|
9
|
-
raise NotImplementedError(
|
|
10
|
-
"You need to write a custom operation for '{{ request_builder.name }}'. "
|
|
11
|
-
"Please refer to https://aka.ms/azsdk/python/dpcodegen/python/customize to learn how to customize."
|
|
12
|
-
)
|
|
13
|
-
{% else %}
|
|
14
8
|
{% if request_builder_serializer.pop_kwargs_from_signature(request_builder) %}
|
|
15
9
|
{{ op_tools.serialize(request_builder_serializer.pop_kwargs_from_signature(request_builder)) | indent }}
|
|
16
10
|
{%- endif -%}
|
|
@@ -31,5 +25,4 @@
|
|
|
31
25
|
{{ op_tools.serialize(request_builder_serializer.serialize_headers(request_builder)) | indent }}
|
|
32
26
|
{% endif %}
|
|
33
27
|
{{ op_tools.serialize(request_builder_serializer.create_http_request(request_builder)) | indent }}
|
|
34
|
-
{% endif %}
|
|
35
28
|
{% endif %}
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
{{ code_model.options['license_header'] }}
|
|
4
4
|
{{ imports }}
|
|
5
5
|
|
|
6
|
-
{{ op_tools.declare_serializer(code_model) }}
|
|
7
|
-
{% if not is_python3_file %}
|
|
8
|
-
# fmt: off
|
|
9
|
-
{% endif %}
|
|
6
|
+
{{ op_tools.declare_serializer(code_model, request_builders) }}
|
|
10
7
|
{% for request_builder in request_builders %}
|
|
11
8
|
|
|
12
9
|
{% include "request_builder.py.jinja2" %}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
{{ code_model.options['license_header'] }}
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{% endfor %}
|
|
8
|
-
except (SyntaxError, ImportError):
|
|
9
|
-
{% for request_builder in request_builders %}
|
|
10
|
-
from ._request_builders import {{ request_builder.name }} # type: ignore
|
|
11
|
-
{% endfor %}
|
|
4
|
+
{% for request_builder in request_builders %}
|
|
5
|
+
from ._request_builders import {{ request_builder.name }}
|
|
6
|
+
{% endfor %}
|
|
12
7
|
|
|
13
8
|
__all__ = [
|
|
14
9
|
{% for request_builder in request_builders %}
|