@autorest/python 5.16.0 → 5.19.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 +79 -4
- package/README.md +30 -4
- package/autorest/__init__.py +1 -1
- package/autorest/codegen/__init__.py +55 -211
- package/autorest/codegen/models/__init__.py +116 -83
- package/autorest/codegen/models/base_builder.py +49 -88
- package/autorest/codegen/models/base_model.py +1 -1
- package/autorest/codegen/models/{base_schema.py → base_type.py} +61 -39
- package/autorest/codegen/models/client.py +165 -53
- package/autorest/codegen/models/code_model.py +122 -257
- package/autorest/codegen/models/combined_type.py +107 -0
- package/autorest/codegen/models/{constant_schema.py → constant_type.py} +49 -40
- package/autorest/codegen/models/credential_types.py +224 -0
- package/autorest/codegen/models/dictionary_type.py +131 -0
- package/autorest/codegen/models/enum_type.py +195 -0
- package/autorest/codegen/models/imports.py +80 -2
- package/autorest/codegen/models/list_type.py +149 -0
- package/autorest/codegen/models/lro_operation.py +79 -156
- package/autorest/codegen/models/lro_paging_operation.py +28 -11
- package/autorest/codegen/models/model_type.py +262 -0
- package/autorest/codegen/models/operation.py +331 -298
- package/autorest/codegen/models/operation_group.py +54 -91
- package/autorest/codegen/models/paging_operation.py +82 -123
- package/autorest/codegen/models/parameter.py +289 -396
- package/autorest/codegen/models/parameter_list.py +355 -360
- package/autorest/codegen/models/primitive_types.py +544 -0
- package/autorest/codegen/models/property.py +123 -139
- package/autorest/codegen/models/request_builder.py +130 -102
- package/autorest/codegen/models/request_builder_parameter.py +112 -100
- package/autorest/codegen/models/response.py +325 -0
- package/autorest/codegen/models/utils.py +12 -19
- package/autorest/codegen/serializers/__init__.py +55 -37
- package/autorest/codegen/serializers/builder_serializer.py +695 -1144
- package/autorest/codegen/serializers/client_serializer.py +92 -89
- package/autorest/codegen/serializers/general_serializer.py +15 -69
- package/autorest/codegen/serializers/import_serializer.py +7 -4
- package/autorest/codegen/serializers/metadata_serializer.py +15 -104
- package/autorest/codegen/serializers/model_base_serializer.py +49 -36
- package/autorest/codegen/serializers/model_generic_serializer.py +8 -6
- package/autorest/codegen/serializers/model_init_serializer.py +2 -4
- package/autorest/codegen/serializers/model_python3_serializer.py +22 -16
- package/autorest/codegen/serializers/operation_groups_serializer.py +7 -13
- package/autorest/codegen/serializers/parameter_serializer.py +174 -0
- package/autorest/codegen/serializers/request_builders_serializer.py +13 -30
- package/autorest/codegen/serializers/utils.py +0 -140
- package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
- package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +10 -7
- package/autorest/codegen/templates/config.py.jinja2 +13 -13
- package/autorest/codegen/templates/enum.py.jinja2 +4 -4
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/init.py.jinja2 +2 -2
- package/autorest/codegen/templates/lro_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/metadata.json.jinja2 +33 -33
- package/autorest/codegen/templates/model.py.jinja2 +23 -24
- package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
- package/autorest/codegen/templates/operation.py.jinja2 +6 -8
- package/autorest/codegen/templates/operation_group.py.jinja2 +21 -8
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +2 -2
- package/autorest/codegen/templates/operation_tools.jinja2 +11 -3
- package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
- package/autorest/codegen/templates/request_builder.py.jinja2 +10 -15
- package/autorest/codegen/templates/request_builders.py.jinja2 +1 -1
- package/autorest/codegen/templates/serialization.py.jinja2 +2006 -0
- package/autorest/codegen/templates/setup.py.jinja2 +13 -3
- package/autorest/codegen/templates/vendor.py.jinja2 +11 -1
- package/autorest/jsonrpc/server.py +15 -3
- package/autorest/m4reformatter/__init__.py +1126 -0
- package/autorest/multiapi/models/client.py +12 -2
- package/autorest/multiapi/models/code_model.py +1 -1
- package/autorest/multiapi/serializers/__init__.py +18 -4
- package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +4 -4
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
- package/autorest/postprocess/__init__.py +202 -0
- package/autorest/postprocess/get_all.py +19 -0
- package/autorest/postprocess/venvtools.py +73 -0
- package/autorest/preprocess/__init__.py +210 -0
- package/autorest/preprocess/helpers.py +54 -0
- package/autorest/{namer → preprocess}/python_mappings.py +21 -16
- package/package.json +2 -2
- package/autorest/codegen/models/credential_model.py +0 -55
- package/autorest/codegen/models/credential_schema.py +0 -95
- package/autorest/codegen/models/credential_schema_policy.py +0 -73
- package/autorest/codegen/models/dictionary_schema.py +0 -106
- package/autorest/codegen/models/enum_schema.py +0 -225
- package/autorest/codegen/models/list_schema.py +0 -135
- package/autorest/codegen/models/object_schema.py +0 -303
- package/autorest/codegen/models/primitive_schemas.py +0 -495
- package/autorest/codegen/models/request_builder_parameter_list.py +0 -249
- package/autorest/codegen/models/schema_request.py +0 -55
- package/autorest/codegen/models/schema_response.py +0 -141
- package/autorest/namer/__init__.py +0 -23
- package/autorest/namer/name_converter.py +0 -509
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
{% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
|
|
2
2
|
{% set base_class = ("(" + operation_group.base_class(async_mode) + ")") if operation_group.base_class(async_mode) 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
|
-
{% if not operation_group.
|
|
13
|
+
{% if not operation_group.is_mixin %}
|
|
5
14
|
"""
|
|
6
15
|
.. warning::
|
|
7
16
|
**DO NOT** instantiate this class directly.
|
|
8
17
|
|
|
9
18
|
Instead, you should access the following operations through
|
|
10
|
-
:class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.
|
|
11
|
-
:attr:`{{ operation_group.
|
|
19
|
+
:class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.client.name }}`'s
|
|
20
|
+
:attr:`{{ operation_group.property_name }}` attribute.
|
|
12
21
|
"""
|
|
13
22
|
|
|
14
|
-
{% if code_model.
|
|
23
|
+
{% if code_model.public_model_types and code_model.options["models_mode"]%}
|
|
15
24
|
models = _models
|
|
16
25
|
|
|
17
26
|
{% endif %}
|
|
@@ -21,17 +30,21 @@ 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) %}
|
|
30
|
-
{% if
|
|
43
|
+
{% if operation.operation_type == "lropaging" %}
|
|
31
44
|
{%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %}
|
|
32
|
-
{% elif
|
|
45
|
+
{% elif operation.operation_type == "lro" %}
|
|
33
46
|
{%- macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %}
|
|
34
|
-
{% elif
|
|
47
|
+
{% elif operation.operation_type == "paging" %}
|
|
35
48
|
{% macro someop() %}{% include "paging_operation.py.jinja2" %}{% endmacro %}
|
|
36
49
|
{% else %}
|
|
37
50
|
{% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %}
|
|
@@ -7,12 +7,12 @@
|
|
|
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) }}
|
|
10
|
+
{{ op_tools.declare_serializer(code_model, request_builders) }}
|
|
11
11
|
{%- if not is_python3_file %}
|
|
12
12
|
# fmt: off
|
|
13
13
|
{% endif %}
|
|
14
14
|
{% for operation_group in operation_groups %}
|
|
15
|
-
{% for request_builder in
|
|
15
|
+
{% for request_builder in request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
|
|
16
16
|
|
|
17
17
|
{% include "request_builder.py.jinja2" %}
|
|
18
18
|
{% endfor %}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
{% endif %}
|
|
18
18
|
{% endfor %}
|
|
19
|
-
{% if serializer.
|
|
19
|
+
{% if serializer.example_template(builder) %}
|
|
20
20
|
|
|
21
21
|
Example:
|
|
22
22
|
.. code-block:: python
|
|
23
|
-
{% for template_line in serializer.
|
|
23
|
+
{% for template_line in serializer.example_template(builder) %}
|
|
24
24
|
{% if template_line %}
|
|
25
25
|
{% set wrap_amount = (template_line | length) - (template_line.lstrip() | length) + 10 %}
|
|
26
26
|
{{ wrap_string(template_line, wrapstring='\n' + " " * wrap_amount, width=(95 - wrap_amount)) }}
|
|
@@ -50,9 +50,17 @@ 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 %}
|
|
61
|
+
|
|
62
|
+
{% macro generate_overloads(operation_serializer, operation) %}
|
|
63
|
+
{% for overload in operation.overloads %}
|
|
64
|
+
{{ operation_serializer.method_signature_and_response_type_annotation(overload) }}
|
|
65
|
+
{{ description(overload, operation_serializer) | indent }}
|
|
66
|
+
{% endfor %}{% endmacro %}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
2
2
|
{# actual template starts here #}
|
|
3
|
-
{{ operation_serializer.method_signature_and_response_type_annotation(operation
|
|
4
|
-
{% if operation.
|
|
3
|
+
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
4
|
+
{% if operation.public %}
|
|
5
5
|
{{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
|
|
6
6
|
{% if not operation.abstract %}
|
|
7
7
|
{% if operation.deprecated %}
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
3
|
-
{{ request_builder_serializer.method_signature_and_response_type_annotation(request_builder
|
|
3
|
+
{{ request_builder_serializer.method_signature_and_response_type_annotation(request_builder) }}
|
|
4
4
|
{% if code_model.options["builders_visibility"] == "public" %}
|
|
5
5
|
{{ op_tools.description(request_builder, request_builder_serializer) | indent }}
|
|
6
6
|
{% endif %}
|
|
7
|
-
{% if request_builder.
|
|
8
|
-
|
|
9
|
-
"You need to write a custom operation for '{{ request_builder.name }}'. "
|
|
10
|
-
"Please refer to https://aka.ms/azsdk/python/dpcodegen/python/customize to learn how to customize."
|
|
11
|
-
)
|
|
12
|
-
{% else %}
|
|
13
|
-
{% if request_builder_serializer.pop_kwargs_from_signature(request_builder) %}
|
|
7
|
+
{% if not request_builder.is_overload %}
|
|
8
|
+
{% if request_builder_serializer.pop_kwargs_from_signature(request_builder) %}
|
|
14
9
|
{{ op_tools.serialize(request_builder_serializer.pop_kwargs_from_signature(request_builder)) | indent }}
|
|
15
|
-
|
|
10
|
+
{%- endif -%}
|
|
16
11
|
{% if request_builder_serializer.declare_non_inputtable_constants(request_builder) %}
|
|
17
12
|
{{ op_tools.serialize(request_builder_serializer.declare_non_inputtable_constants(request_builder)) | indent }}
|
|
18
|
-
|
|
13
|
+
{% endif %}
|
|
19
14
|
# Construct URL
|
|
20
15
|
{{ request_builder_serializer.construct_url(request_builder) }}
|
|
21
16
|
{% if request_builder.parameters.path %}
|
|
22
17
|
{{ op_tools.serialize(request_builder_serializer.serialize_path(request_builder)) | indent }}
|
|
23
18
|
_url = _format_url_section(_url, **path_format_arguments)
|
|
24
|
-
|
|
19
|
+
{% endif %}
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
{% if request_builder.parameters.query %}
|
|
27
22
|
{{ op_tools.serialize(request_builder_serializer.serialize_query(request_builder)) | indent }}
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
{% endif %}
|
|
24
|
+
{% if request_builder.parameters.headers %}
|
|
30
25
|
{{ op_tools.serialize(request_builder_serializer.serialize_headers(request_builder)) | indent }}
|
|
31
|
-
|
|
26
|
+
{% endif %}
|
|
32
27
|
{{ op_tools.serialize(request_builder_serializer.create_http_request(request_builder)) | indent }}
|
|
33
28
|
{% endif %}
|