@autorest/python 5.18.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.
Files changed (30) hide show
  1. package/ChangeLog.md +17 -16
  2. package/autorest/codegen/__init__.py +7 -2
  3. package/autorest/codegen/models/client.py +8 -5
  4. package/autorest/codegen/models/code_model.py +15 -4
  5. package/autorest/codegen/models/imports.py +57 -2
  6. package/autorest/codegen/models/lro_operation.py +2 -0
  7. package/autorest/codegen/models/operation.py +44 -45
  8. package/autorest/codegen/models/operation_group.py +6 -2
  9. package/autorest/codegen/models/paging_operation.py +2 -0
  10. package/autorest/codegen/models/request_builder.py +31 -20
  11. package/autorest/codegen/serializers/__init__.py +9 -0
  12. package/autorest/codegen/serializers/builder_serializer.py +0 -4
  13. package/autorest/codegen/serializers/client_serializer.py +8 -0
  14. package/autorest/codegen/serializers/general_serializer.py +10 -5
  15. package/autorest/codegen/serializers/model_base_serializer.py +10 -5
  16. package/autorest/codegen/serializers/operation_groups_serializer.py +3 -0
  17. package/autorest/codegen/serializers/request_builders_serializer.py +1 -1
  18. package/autorest/codegen/templates/client.py.jinja2 +3 -0
  19. package/autorest/codegen/templates/operation_group.py.jinja2 +15 -2
  20. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +2 -2
  21. package/autorest/codegen/templates/operation_tools.jinja2 +3 -1
  22. package/autorest/codegen/templates/request_builder.py.jinja2 +0 -7
  23. package/autorest/codegen/templates/request_builders.py.jinja2 +1 -1
  24. package/autorest/codegen/templates/serialization.py.jinja2 +2006 -0
  25. package/autorest/codegen/templates/setup.py.jinja2 +4 -0
  26. package/autorest/codegen/templates/vendor.py.jinja2 +10 -0
  27. package/autorest/multiapi/models/client.py +12 -2
  28. package/autorest/multiapi/serializers/__init__.py +14 -0
  29. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +1 -1
  30. package/package.json +1 -1
@@ -1,5 +1,14 @@
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
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,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 code_model.request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
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 %}
@@ -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) %}
@@ -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,7 +3,7 @@
3
3
  {{ code_model.options['license_header'] }}
4
4
  {{ imports }}
5
5
 
6
- {{ op_tools.declare_serializer(code_model) }}
6
+ {{ op_tools.declare_serializer(code_model, request_builders) }}
7
7
  {% if not is_python3_file %}
8
8
  # fmt: off
9
9
  {% endif %}