@autorest/python 5.14.0 → 5.17.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 +91 -2
- package/README.md +30 -4
- package/autorest/__init__.py +2 -3
- package/autorest/black/__init__.py +12 -5
- package/autorest/codegen/__init__.py +130 -179
- package/autorest/codegen/models/__init__.py +122 -78
- package/autorest/codegen/models/base_builder.py +70 -72
- package/autorest/codegen/models/base_model.py +7 -5
- package/autorest/codegen/models/{base_schema.py → base_type.py} +62 -49
- package/autorest/codegen/models/client.py +195 -36
- package/autorest/codegen/models/code_model.py +165 -299
- package/autorest/codegen/models/combined_type.py +107 -0
- package/autorest/codegen/models/constant_type.py +122 -0
- package/autorest/codegen/models/credential_types.py +224 -0
- package/autorest/codegen/models/dictionary_type.py +116 -0
- package/autorest/codegen/models/enum_type.py +195 -0
- package/autorest/codegen/models/imports.py +95 -41
- package/autorest/codegen/models/list_type.py +134 -0
- package/autorest/codegen/models/lro_operation.py +90 -133
- package/autorest/codegen/models/lro_paging_operation.py +28 -12
- package/autorest/codegen/models/model_type.py +239 -0
- package/autorest/codegen/models/operation.py +415 -241
- package/autorest/codegen/models/operation_group.py +82 -88
- package/autorest/codegen/models/paging_operation.py +101 -117
- package/autorest/codegen/models/parameter.py +307 -322
- package/autorest/codegen/models/parameter_list.py +366 -357
- package/autorest/codegen/models/primitive_types.py +544 -0
- package/autorest/codegen/models/property.py +122 -134
- package/autorest/codegen/models/request_builder.py +138 -86
- package/autorest/codegen/models/request_builder_parameter.py +122 -79
- package/autorest/codegen/models/response.py +325 -0
- package/autorest/codegen/models/utils.py +17 -1
- package/autorest/codegen/serializers/__init__.py +242 -118
- package/autorest/codegen/serializers/builder_serializer.py +863 -1027
- package/autorest/codegen/serializers/client_serializer.py +148 -82
- package/autorest/codegen/serializers/general_serializer.py +44 -47
- package/autorest/codegen/serializers/import_serializer.py +96 -31
- package/autorest/codegen/serializers/metadata_serializer.py +39 -79
- package/autorest/codegen/serializers/model_base_serializer.py +65 -29
- package/autorest/codegen/serializers/model_generic_serializer.py +9 -10
- package/autorest/codegen/serializers/model_init_serializer.py +4 -2
- package/autorest/codegen/serializers/model_python3_serializer.py +29 -22
- package/autorest/codegen/serializers/operation_groups_serializer.py +21 -18
- package/autorest/codegen/serializers/operations_init_serializer.py +23 -11
- package/autorest/codegen/serializers/parameter_serializer.py +174 -0
- package/autorest/codegen/serializers/patch_serializer.py +14 -2
- package/autorest/codegen/serializers/request_builders_serializer.py +57 -0
- package/autorest/codegen/serializers/utils.py +0 -103
- package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
- package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -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 -2
- package/autorest/codegen/templates/init.py.jinja2 +9 -6
- package/autorest/codegen/templates/keywords.jinja2 +14 -1
- package/autorest/codegen/templates/lro_operation.py.jinja2 +6 -5
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +6 -5
- package/autorest/codegen/templates/metadata.json.jinja2 +36 -35
- package/autorest/codegen/templates/model.py.jinja2 +23 -29
- package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +9 -8
- package/autorest/codegen/templates/operation.py.jinja2 +10 -15
- package/autorest/codegen/templates/operation_group.py.jinja2 +14 -13
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -2
- package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
- package/autorest/codegen/templates/operations_folder_init.py.jinja2 +4 -0
- package/autorest/codegen/templates/paging_operation.py.jinja2 +7 -8
- package/autorest/codegen/templates/patch.py.jinja2 +18 -29
- package/autorest/codegen/templates/request_builder.py.jinja2 +20 -13
- package/autorest/codegen/templates/setup.py.jinja2 +9 -3
- package/autorest/codegen/templates/vendor.py.jinja2 +12 -2
- package/autorest/jsonrpc/__init__.py +7 -12
- package/autorest/jsonrpc/localapi.py +4 -3
- package/autorest/jsonrpc/server.py +28 -9
- package/autorest/jsonrpc/stdstream.py +13 -6
- package/autorest/m2r/__init__.py +5 -8
- package/autorest/m4reformatter/__init__.py +1108 -0
- package/autorest/multiapi/__init__.py +24 -14
- package/autorest/multiapi/models/client.py +21 -11
- package/autorest/multiapi/models/code_model.py +23 -10
- package/autorest/multiapi/models/config.py +4 -1
- package/autorest/multiapi/models/constant_global_parameter.py +1 -0
- package/autorest/multiapi/models/global_parameter.py +2 -1
- package/autorest/multiapi/models/global_parameters.py +14 -8
- package/autorest/multiapi/models/imports.py +35 -18
- package/autorest/multiapi/models/mixin_operation.py +5 -5
- package/autorest/multiapi/models/operation_group.py +2 -1
- package/autorest/multiapi/models/operation_mixin_group.py +21 -10
- package/autorest/multiapi/serializers/__init__.py +20 -25
- package/autorest/multiapi/serializers/import_serializer.py +47 -15
- package/autorest/multiapi/serializers/multiapi_serializer.py +17 -17
- 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/multiapi/utils.py +3 -3
- 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 +209 -0
- package/autorest/preprocess/helpers.py +54 -0
- package/autorest/{namer → preprocess}/python_mappings.py +25 -32
- package/package.json +3 -3
- package/run-python3.js +2 -3
- package/venvtools.py +1 -1
- package/autorest/codegen/models/constant_schema.py +0 -97
- package/autorest/codegen/models/credential_schema.py +0 -90
- package/autorest/codegen/models/credential_schema_policy.py +0 -77
- package/autorest/codegen/models/dictionary_schema.py +0 -103
- package/autorest/codegen/models/enum_schema.py +0 -246
- package/autorest/codegen/models/list_schema.py +0 -113
- package/autorest/codegen/models/object_schema.py +0 -249
- package/autorest/codegen/models/primitive_schemas.py +0 -476
- package/autorest/codegen/models/request_builder_parameter_list.py +0 -280
- package/autorest/codegen/models/rest.py +0 -42
- package/autorest/codegen/models/schema_request.py +0 -45
- package/autorest/codegen/models/schema_response.py +0 -123
- package/autorest/codegen/serializers/rest_serializer.py +0 -57
- package/autorest/namer/__init__.py +0 -25
- package/autorest/namer/name_converter.py +0 -412
|
@@ -11,32 +11,32 @@
|
|
|
11
11
|
VERSION = "unknown"
|
|
12
12
|
{% endif %}
|
|
13
13
|
|
|
14
|
-
class {{ code_model.
|
|
15
|
-
"""Configuration for {{ code_model.
|
|
14
|
+
class {{ code_model.client.name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
|
|
15
|
+
"""Configuration for {{ code_model.client.name }}.
|
|
16
16
|
|
|
17
17
|
Note that all parameters used to create this instance are saved as instance
|
|
18
18
|
attributes.
|
|
19
|
-
{% if code_model.
|
|
19
|
+
{% if code_model.config.parameters.method | first %}
|
|
20
20
|
|
|
21
21
|
{% endif %}
|
|
22
|
-
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(), "\n ") | indent }}
|
|
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
|
-
super({{ code_model.
|
|
25
|
-
{% if code_model.
|
|
24
|
+
super({{ code_model.client.name }}Configuration, self).__init__(**kwargs)
|
|
25
|
+
{% if code_model.config.parameters.kwargs_to_pop(async_mode) %}
|
|
26
26
|
{{ op_tools.serialize(serializer.pop_kwargs_from_signature(async_mode)) | indent(8) }}
|
|
27
27
|
{% endif %}
|
|
28
28
|
{% if serializer.check_required_parameters() %}
|
|
29
29
|
{{ op_tools.serialize(serializer.check_required_parameters()) | indent(8) -}}
|
|
30
30
|
{% endif %}
|
|
31
31
|
|
|
32
|
-
{% for parameter in code_model.
|
|
33
|
-
self.{{ parameter.
|
|
32
|
+
{% for parameter in code_model.config.parameters.method %}
|
|
33
|
+
self.{{ parameter.client_name }} = {{ parameter.client_name }}
|
|
34
34
|
{% endfor %}
|
|
35
35
|
{% if serializer.set_constants() %}
|
|
36
36
|
{{ op_tools.serialize(serializer.set_constants()) | indent(8) -}}
|
|
37
37
|
{% endif %}
|
|
38
|
-
{% if code_model.
|
|
39
|
-
self.credential_scopes = kwargs.pop('credential_scopes', {{ code_model.
|
|
38
|
+
{% if code_model.credential and code_model.credential.type.policy.credential_scopes is defined %}
|
|
39
|
+
self.credential_scopes = kwargs.pop('credential_scopes', {{ code_model.credential.type.policy.credential_scopes }})
|
|
40
40
|
{% endif %}
|
|
41
41
|
kwargs.setdefault('sdk_moniker', '{{ sdk_moniker }}/{}'.format(VERSION))
|
|
42
42
|
self._configure(**kwargs)
|
|
@@ -57,12 +57,12 @@ class {{ code_model.class_name }}Configuration(Configuration): # pylint: disabl
|
|
|
57
57
|
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
|
|
58
58
|
self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ keywords.async_class }}RedirectPolicy(**kwargs)
|
|
59
59
|
self.authentication_policy = kwargs.get('authentication_policy')
|
|
60
|
-
{% if code_model.
|
|
60
|
+
{% if code_model.credential %}
|
|
61
61
|
{# only adding this if credential_scopes is not passed during code generation #}
|
|
62
|
-
{% if code_model.
|
|
62
|
+
{% if code_model.credential.type.policy.credential_scopes is defined and code_model.credential.type.policy.credential_scopes | length == 0 %}
|
|
63
63
|
if not self.credential_scopes and not self.authentication_policy:
|
|
64
64
|
raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs")
|
|
65
65
|
{% endif %}
|
|
66
66
|
if self.credential and not self.authentication_policy:
|
|
67
|
-
self.authentication_policy = {{ code_model.
|
|
67
|
+
self.authentication_policy = {{ code_model.credential.type.policy.call(async_mode) }}
|
|
68
68
|
{% endif %}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
class {{ enum.name }}(
|
|
3
|
-
{% if enum.description %}
|
|
4
|
-
"""{{ enum.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
2
|
+
class {{ enum.name }}({{ enum.value_type.type_annotation(is_operation_file=False) }}, Enum, metaclass=CaseInsensitiveEnumMeta):
|
|
3
|
+
{% if enum.yaml_data.get("description") %}
|
|
4
|
+
"""{{ enum.yaml_data["description"] | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
5
5
|
"""
|
|
6
6
|
{% endif %}
|
|
7
7
|
|
|
@@ -9,5 +9,5 @@ class {{ enum.name }}(with_metaclass(CaseInsensitiveEnumMeta, {{ enum.enum_type.
|
|
|
9
9
|
{% if value.description %}
|
|
10
10
|
#: {{ value.description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n #: ') }}
|
|
11
11
|
{% endif %}
|
|
12
|
-
{{ value.name }} = {{ enum.
|
|
12
|
+
{{ value.name }} = {{ enum.value_type.get_declaration(value.value) }}
|
|
13
13
|
{% endfor %}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
{{ code_model.options['license_header'] }}
|
|
3
3
|
|
|
4
4
|
from enum import Enum
|
|
5
|
-
from six import with_metaclass
|
|
6
5
|
from azure.core import CaseInsensitiveEnumMeta
|
|
7
6
|
|
|
8
|
-
{% for enum in code_model.enums
|
|
7
|
+
{% for enum in code_model.enums | sort %}
|
|
9
8
|
{% include "enum.py.jinja2" %}
|
|
10
9
|
{% endfor %}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
{% import 'keywords.jinja2' as keywords %}
|
|
1
2
|
# coding=utf-8
|
|
2
3
|
{{ code_model.options['license_header'] }}
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
{% if code_model.request_builders %}
|
|
6
|
+
from .{{ code_model.client.filename }} import {{ code_model.client.name }}
|
|
7
|
+
{% endif %}
|
|
5
8
|
{% if not async_mode and code_model.options['package_version']%}
|
|
6
9
|
from ._version import VERSION
|
|
7
10
|
|
|
8
11
|
__version__ = VERSION
|
|
9
12
|
{% endif %}
|
|
10
|
-
__all__ = ['{{ code_model.class_name }}']
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
{{ keywords.patch_imports(try_except=True) }}
|
|
15
|
+
__all__ = [{{("'" + code_model.client.name + "'") if code_model.request_builders else ""}}]
|
|
16
|
+
{{ keywords.extend_all }}
|
|
17
|
+
|
|
18
|
+
_patch_sdk()
|
|
@@ -3,4 +3,17 @@
|
|
|
3
3
|
{% set await = "await " if async_mode else "" %}
|
|
4
4
|
{% set async_class = "Async" if async_mode else "" %}
|
|
5
5
|
{% macro escape_str(s) %}'{{ s|replace("'", "\\'") }}'{% endmacro %}
|
|
6
|
-
{% set kwargs_declaration = "**kwargs: Any" if async_mode else "**kwargs # type: Any" %}
|
|
6
|
+
{% set kwargs_declaration = "**kwargs: Any" if async_mode else "**kwargs # type: Any" %}
|
|
7
|
+
{% set extend_all = "__all__.extend([p for p in _patch_all if p not in __all__])" %}
|
|
8
|
+
{% macro patch_imports(try_except=False) %}
|
|
9
|
+
{% set indentation = " " if try_except else "" %}
|
|
10
|
+
{% if try_except %}
|
|
11
|
+
try:
|
|
12
|
+
{% endif %}
|
|
13
|
+
{{ indentation }}from ._patch import __all__ as _patch_all
|
|
14
|
+
{{ indentation }}from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
|
|
15
|
+
{% if try_except %}
|
|
16
|
+
except ImportError:
|
|
17
|
+
_patch_all = []
|
|
18
|
+
{% endif %}
|
|
19
|
+
from ._patch import patch_sdk as _patch_sdk{% endmacro %}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
2
|
-
{% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %}
|
|
3
2
|
{# actual template starts here #}
|
|
4
|
-
{% if
|
|
5
|
-
{{
|
|
3
|
+
{% if operation.overloads and operation.public %}
|
|
4
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
6
5
|
{% endif %}
|
|
7
6
|
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
8
7
|
{{ op_tools.description(operation, operation_serializer) | indent -}}
|
|
9
|
-
{% if operation.
|
|
8
|
+
{% if not operation.abstract %}
|
|
9
|
+
{% if operation_serializer.pop_kwargs_from_signature(operation) %}
|
|
10
10
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
11
|
-
|
|
11
|
+
{%- endif %}
|
|
12
12
|
{{ op_tools.serialize(operation_serializer.initial_call(operation)) | indent }}
|
|
13
13
|
{{ op_tools.serialize(operation_serializer.get_long_running_output(operation)) | indent }}
|
|
14
14
|
|
|
15
15
|
{{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
|
|
16
|
+
{% endif %}
|
|
16
17
|
{% if not code_model.options["version_tolerant"] %}
|
|
17
18
|
{{ operation_serializer.get_metadata_url(operation) -}}
|
|
18
19
|
{% endif %}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
2
2
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
3
|
-
{% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %}
|
|
4
3
|
{# actual template starts here #}
|
|
5
|
-
{% if
|
|
6
|
-
{{
|
|
4
|
+
{% if operation.overloads and operation.public %}
|
|
5
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
7
6
|
{% endif %}
|
|
8
7
|
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
9
8
|
{{ op_tools.description(operation, operation_serializer) | indent }}
|
|
10
|
-
{% if operation.
|
|
9
|
+
{% if not operation.abstract %}
|
|
10
|
+
{% if operation_serializer.pop_kwargs_from_signature(operation) %}
|
|
11
11
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
12
|
-
|
|
12
|
+
{% endif %}
|
|
13
13
|
{{ op_tools.serialize(operation_serializer.set_up_params_for_pager(operation)) | indent }}
|
|
14
14
|
|
|
15
15
|
{{ op_tools.serialize(operation_serializer.initial_call(operation)) | indent }}
|
|
16
16
|
{{ op_tools.serialize(operation_serializer.get_long_running_output(operation)) | indent }}
|
|
17
17
|
{{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
|
|
18
|
+
{% endif %}
|
|
18
19
|
{% if not code_model.options["version_tolerant"] %}
|
|
19
20
|
{{ operation_serializer.get_metadata_url(operation) }}
|
|
20
21
|
{% endif %}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
2
|
{% import 'keywords.jinja2' as keywords %}
|
|
3
|
-
{% set
|
|
3
|
+
{% set client = code_model.client %}
|
|
4
4
|
{
|
|
5
5
|
"chosen_version": {{ chosen_version | tojson }},
|
|
6
6
|
"total_api_version_list": {{ total_api_version_list | tojson }},
|
|
7
7
|
"client": {
|
|
8
|
-
"name": {{ code_model.
|
|
8
|
+
"name": {{ code_model.client.name | tojson }},
|
|
9
9
|
"filename": {{ ("_" + code_model.module_name) | tojson }},
|
|
10
|
-
"description": {{ code_model.description | tojson }},
|
|
11
|
-
"host_value": {{ (
|
|
12
|
-
"parameterized_host_template": {{ (keywords.escape_str(
|
|
10
|
+
"description": {{ code_model.client.description | tojson }},
|
|
11
|
+
"host_value": {{ (client.parameters.host.client_default_value_declaration if not client.has_parameterized_host else None) | tojson }},
|
|
12
|
+
"parameterized_host_template": {{ (keywords.escape_str(client.url) if client.has_parameterized_host else None) | tojson }},
|
|
13
13
|
"azure_arm": {{ code_model.options["azure_arm"] | tojson }},
|
|
14
14
|
"has_lro_operations": {{ code_model.has_lro_operations | tojson }},
|
|
15
15
|
"client_side_validation": {{ code_model.options["client_side_validation"] | tojson }},
|
|
@@ -18,31 +18,31 @@
|
|
|
18
18
|
},
|
|
19
19
|
"global_parameters": {
|
|
20
20
|
"sync": {
|
|
21
|
-
{% for gp in
|
|
22
|
-
{{ gp.
|
|
23
|
-
"signature": {{ gp.method_signature(is_python3_file=False) | tojson }},
|
|
21
|
+
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
22
|
+
{{ gp.client_name | tojson }}: {
|
|
23
|
+
"signature": {{ gp.method_signature(is_python3_file=False, async_mode=False) | tojson }},
|
|
24
24
|
"description": {{ gp.description | tojson }},
|
|
25
|
-
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
26
|
-
"required": {{ gp.
|
|
25
|
+
"docstring_type": {{ gp.docstring_type(async_mode=False) | tojson }},
|
|
26
|
+
"required": {{ (not gp.optional) | tojson }}
|
|
27
27
|
}{{ "," if not loop.last else "" }}
|
|
28
28
|
{% endfor %}
|
|
29
29
|
},
|
|
30
30
|
"async": {
|
|
31
|
-
{% for gp in
|
|
32
|
-
{{ gp.
|
|
33
|
-
"signature": {{ (gp.method_signature(is_python3_file=True)) | tojson }},
|
|
31
|
+
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
32
|
+
{{ gp.client_name | tojson }}: {
|
|
33
|
+
"signature": {{ (gp.method_signature(is_python3_file=True, async_mode=True)) | tojson }},
|
|
34
34
|
"description": {{ gp.description | tojson }},
|
|
35
|
-
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
36
|
-
"required": {{ gp.
|
|
35
|
+
"docstring_type": {{ gp.docstring_type(async_mode=True) | tojson }},
|
|
36
|
+
"required": {{ (not gp.optional) | tojson }}
|
|
37
37
|
}{{ "," if not loop.last else "" }}
|
|
38
38
|
{% endfor %}
|
|
39
39
|
},
|
|
40
40
|
"constant": {
|
|
41
|
-
{% for gp in code_model.
|
|
42
|
-
{{ gp.
|
|
41
|
+
{% for gp in code_model.client.parameters.constant | rejectattr("client_name", "equalto", "api_version") %}
|
|
42
|
+
{{ gp.client_name | tojson }}: {{ gp.constant_declaration | tojson }}{{ "," if not loop.last else "" }}
|
|
43
43
|
{% endfor %}
|
|
44
44
|
},
|
|
45
|
-
"call": {{ code_model.
|
|
45
|
+
"call": {{ code_model.client.parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") | map(attribute="client_name") | join(', ') | tojson }},
|
|
46
46
|
"service_client_specific": {
|
|
47
47
|
"sync": {
|
|
48
48
|
"api_version": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"docstring_type": "str",
|
|
52
52
|
"required": false
|
|
53
53
|
},
|
|
54
|
-
{% if not
|
|
54
|
+
{% if not client.has_parameterized_host %}
|
|
55
55
|
"base_url": {
|
|
56
|
-
"signature": {{
|
|
56
|
+
"signature": {{ client.parameters.host.method_signature(False, async_mode=False) | tojson }},
|
|
57
57
|
"description": "Service URL",
|
|
58
58
|
"docstring_type": "str",
|
|
59
59
|
"required": false
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"docstring_type": "str",
|
|
74
74
|
"required": false
|
|
75
75
|
},
|
|
76
|
-
{% if not
|
|
76
|
+
{% if not client.has_parameterized_host %}
|
|
77
77
|
"base_url": {
|
|
78
|
-
"signature": {{
|
|
78
|
+
"signature": {{ client.parameters.host.method_signature(True, async_mode=True) | tojson }},
|
|
79
79
|
"description": "Service URL",
|
|
80
80
|
"docstring_type": "str",
|
|
81
81
|
"required": false
|
|
@@ -91,16 +91,16 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"config": {
|
|
94
|
-
"credential": {{
|
|
95
|
-
"credential_scopes": {{ (code_model.
|
|
96
|
-
"credential_call_sync": {{ (code_model.
|
|
97
|
-
"credential_call_async": {{ (code_model.
|
|
94
|
+
"credential": {{ has_credential | tojson }},
|
|
95
|
+
"credential_scopes": {{ (code_model.credential.type.policy.credential_scopes if has_credential and code_model.credential.type.policy.credential_scopes is defined else None)| tojson}},
|
|
96
|
+
"credential_call_sync": {{ (code_model.credential.type.policy.call(async_mode=False) if has_credential else None) | tojson }},
|
|
97
|
+
"credential_call_async": {{ (code_model.credential.type.policy.call(async_mode=True) if has_credential else None) | tojson }},
|
|
98
98
|
"sync_imports": {{ sync_config_imports | tojson }},
|
|
99
99
|
"async_imports": {{ async_config_imports | tojson }}
|
|
100
100
|
},
|
|
101
101
|
"operation_groups": {
|
|
102
|
-
{% for operation_group in code_model.operation_groups | rejectattr('
|
|
103
|
-
{{ operation_group.
|
|
102
|
+
{% for operation_group in code_model.operation_groups | rejectattr('is_mixin') %}
|
|
103
|
+
{{ operation_group.property_name | tojson }}: {{ operation_group.class_name | tojson }}{{ "," if not loop.last else "" }}
|
|
104
104
|
{% endfor %}
|
|
105
105
|
}{{ "," if mixin_operations }}
|
|
106
106
|
{% if mixin_operations %}
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"async_imports": {{ str(async_mixin_imports) | tojson }},
|
|
110
110
|
"operations": {
|
|
111
111
|
{% for operation in mixin_operations %}
|
|
112
|
-
{{ operation.
|
|
112
|
+
{{ operation.name | tojson }} : {
|
|
113
113
|
{% set request_builder = operation.request_builder %}
|
|
114
114
|
"sync": {
|
|
115
115
|
{% set operation_serializer = get_sync_operation_serializer(operation) %}
|
|
@@ -126,8 +126,9 @@
|
|
|
126
126
|
{% from "operation.py.jinja2" import operation_docstring with context %}
|
|
127
127
|
{% set sync_return_type_wrapper = "" %}
|
|
128
128
|
{% endif %}
|
|
129
|
-
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation) + "\n") | tojson }},
|
|
130
|
-
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }}
|
|
129
|
+
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation, want_decorators=False) + "\n") | tojson }},
|
|
130
|
+
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }},
|
|
131
|
+
"call": {{ operation.parameters.call | join(', ') | tojson }}
|
|
131
132
|
},
|
|
132
133
|
"async": {
|
|
133
134
|
{% set coroutine = False if (is_paging(operation) and not is_lro(operation)) else True %}
|
|
@@ -146,10 +147,10 @@
|
|
|
146
147
|
{% from "operation.py.jinja2" import operation_docstring with context %}
|
|
147
148
|
{% set async_return_type_wrapper = "" %}
|
|
148
149
|
{% endif %}
|
|
149
|
-
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation) + "\n") | tojson }},
|
|
150
|
-
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }}
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation, want_decorators=False) + "\n") | tojson }},
|
|
151
|
+
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }},
|
|
152
|
+
"call": {{ operation.parameters.call | join(', ') | tojson }}
|
|
153
|
+
}
|
|
153
154
|
}{{ "," if not loop.last else "" }}
|
|
154
155
|
{% endfor %}
|
|
155
156
|
}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
{% set basename = model.base_models | join(', ', attribute='name') if model.base_models else "" %}
|
|
2
1
|
{# actual template starts here #}
|
|
3
2
|
|
|
4
3
|
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
{%
|
|
8
|
-
class {{ model.name }}(msrest.serialization.Model):
|
|
9
|
-
{% endif %}
|
|
10
|
-
"""{{ model.description }}
|
|
11
|
-
{% if model.discriminator_name %}
|
|
4
|
+
{{ serializer.declare_model(model) }}
|
|
5
|
+
"""{{ model.description(is_operation_file=False) }}
|
|
6
|
+
{% if model.discriminated_subtypes %}
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
sub-classes are: {{ model.subtype_map.values()|join(', ') }}.
|
|
8
|
+
{{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
15
9
|
{% endif %}
|
|
16
10
|
{% if model.has_readonly_or_constant_property %}
|
|
17
11
|
|
|
18
12
|
Variables are only populated by the server, and will be ignored when sending a request.
|
|
19
13
|
{% endif %}
|
|
20
|
-
{% if (model.properties | selectattr('
|
|
14
|
+
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
21
15
|
|
|
22
16
|
All required parameters must be populated in order to send to Azure.
|
|
23
17
|
{% endif %}
|
|
24
18
|
|
|
25
19
|
{% if model.properties != None %}
|
|
26
20
|
{% for p in model.properties %}
|
|
27
|
-
{% for line in variable_documentation_string(p) %}
|
|
21
|
+
{% for line in serializer.variable_documentation_string(p) %}
|
|
28
22
|
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
|
|
29
23
|
{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
30
24
|
{% endfor %}
|
|
@@ -32,45 +26,44 @@ class {{ model.name }}(msrest.serialization.Model):
|
|
|
32
26
|
{% endfor %}
|
|
33
27
|
{% endif %}
|
|
34
28
|
"""
|
|
35
|
-
{% if (model.properties | selectattr('
|
|
29
|
+
{% if (model.properties | selectattr('validation') ) | first %}
|
|
36
30
|
|
|
37
31
|
_validation = {
|
|
38
|
-
{% for p in model.properties | selectattr('
|
|
39
|
-
'{{ p.
|
|
32
|
+
{% for p in model.properties | selectattr('validation')%}
|
|
33
|
+
'{{ p.client_name }}': {{ str(p.validation) }},
|
|
40
34
|
{% endfor %}
|
|
41
35
|
}
|
|
42
36
|
{% endif %}
|
|
43
37
|
|
|
44
38
|
_attribute_map = {
|
|
45
|
-
{% if model.properties
|
|
39
|
+
{% if model.properties %}
|
|
46
40
|
{% for p in model.properties %}
|
|
47
|
-
|
|
41
|
+
{{ p.attribute_map }}
|
|
48
42
|
{% endfor %}
|
|
49
|
-
{% else%}
|
|
50
43
|
{% endif %}
|
|
51
44
|
}
|
|
52
|
-
{% if model.
|
|
45
|
+
{% if model.discriminated_subtypes %}
|
|
53
46
|
|
|
54
47
|
_subtype_map = {
|
|
55
|
-
'{{ model.
|
|
48
|
+
'{{ model.discriminator.client_name }}': {{ str(model.discriminated_subtypes) }}
|
|
56
49
|
}
|
|
57
50
|
{% endif %}
|
|
58
|
-
{% if model.
|
|
51
|
+
{% if model.xml_map_content %}
|
|
59
52
|
_xml_map = {
|
|
60
|
-
{{ model.xml_map_content
|
|
53
|
+
{{ model.xml_map_content }}
|
|
61
54
|
}
|
|
62
55
|
{% endif %}
|
|
63
56
|
{% if (model.properties | selectattr('constant') | first) is defined %}
|
|
64
57
|
|
|
65
58
|
{% for p in model.properties | selectattr('constant')%}
|
|
66
|
-
{{ p.
|
|
59
|
+
{{ p.client_name }} = {{ p.type.get_declaration() }}
|
|
67
60
|
{% endfor %}
|
|
68
61
|
{% endif %}
|
|
69
62
|
|
|
70
|
-
def __init__(
|
|
63
|
+
def __init__({{ model.init_pylint_disable }}
|
|
71
64
|
self,
|
|
72
|
-
{% for param_signature in init_line(model) %}
|
|
73
|
-
{{ param_signature }}
|
|
65
|
+
{% for param_signature in serializer.init_line(model) %}
|
|
66
|
+
{{ param_signature }}
|
|
74
67
|
{% endfor %}
|
|
75
68
|
**kwargs
|
|
76
69
|
):
|
|
@@ -78,7 +71,7 @@ class {{ model.name }}(msrest.serialization.Model):
|
|
|
78
71
|
{% if model.properties %}
|
|
79
72
|
{% for p in model.properties %}
|
|
80
73
|
{% if p.is_input %}
|
|
81
|
-
{% for line in input_documentation_string(p) %}
|
|
74
|
+
{% for line in serializer.input_documentation_string(p) %}
|
|
82
75
|
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
|
|
83
76
|
{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
84
77
|
{% endfor %}
|
|
@@ -87,6 +80,7 @@ class {{ model.name }}(msrest.serialization.Model):
|
|
|
87
80
|
{% endfor %}
|
|
88
81
|
{% endif %}
|
|
89
82
|
"""
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
{{ serializer.super_call(model) }}
|
|
84
|
+
{% for initialize_property in serializer.initialize_properties(model) %}
|
|
85
|
+
{{ initialize_property }}
|
|
92
86
|
{% endfor %}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
{% import 'keywords.jinja2' as keywords %}
|
|
1
2
|
# coding=utf-8
|
|
2
3
|
{{ code_model.options['license_header'] }}
|
|
3
4
|
{% macro iterate_models_py3() %}
|
|
4
5
|
{% for schema in schemas %}
|
|
5
|
-
from .
|
|
6
|
+
from .{{ code_model.get_models_filename(is_python3_file=True) }} import {{ schema }}
|
|
6
7
|
{% endfor %}
|
|
7
8
|
{% endmacro %}
|
|
8
9
|
|
|
@@ -14,19 +15,17 @@ try:
|
|
|
14
15
|
{{ iterate_models_py3() | indent-}}
|
|
15
16
|
except (SyntaxError, ImportError):
|
|
16
17
|
{% for schema in schemas %}
|
|
17
|
-
from .
|
|
18
|
+
from .{{ code_model.get_models_filename(is_python3_file=False) }} import {{ schema }} # type: ignore
|
|
18
19
|
{% endfor %}
|
|
19
20
|
{% endif %}
|
|
20
21
|
{% endif %}
|
|
21
22
|
{% if enums %}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{% endfor %}
|
|
27
|
-
)
|
|
24
|
+
{% for enum in enums %}
|
|
25
|
+
from .{{ code_model.enums_filename }} import {{ enum }}
|
|
26
|
+
{% endfor %}
|
|
28
27
|
{% endif %}
|
|
29
|
-
|
|
28
|
+
{{ keywords.patch_imports() }}
|
|
30
29
|
__all__ = [
|
|
31
30
|
{% for schema in schemas %}
|
|
32
31
|
'{{ schema }}',
|
|
@@ -37,3 +36,5 @@ __all__ = [
|
|
|
37
36
|
{% endfor %}
|
|
38
37
|
{% endif %}
|
|
39
38
|
]
|
|
39
|
+
{{ keywords.extend_all }}
|
|
40
|
+
_patch_sdk()
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
3
|
-
{% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %}
|
|
4
|
-
{% set stream_request_parameter = "stream=" ~ ("True" if operation.is_stream_response else "False") %}
|
|
5
3
|
{# actual template starts here #}
|
|
6
|
-
{
|
|
7
|
-
{{
|
|
4
|
+
{% if operation.overloads and operation.public %}
|
|
5
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
8
6
|
{% endif %}
|
|
9
7
|
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
10
|
-
{% if operation.
|
|
8
|
+
{% if operation.public %}
|
|
11
9
|
{{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
|
|
12
|
-
|
|
13
|
-
{% if operation.deprecated %}
|
|
10
|
+
{% if not operation.abstract %}
|
|
11
|
+
{% if operation.deprecated %}
|
|
14
12
|
warnings.warn('Method {{operation.name}} is deprecated', DeprecationWarning)
|
|
15
|
-
{% endif %}
|
|
13
|
+
{% endif %}
|
|
16
14
|
{{ op_tools.serialize(operation_serializer.error_map(operation)) | indent }}
|
|
17
|
-
|
|
15
|
+
{% if operation_serializer.pop_kwargs_from_signature(operation) %}
|
|
18
16
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
19
|
-
|
|
17
|
+
{% endif %}
|
|
20
18
|
{{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }}
|
|
21
|
-
|
|
22
|
-
request,
|
|
23
|
-
{{ stream_request_parameter }},
|
|
24
|
-
**kwargs
|
|
25
|
-
)
|
|
19
|
+
{{ op_tools.serialize(operation_serializer.make_pipeline_call(operation)) | indent }}
|
|
26
20
|
{{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
|
|
21
|
+
{% endif %}
|
|
27
22
|
{% if not code_model.options["version_tolerant"] %}
|
|
28
23
|
{{ operation_serializer.get_metadata_url(operation) }}
|
|
29
24
|
{% endif %}
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
{% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
|
|
2
|
-
|
|
3
|
-
{
|
|
2
|
+
{% set base_class = ("(" + operation_group.base_class(async_mode) + ")") if operation_group.base_class(async_mode) else "" %}
|
|
3
|
+
class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
4
|
+
{% if not operation_group.is_mixin %}
|
|
4
5
|
"""
|
|
5
6
|
.. warning::
|
|
6
7
|
**DO NOT** instantiate this class directly.
|
|
7
8
|
|
|
8
9
|
Instead, you should access the following operations through
|
|
9
|
-
:class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.
|
|
10
|
-
:attr:`{{ operation_group.
|
|
10
|
+
:class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.client.name }}`'s
|
|
11
|
+
:attr:`{{ operation_group.property_name }}` attribute.
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
|
-
{% if code_model.
|
|
14
|
+
{% if code_model.public_model_types and code_model.options["models_mode"] %}
|
|
14
15
|
models = _models
|
|
15
16
|
|
|
16
17
|
{% endif %}
|
|
17
18
|
def __init__(self, *args, **kwargs){{ return_none_type_annotation }}:
|
|
18
|
-
|
|
19
|
-
self._client =
|
|
20
|
-
self._config =
|
|
21
|
-
self._serialize =
|
|
22
|
-
self._deserialize =
|
|
19
|
+
input_args = list(args)
|
|
20
|
+
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
21
|
+
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
22
|
+
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
23
|
+
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
23
24
|
|
|
24
25
|
{% endif %}
|
|
25
26
|
{% for operation in operation_group.operations %}
|
|
26
27
|
|
|
27
28
|
{% set request_builder = operation.request_builder %}
|
|
28
29
|
{% set operation_serializer = get_operation_serializer(operation) %}
|
|
29
|
-
{% if
|
|
30
|
+
{% if operation.operation_type == "lropaging" %}
|
|
30
31
|
{%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %}
|
|
31
|
-
{% elif
|
|
32
|
+
{% elif operation.operation_type == "lro" %}
|
|
32
33
|
{%- macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %}
|
|
33
|
-
{% elif
|
|
34
|
+
{% elif operation.operation_type == "paging" %}
|
|
34
35
|
{% macro someop() %}{% include "paging_operation.py.jinja2" %}{% endmacro %}
|
|
35
36
|
{% else %}
|
|
36
37
|
{% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
|
-
{% set object_base_class = "" if async_mode else "(object)" %}
|
|
3
2
|
{% set operations_description = "async operations" if async_mode else "operations" %}
|
|
4
3
|
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
5
4
|
# pylint: disable=too-many-lines
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
# fmt: off
|
|
14
13
|
{% endif %}
|
|
15
14
|
{% for operation_group in operation_groups %}
|
|
16
|
-
{% for request_builder in code_model.
|
|
15
|
+
{% for request_builder in code_model.request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
|
|
17
16
|
|
|
18
17
|
{% include "request_builder.py.jinja2" %}
|
|
19
18
|
{% endfor %}
|