@autorest/python 6.2.0 → 6.2.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/autorest/codegen/__init__.py +9 -74
- package/autorest/codegen/models/__init__.py +11 -12
- package/autorest/codegen/models/{base_type.py → base.py} +29 -10
- package/autorest/codegen/models/base_builder.py +8 -10
- package/autorest/codegen/models/client.py +111 -40
- package/autorest/codegen/models/code_model.py +131 -90
- package/autorest/codegen/models/combined_type.py +7 -7
- package/autorest/codegen/models/constant_type.py +44 -10
- package/autorest/codegen/models/credential_types.py +17 -19
- package/autorest/codegen/models/dictionary_type.py +7 -9
- package/autorest/codegen/models/enum_type.py +19 -24
- package/autorest/codegen/models/imports.py +82 -33
- package/autorest/codegen/models/list_type.py +11 -15
- package/autorest/codegen/models/lro_operation.py +6 -10
- package/autorest/codegen/models/model_type.py +20 -21
- package/autorest/codegen/models/operation.py +49 -42
- package/autorest/codegen/models/operation_group.py +11 -11
- package/autorest/codegen/models/paging_operation.py +8 -10
- package/autorest/codegen/models/parameter.py +44 -31
- package/autorest/codegen/models/parameter_list.py +16 -22
- package/autorest/codegen/models/primitive_types.py +12 -23
- package/autorest/codegen/models/property.py +11 -11
- package/autorest/codegen/models/request_builder.py +19 -19
- package/autorest/codegen/models/request_builder_parameter.py +14 -16
- package/autorest/codegen/models/response.py +24 -28
- package/autorest/codegen/serializers/__init__.py +202 -187
- package/autorest/codegen/serializers/builder_serializer.py +46 -49
- package/autorest/codegen/serializers/client_serializer.py +9 -7
- package/autorest/codegen/serializers/enum_serializer.py +4 -4
- package/autorest/codegen/serializers/general_serializer.py +26 -36
- package/autorest/codegen/serializers/import_serializer.py +30 -36
- package/autorest/codegen/serializers/metadata_serializer.py +35 -17
- package/autorest/codegen/serializers/model_init_serializer.py +6 -10
- package/autorest/codegen/serializers/model_serializer.py +42 -27
- package/autorest/codegen/serializers/operation_groups_serializer.py +12 -8
- package/autorest/codegen/serializers/operations_init_serializer.py +13 -6
- package/autorest/codegen/serializers/patch_serializer.py +4 -4
- package/autorest/codegen/serializers/request_builders_serializer.py +6 -6
- package/autorest/codegen/serializers/sample_serializer.py +10 -12
- package/autorest/codegen/templates/client_container.py.jinja2 +2 -2
- package/autorest/codegen/templates/config.py.jinja2 +1 -1
- package/autorest/codegen/templates/config_container.py.jinja2 +3 -3
- package/autorest/codegen/templates/enum_container.py.jinja2 +2 -2
- package/autorest/codegen/templates/init.py.jinja2 +2 -2
- package/autorest/codegen/templates/lro_operation.py.jinja2 +1 -1
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +1 -1
- package/autorest/codegen/templates/metadata.json.jinja2 +2 -2
- package/autorest/codegen/templates/model_container.py.jinja2 +3 -3
- package/autorest/codegen/templates/model_dpg.py.jinja2 +4 -4
- package/autorest/codegen/templates/model_init.py.jinja2 +3 -3
- package/autorest/codegen/templates/operation.py.jinja2 +1 -1
- package/autorest/codegen/templates/operation_group.py.jinja2 +2 -2
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +3 -3
- package/autorest/codegen/templates/operation_tools.jinja2 +3 -3
- package/autorest/codegen/templates/operations_folder_init.py.jinja2 +4 -4
- package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +4 -1
- package/autorest/codegen/templates/paging_operation.py.jinja2 +1 -1
- package/autorest/codegen/templates/request_builder.py.jinja2 +1 -1
- package/autorest/codegen/templates/request_builders.py.jinja2 +2 -2
- package/autorest/codegen/templates/rest_init.py.jinja2 +1 -1
- package/autorest/codegen/templates/sample.py.jinja2 +5 -5
- package/autorest/codegen/templates/validation.py.jinja2 +1 -1
- package/autorest/codegen/templates/vendor.py.jinja2 +6 -6
- package/autorest/codegen/templates/version.py.jinja2 +2 -2
- package/autorest/m4reformatter/__init__.py +7 -6
- package/autorest/multiapi/models/imports.py +89 -18
- package/autorest/multiapi/serializers/import_serializer.py +88 -7
- package/autorest/multiapi/utils.py +6 -0
- package/autorest/preprocess/__init__.py +23 -26
- package/package.json +1 -1
- package/run_cadl.py +0 -1
- package/autorest/cadlflags/__init__.py +0 -130
- package/autorest/codegen/models/base_model.py +0 -30
|
@@ -39,7 +39,7 @@ class {{ client.name }}Configuration(Configuration): # pylint: disable=too-many
|
|
|
39
39
|
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
|
|
40
40
|
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
|
|
41
41
|
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
|
|
42
|
-
self.http_logging_policy = kwargs.get('http_logging_policy') or {{ "ARM" if client.
|
|
42
|
+
self.http_logging_policy = kwargs.get('http_logging_policy') or {{ "ARM" if client.code_model.options['azure_arm'] else "policies." }}HttpLoggingPolicy(**kwargs)
|
|
43
43
|
self.retry_policy = kwargs.get('retry_policy') or policies.{{ keywords.async_class }}RetryPolicy(**kwargs)
|
|
44
44
|
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
|
|
45
45
|
self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ keywords.async_class }}RedirectPolicy(**kwargs)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
3
3
|
{# actual template starts here #}
|
|
4
4
|
# coding=utf-8
|
|
5
|
-
{{
|
|
5
|
+
{{ code_model.options['license_header'] }}
|
|
6
6
|
|
|
7
7
|
{{ imports }}
|
|
8
8
|
|
|
9
|
-
{% if not
|
|
9
|
+
{% if not code_model.options['package_version'] %}
|
|
10
10
|
VERSION = "unknown"
|
|
11
11
|
{% endif %}
|
|
12
12
|
|
|
13
|
-
{% for client in
|
|
13
|
+
{% for client in clients %}
|
|
14
14
|
{% set serializer = get_serializer(client) %}
|
|
15
15
|
{% include "config.py.jinja2" %}
|
|
16
16
|
{% endfor %}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
|
-
{{
|
|
2
|
+
{{ code_model.options['license_header'] }}
|
|
3
3
|
|
|
4
4
|
from enum import Enum
|
|
5
5
|
from azure.core import CaseInsensitiveEnumMeta
|
|
6
6
|
|
|
7
|
-
{% for enum in
|
|
7
|
+
{% for enum in code_model.enums | sort %}
|
|
8
8
|
{% include "enum.py.jinja2" %}
|
|
9
9
|
{% endfor %}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords %}
|
|
2
2
|
# coding=utf-8
|
|
3
|
-
{{
|
|
3
|
+
{{ code_model.options['license_header'] }}
|
|
4
4
|
|
|
5
5
|
{% if clients %}
|
|
6
6
|
{% for client in clients %}
|
|
7
7
|
from .{{ client.filename }} import {{ client.name }}
|
|
8
8
|
{% endfor %}
|
|
9
9
|
{% endif %}
|
|
10
|
-
{% if not async_mode and
|
|
10
|
+
{% if not async_mode and code_model.options['package_version']%}
|
|
11
11
|
from ._version import VERSION
|
|
12
12
|
|
|
13
13
|
__version__ = VERSION
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
{{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
|
|
16
16
|
{% endif %}
|
|
17
|
-
{% if not
|
|
17
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
18
18
|
{{ operation_serializer.get_metadata_url(operation) -}}
|
|
19
19
|
{% endif %}
|
|
@@ -16,6 +16,6 @@
|
|
|
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
18
|
{% endif %}
|
|
19
|
-
{% if not
|
|
19
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
20
20
|
{{ operation_serializer.get_metadata_url(operation) }}
|
|
21
21
|
{% endif %}
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"description": {{ client.description | tojson }},
|
|
10
10
|
"host_value": {{ (client.parameters.host.client_default_value_declaration if not client.has_parameterized_host else None) | tojson }},
|
|
11
11
|
"parameterized_host_template": {{ (keywords.escape_str(client.url) if client.has_parameterized_host else None) | tojson }},
|
|
12
|
-
"azure_arm": {{ client.
|
|
12
|
+
"azure_arm": {{ client.code_model.options["azure_arm"] | tojson }},
|
|
13
13
|
"has_lro_operations": {{ client.has_lro_operations | tojson }},
|
|
14
|
-
"client_side_validation": {{ client.
|
|
14
|
+
"client_side_validation": {{ client.code_model.options["client_side_validation"] | tojson }},
|
|
15
15
|
"sync_imports": {{ sync_client_imports | tojson }},
|
|
16
16
|
"async_imports": {{ async_client_imports | tojson }}
|
|
17
17
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
# pylint: disable=too-many-lines
|
|
3
|
-
{{
|
|
3
|
+
{{ code_model.options['license_header'] }}
|
|
4
4
|
|
|
5
5
|
{{ imports }}
|
|
6
|
-
{% for model in
|
|
7
|
-
{% if
|
|
6
|
+
{% for model in code_model.model_types %}
|
|
7
|
+
{% if code_model.options["models_mode"] == "dpg" %}
|
|
8
8
|
{% include "model_dpg.py.jinja2" %}
|
|
9
9
|
{% else %}
|
|
10
10
|
{% include "model_msrest.py.jinja2" %}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
{% if model.is_polymorphic %}
|
|
31
31
|
__mapping__ = {}
|
|
32
32
|
{% endif %}
|
|
33
|
-
{% for p in serializer.
|
|
33
|
+
{% for p in serializer.get_properties_to_declare(model)%}
|
|
34
34
|
{% for line in serializer.declare_property(p) %}
|
|
35
35
|
{{ line }}
|
|
36
36
|
{% endfor %}
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
{% endif %}
|
|
58
58
|
def __init__(self, *args, **kwargs):
|
|
59
59
|
super().__init__(*args, **kwargs)
|
|
60
|
-
{%
|
|
61
|
-
{{
|
|
62
|
-
{%
|
|
60
|
+
{% for initialize_property in serializer.initialize_properties(model) %}
|
|
61
|
+
{{ initialize_property }}
|
|
62
|
+
{% endfor %}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords %}
|
|
2
2
|
# coding=utf-8
|
|
3
|
-
{{
|
|
3
|
+
{{ code_model.options['license_header'] }}
|
|
4
4
|
{% if schemas %}
|
|
5
5
|
|
|
6
6
|
{% for schema in schemas %}
|
|
7
|
-
from .{{
|
|
7
|
+
from .{{ code_model.models_filename }} import {{ schema }}
|
|
8
8
|
{% endfor %}
|
|
9
9
|
{% endif %}
|
|
10
10
|
{% if enums %}
|
|
11
11
|
|
|
12
12
|
{% for enum in enums %}
|
|
13
|
-
from .{{
|
|
13
|
+
from .{{ code_model.enums_filename }} import {{ enum }}
|
|
14
14
|
{% endfor %}
|
|
15
15
|
{% endif %}
|
|
16
16
|
{{ keywords.patch_imports() }}
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
{{ op_tools.serialize(operation_serializer.make_pipeline_call(operation)) | indent }}
|
|
20
20
|
{{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
|
|
21
21
|
{% endif %}
|
|
22
|
-
{% if not
|
|
22
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
23
23
|
{{ operation_serializer.get_metadata_url(operation) }}
|
|
24
24
|
{% endif %}
|
|
@@ -16,11 +16,11 @@ class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
|
16
16
|
**DO NOT** instantiate this class directly.
|
|
17
17
|
|
|
18
18
|
Instead, you should access the following operations through
|
|
19
|
-
:class:`{{ "~" +
|
|
19
|
+
:class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + operation_group.client.name }}`'s
|
|
20
20
|
:attr:`{{ operation_group.property_name }}` attribute.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
{% if
|
|
23
|
+
{% if code_model.public_model_types and code_model.options["models_mode"] == "msrest" %}
|
|
24
24
|
models = _models
|
|
25
25
|
|
|
26
26
|
{% endif %}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
4
4
|
# pylint: disable=too-many-lines
|
|
5
5
|
# coding=utf-8
|
|
6
|
-
{{
|
|
6
|
+
{{ code_model.options['license_header'] }}
|
|
7
7
|
{{ imports }}
|
|
8
8
|
|
|
9
|
-
{% if
|
|
10
|
-
{{ op_tools.declare_serializer(
|
|
9
|
+
{% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
|
|
10
|
+
{{ op_tools.declare_serializer(code_model) }}
|
|
11
11
|
{% for operation_group in operation_groups %}
|
|
12
12
|
{% for request_builder in get_request_builders(operation_group) %}
|
|
13
13
|
|
|
@@ -50,10 +50,10 @@ Example:
|
|
|
50
50
|
{% endif %}
|
|
51
51
|
{% endfor %}{% endmacro %}
|
|
52
52
|
|
|
53
|
-
{% macro declare_serializer(
|
|
54
|
-
{% if
|
|
53
|
+
{% macro declare_serializer(code_model) %}
|
|
54
|
+
{% if code_model.has_non_abstract_operations %}
|
|
55
55
|
_SERIALIZER = Serializer()
|
|
56
|
-
{% if not
|
|
56
|
+
{% if not code_model.options["client_side_validation"] %}
|
|
57
57
|
_SERIALIZER.client_side_validation = False
|
|
58
58
|
{% endif %}
|
|
59
59
|
{% endif %}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
{% import 'keywords.jinja2' as keywords %}
|
|
3
3
|
{# actual template starts here #}
|
|
4
4
|
# coding=utf-8
|
|
5
|
-
{{
|
|
5
|
+
{{ code_model.options['license_header'] }}
|
|
6
6
|
|
|
7
7
|
{{ op_tools.serialize(operation_group_imports()) }}
|
|
8
8
|
{{ keywords.patch_imports() }}
|
|
9
|
-
{% if namespace_model.operation_groups %}
|
|
10
9
|
__all__ = [
|
|
11
|
-
{% for
|
|
10
|
+
{% for client in clients %}
|
|
11
|
+
{% for operation_group in client.operation_groups %}
|
|
12
12
|
'{{ operation_group.class_name }}',
|
|
13
|
+
{% endfor %}
|
|
13
14
|
{% endfor %}
|
|
14
15
|
]
|
|
15
|
-
{% endif %}
|
|
16
16
|
{{ keywords.extend_all }}
|
|
17
17
|
_patch_sdk()
|
|
@@ -7,7 +7,7 @@ import re
|
|
|
7
7
|
{% endif -%}
|
|
8
8
|
from setuptools import setup, find_packages
|
|
9
9
|
|
|
10
|
-
{% set package_name = package_name or code_model.
|
|
10
|
+
{% set package_name = package_name or code_model.clients[0].name %}
|
|
11
11
|
|
|
12
12
|
PACKAGE_NAME = "{{ package_name|lower }}"
|
|
13
13
|
{% if package_mode -%}
|
|
@@ -91,6 +91,9 @@ setup(
|
|
|
91
91
|
{% else %}
|
|
92
92
|
"azure-core<2.0.0,>=1.24.0",
|
|
93
93
|
{% endif %}
|
|
94
|
+
{% if code_model.need_typing_extensions %}
|
|
95
|
+
"typing_extensions>=4.3.0; python_version<'3.8.0'",
|
|
96
|
+
{% endif %}
|
|
94
97
|
],
|
|
95
98
|
{% if package_mode %}
|
|
96
99
|
python_requires=">=3.7",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
3
3
|
{{ request_builder_serializer.method_signature_and_response_type_annotation(request_builder) }}
|
|
4
|
-
{% if
|
|
4
|
+
{% if code_model.options["builders_visibility"] == "public" %}
|
|
5
5
|
{{ op_tools.description(request_builder, request_builder_serializer) | indent }}
|
|
6
6
|
{% endif %}
|
|
7
7
|
{% if not request_builder.is_overload %}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
2
|
# coding=utf-8
|
|
3
|
-
{{
|
|
3
|
+
{{ code_model.options['license_header'] }}
|
|
4
4
|
{{ imports }}
|
|
5
5
|
|
|
6
|
-
{{ op_tools.declare_serializer(
|
|
6
|
+
{{ op_tools.declare_serializer(code_model) }}
|
|
7
7
|
{% for request_builder in request_builders %}
|
|
8
8
|
|
|
9
9
|
{% include "request_builder.py.jinja2" %}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
{% set aad_token = "DefaultAzureCredential" %}
|
|
3
3
|
{% set azure_key = "AzureKeyCredential" %}
|
|
4
|
-
{{
|
|
4
|
+
{{ code_model.options['license_header'] }}
|
|
5
5
|
|
|
6
6
|
{{ imports }}
|
|
7
7
|
"""
|
|
@@ -9,23 +9,23 @@
|
|
|
9
9
|
{% if "credential" in client_params and aad_token in client_params["credential"] %}
|
|
10
10
|
pip install azure-identity
|
|
11
11
|
{% endif %}
|
|
12
|
-
pip install {{ (
|
|
12
|
+
pip install {{ (code_model.options["package_name"] or code_model.clients[0].name)|lower }}
|
|
13
13
|
# USAGE
|
|
14
14
|
python {{ file_name }}
|
|
15
15
|
{% if "credential" in client_params and aad_token in client_params["credential"] %}
|
|
16
16
|
|
|
17
|
-
Before run the sample, please set the values of the client ID, tenant ID and client secret
|
|
17
|
+
Before run the sample, please set the values of the client ID, tenant ID and client secret
|
|
18
18
|
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
|
|
19
19
|
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
|
|
20
20
|
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
|
|
21
21
|
{% elif "credential" in client_params and azure_key in client_params["credential"] %}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
Before run the sample, please set environment variables AZURE_KEY with real value
|
|
24
24
|
which can access your service
|
|
25
25
|
{% endif %}
|
|
26
26
|
"""
|
|
27
27
|
def main():
|
|
28
|
-
client = {{
|
|
28
|
+
client = {{ code_model.clients[0].name }}(
|
|
29
29
|
{% for key,value in client_params.items() %}
|
|
30
30
|
{{ key }}={{ value }},
|
|
31
31
|
{% endfor %}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
|
-
{{
|
|
2
|
+
{{ code_model.options['license_header'] }}
|
|
3
3
|
|
|
4
4
|
{{ imports }}
|
|
5
5
|
|
|
6
|
-
{% if
|
|
6
|
+
{% if code_model.need_request_converter and not async_mode %}
|
|
7
7
|
def _convert_request(request, files=None):
|
|
8
8
|
data = request.content if not files else None
|
|
9
9
|
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
|
|
@@ -11,7 +11,7 @@ def _convert_request(request, files=None):
|
|
|
11
11
|
request.set_formdata_body(files)
|
|
12
12
|
return request
|
|
13
13
|
{% endif %}
|
|
14
|
-
{% if
|
|
14
|
+
{% if code_model.need_format_url and not async_mode %}
|
|
15
15
|
|
|
16
16
|
def _format_url_section(template, **kwargs):
|
|
17
17
|
components = template.split("/")
|
|
@@ -25,8 +25,8 @@ def _format_url_section(template, **kwargs):
|
|
|
25
25
|
]
|
|
26
26
|
template = "/".join(components)
|
|
27
27
|
{% endif %}
|
|
28
|
-
{% if
|
|
29
|
-
{% for client in
|
|
28
|
+
{% if code_model.need_mixin_abc %}
|
|
29
|
+
{% for client in code_model.clients | selectattr("has_mixin") %}
|
|
30
30
|
|
|
31
31
|
class {{ client.name }}MixinABC(ABC):
|
|
32
32
|
"""DO NOT use this class. It is for internal typing use only."""
|
|
@@ -36,7 +36,7 @@ class {{ client.name }}MixinABC(ABC):
|
|
|
36
36
|
_deserialize: "Deserializer"
|
|
37
37
|
{% endfor %}
|
|
38
38
|
{% endif %}
|
|
39
|
-
{% if
|
|
39
|
+
{% if code_model.has_abstract_operations %}
|
|
40
40
|
|
|
41
41
|
def raise_if_not_implemented(cls, abstract_methods):
|
|
42
42
|
not_implemented = [f for f in abstract_methods if not callable(getattr(cls, f, None))]
|
|
@@ -1108,14 +1108,15 @@ class M4Reformatter(
|
|
|
1108
1108
|
# we don't generate cloud error
|
|
1109
1109
|
continue
|
|
1110
1110
|
update_type(t)
|
|
1111
|
-
yaml_data[namespace] =
|
|
1112
|
-
yaml_data[
|
|
1113
|
-
yaml_data[
|
|
1111
|
+
yaml_data["namespace"] = namespace
|
|
1112
|
+
yaml_data["subnamespaceToClients"] = {}
|
|
1113
|
+
yaml_data["clients"] = [self.update_client(yaml_data)]
|
|
1114
|
+
yaml_data["clients"][0]["operationGroups"] = [
|
|
1114
1115
|
self.update_operation_group(og) for og in yaml_data["operationGroups"]
|
|
1115
1116
|
]
|
|
1116
|
-
yaml_data[
|
|
1117
|
-
|
|
1118
|
-
)
|
|
1117
|
+
yaml_data["types"] = list(ORIGINAL_ID_TO_UPDATED_TYPE.values()) + list(
|
|
1118
|
+
KNOWN_TYPES.values()
|
|
1119
|
+
)
|
|
1119
1120
|
if yaml_data.get("globalParameters"):
|
|
1120
1121
|
del yaml_data["globalParameters"]
|
|
1121
1122
|
del yaml_data["info"]
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from typing import Dict, Optional, Set, Union, Tuple
|
|
8
|
+
from ..utils import convert_list_to_tuple
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class ImportType(str, Enum):
|
|
@@ -12,6 +13,7 @@ class ImportType(str, Enum):
|
|
|
12
13
|
THIRDPARTY = "thirdparty"
|
|
13
14
|
AZURECORE = "azurecore"
|
|
14
15
|
LOCAL = "local"
|
|
16
|
+
BYVERSION = "by_version"
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
class TypingSection(str, Enum):
|
|
@@ -25,7 +27,28 @@ class FileImport:
|
|
|
25
27
|
self,
|
|
26
28
|
imports: Dict[
|
|
27
29
|
TypingSection,
|
|
28
|
-
Dict[
|
|
30
|
+
Dict[
|
|
31
|
+
ImportType,
|
|
32
|
+
Dict[
|
|
33
|
+
str,
|
|
34
|
+
Set[
|
|
35
|
+
Optional[
|
|
36
|
+
Union[
|
|
37
|
+
str,
|
|
38
|
+
Tuple[
|
|
39
|
+
str,
|
|
40
|
+
str,
|
|
41
|
+
],
|
|
42
|
+
Tuple[
|
|
43
|
+
str,
|
|
44
|
+
str,
|
|
45
|
+
Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
|
|
46
|
+
],
|
|
47
|
+
]
|
|
48
|
+
]
|
|
49
|
+
],
|
|
50
|
+
],
|
|
51
|
+
],
|
|
29
52
|
] = None,
|
|
30
53
|
) -> None:
|
|
31
54
|
# Basic implementation
|
|
@@ -35,7 +58,28 @@ class FileImport:
|
|
|
35
58
|
# Fourth level set: None if this import is a "import", the name to import if it's a "from"
|
|
36
59
|
self._imports: Dict[
|
|
37
60
|
TypingSection,
|
|
38
|
-
Dict[
|
|
61
|
+
Dict[
|
|
62
|
+
ImportType,
|
|
63
|
+
Dict[
|
|
64
|
+
str,
|
|
65
|
+
Set[
|
|
66
|
+
Optional[
|
|
67
|
+
Union[
|
|
68
|
+
str,
|
|
69
|
+
Tuple[
|
|
70
|
+
str,
|
|
71
|
+
str,
|
|
72
|
+
],
|
|
73
|
+
Tuple[
|
|
74
|
+
str,
|
|
75
|
+
str,
|
|
76
|
+
Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
|
|
77
|
+
],
|
|
78
|
+
]
|
|
79
|
+
]
|
|
80
|
+
],
|
|
81
|
+
],
|
|
82
|
+
],
|
|
39
83
|
] = (
|
|
40
84
|
imports or dict()
|
|
41
85
|
)
|
|
@@ -44,14 +88,29 @@ class FileImport:
|
|
|
44
88
|
self,
|
|
45
89
|
from_section: str,
|
|
46
90
|
import_type: ImportType,
|
|
47
|
-
name_import: Optional[
|
|
91
|
+
name_import: Optional[
|
|
92
|
+
Union[
|
|
93
|
+
str,
|
|
94
|
+
Tuple[
|
|
95
|
+
str,
|
|
96
|
+
str,
|
|
97
|
+
],
|
|
98
|
+
Tuple[str, str, Tuple[Tuple[Tuple[int, int], str, Optional[str]]]],
|
|
99
|
+
]
|
|
100
|
+
] = None,
|
|
48
101
|
typing_section: TypingSection = TypingSection.REGULAR,
|
|
49
102
|
) -> None:
|
|
50
|
-
name_input: Optional[
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
103
|
+
name_input: Optional[
|
|
104
|
+
Union[
|
|
105
|
+
str,
|
|
106
|
+
Tuple[
|
|
107
|
+
str,
|
|
108
|
+
str,
|
|
109
|
+
],
|
|
110
|
+
Tuple[str, str, Tuple[Tuple[Tuple[int, int], str, Optional[str]]]],
|
|
111
|
+
]
|
|
112
|
+
] = None
|
|
113
|
+
name_input = convert_list_to_tuple(name_import)
|
|
55
114
|
self._imports.setdefault(typing_section, dict()).setdefault(
|
|
56
115
|
import_type, dict()
|
|
57
116
|
).setdefault(from_section, set()).add(name_input)
|
|
@@ -66,21 +125,33 @@ class FileImport:
|
|
|
66
125
|
"""Add an import to this import block."""
|
|
67
126
|
self._add_import(from_section, import_type, name_import, typing_section)
|
|
68
127
|
|
|
69
|
-
def add_import(
|
|
70
|
-
self,
|
|
71
|
-
name_import: str,
|
|
72
|
-
import_type: ImportType,
|
|
73
|
-
typing_section: TypingSection = TypingSection.REGULAR,
|
|
74
|
-
) -> None:
|
|
75
|
-
# Implementation detail: a regular import is just a "from" with no from
|
|
76
|
-
self._add_import(name_import, import_type, None, typing_section)
|
|
77
|
-
|
|
78
128
|
@property
|
|
79
129
|
def imports(
|
|
80
130
|
self,
|
|
81
131
|
) -> Dict[
|
|
82
132
|
TypingSection,
|
|
83
|
-
Dict[
|
|
133
|
+
Dict[
|
|
134
|
+
ImportType,
|
|
135
|
+
Dict[
|
|
136
|
+
str,
|
|
137
|
+
Set[
|
|
138
|
+
Optional[
|
|
139
|
+
Union[
|
|
140
|
+
str,
|
|
141
|
+
Tuple[
|
|
142
|
+
str,
|
|
143
|
+
str,
|
|
144
|
+
],
|
|
145
|
+
Tuple[
|
|
146
|
+
str,
|
|
147
|
+
str,
|
|
148
|
+
Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
|
|
149
|
+
],
|
|
150
|
+
]
|
|
151
|
+
]
|
|
152
|
+
],
|
|
153
|
+
],
|
|
154
|
+
],
|
|
84
155
|
]:
|
|
85
156
|
return self._imports
|
|
86
157
|
|