@autorest/python 6.1.11 → 6.2.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 (73) hide show
  1. package/autorest/_utils.py +2 -1
  2. package/autorest/codegen/__init__.py +87 -80
  3. package/autorest/codegen/models/__init__.py +11 -8
  4. package/autorest/codegen/models/base_builder.py +11 -5
  5. package/autorest/codegen/models/base_model.py +5 -3
  6. package/autorest/codegen/models/base_type.py +7 -5
  7. package/autorest/codegen/models/client.py +131 -32
  8. package/autorest/codegen/models/code_model.py +92 -120
  9. package/autorest/codegen/models/combined_type.py +9 -6
  10. package/autorest/codegen/models/constant_type.py +6 -6
  11. package/autorest/codegen/models/credential_types.py +18 -16
  12. package/autorest/codegen/models/dictionary_type.py +8 -6
  13. package/autorest/codegen/models/enum_type.py +24 -17
  14. package/autorest/codegen/models/imports.py +4 -4
  15. package/autorest/codegen/models/list_type.py +14 -10
  16. package/autorest/codegen/models/lro_operation.py +14 -6
  17. package/autorest/codegen/models/model_type.py +19 -19
  18. package/autorest/codegen/models/operation.py +50 -33
  19. package/autorest/codegen/models/operation_group.py +23 -12
  20. package/autorest/codegen/models/paging_operation.py +14 -11
  21. package/autorest/codegen/models/parameter.py +25 -25
  22. package/autorest/codegen/models/parameter_list.py +22 -16
  23. package/autorest/codegen/models/primitive_types.py +21 -11
  24. package/autorest/codegen/models/property.py +7 -7
  25. package/autorest/codegen/models/request_builder.py +31 -20
  26. package/autorest/codegen/models/request_builder_parameter.py +18 -13
  27. package/autorest/codegen/models/response.py +29 -22
  28. package/autorest/codegen/serializers/__init__.py +196 -139
  29. package/autorest/codegen/serializers/builder_serializer.py +50 -49
  30. package/autorest/codegen/serializers/client_serializer.py +40 -46
  31. package/autorest/codegen/serializers/enum_serializer.py +4 -4
  32. package/autorest/codegen/serializers/general_serializer.py +96 -43
  33. package/autorest/codegen/serializers/metadata_serializer.py +20 -16
  34. package/autorest/codegen/serializers/model_init_serializer.py +10 -6
  35. package/autorest/codegen/serializers/model_serializer.py +8 -8
  36. package/autorest/codegen/serializers/operation_groups_serializer.py +24 -12
  37. package/autorest/codegen/serializers/operations_init_serializer.py +6 -7
  38. package/autorest/codegen/serializers/patch_serializer.py +4 -4
  39. package/autorest/codegen/serializers/request_builders_serializer.py +6 -6
  40. package/autorest/codegen/serializers/sample_serializer.py +146 -0
  41. package/autorest/codegen/templates/client.py.jinja2 +7 -15
  42. package/autorest/codegen/templates/client_container.py.jinja2 +12 -0
  43. package/autorest/codegen/templates/config.py.jinja2 +13 -26
  44. package/autorest/codegen/templates/config_container.py.jinja2 +16 -0
  45. package/autorest/codegen/templates/enum_container.py.jinja2 +3 -3
  46. package/autorest/codegen/templates/init.py.jinja2 +11 -5
  47. package/autorest/codegen/templates/lro_operation.py.jinja2 +2 -2
  48. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +1 -1
  49. package/autorest/codegen/templates/metadata.json.jinja2 +13 -14
  50. package/autorest/codegen/templates/model_container.py.jinja2 +3 -3
  51. package/autorest/codegen/templates/model_init.py.jinja2 +4 -4
  52. package/autorest/codegen/templates/operation.py.jinja2 +2 -2
  53. package/autorest/codegen/templates/operation_group.py.jinja2 +3 -3
  54. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +7 -7
  55. package/autorest/codegen/templates/operation_tools.jinja2 +3 -3
  56. package/autorest/codegen/templates/operations_folder_init.py.jinja2 +4 -4
  57. package/autorest/codegen/templates/{CHANGELOG.md.jinja2 → packaging_templates/CHANGELOG.md.jinja2} +0 -0
  58. package/autorest/codegen/templates/{LICENSE.jinja2 → packaging_templates/LICENSE.jinja2} +0 -0
  59. package/autorest/codegen/templates/{MANIFEST.in.jinja2 → packaging_templates/MANIFEST.in.jinja2} +0 -0
  60. package/autorest/codegen/templates/{README.md.jinja2 → packaging_templates/README.md.jinja2} +0 -0
  61. package/autorest/codegen/templates/{dev_requirements.txt.jinja2 → packaging_templates/dev_requirements.txt.jinja2} +0 -0
  62. package/autorest/codegen/templates/{setup.py.jinja2 → packaging_templates/setup.py.jinja2} +9 -9
  63. package/autorest/codegen/templates/paging_operation.py.jinja2 +1 -1
  64. package/autorest/codegen/templates/request_builder.py.jinja2 +1 -1
  65. package/autorest/codegen/templates/request_builders.py.jinja2 +3 -3
  66. package/autorest/codegen/templates/rest_init.py.jinja2 +1 -1
  67. package/autorest/codegen/templates/sample.py.jinja2 +44 -0
  68. package/autorest/codegen/templates/validation.py.jinja2 +1 -1
  69. package/autorest/codegen/templates/vendor.py.jinja2 +9 -7
  70. package/autorest/codegen/templates/version.py.jinja2 +2 -2
  71. package/autorest/m4reformatter/__init__.py +20 -7
  72. package/autorest/preprocess/__init__.py +38 -23
  73. package/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ # pylint: disable=too-many-lines
2
+ # -------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for
5
+ # license information.
6
+ # --------------------------------------------------------------------------
7
+ import logging
8
+ from typing import Dict, Any
9
+ from jinja2 import Environment
10
+
11
+ from autorest.codegen.models.credential_types import AzureKeyCredentialType
12
+ from autorest.codegen.models.credential_types import TokenCredentialType
13
+ from autorest.codegen.models.imports import FileImport, ImportType
14
+ from autorest.codegen.models.operation import OperationBase
15
+ from autorest.codegen.models.operation_group import OperationGroup
16
+ from autorest.codegen.serializers.import_serializer import FileImportSerializer
17
+ from ..models import NamespaceModel
18
+
19
+ _LOGGER = logging.getLogger(__name__)
20
+
21
+
22
+ class SampleSerializer:
23
+ def __init__(
24
+ self,
25
+ namespace_model: NamespaceModel,
26
+ env: Environment,
27
+ operation_group: OperationGroup,
28
+ operation: OperationBase[Any],
29
+ sample: Dict[str, Any],
30
+ file_name: str,
31
+ sample_origin_name: str,
32
+ ) -> None:
33
+ self.namespace_model = namespace_model
34
+ self.env = env
35
+ self.operation_group = operation_group
36
+ self.operation = operation
37
+ self.sample = sample
38
+ self.file_name = file_name
39
+ self.sample_origin_name = sample_origin_name
40
+
41
+ def _imports(self) -> FileImportSerializer:
42
+ imports = FileImport()
43
+ namespace = (self.namespace_model.options["package_name"] or "").replace(
44
+ "-", "."
45
+ ) or self.namespace_model.namespace
46
+ client = self.namespace_model.clients[0]
47
+ imports.add_submodule_import(namespace, client.name, ImportType.THIRDPARTY)
48
+ credential_type = getattr(client.credential, "type", None)
49
+ if isinstance(credential_type, TokenCredentialType):
50
+ imports.add_submodule_import(
51
+ "azure.identity", "DefaultAzureCredential", ImportType.THIRDPARTY
52
+ )
53
+ elif isinstance(credential_type, AzureKeyCredentialType):
54
+ imports.add_import("os", ImportType.STDLIB)
55
+ imports.add_submodule_import(
56
+ "azure.core.credentials", "AzureKeyCredential", ImportType.THIRDPARTY
57
+ )
58
+ return FileImportSerializer(imports, True)
59
+
60
+ def _client_params(self) -> Dict[str, Any]:
61
+ # client params
62
+ special_param = dict()
63
+ credential_type = getattr(
64
+ self.namespace_model.clients[0].credential, "type", None
65
+ )
66
+ if isinstance(credential_type, TokenCredentialType):
67
+ special_param.update({"credential": "DefaultAzureCredential()"})
68
+ elif isinstance(credential_type, AzureKeyCredentialType):
69
+ special_param.update(
70
+ {"credential": 'AzureKeyCredential(key=os.getenv("AZURE_KEY"))'}
71
+ )
72
+
73
+ params_positional = [
74
+ p
75
+ for p in self.namespace_model.clients[0].parameters.positional
76
+ if not (p.optional or p.client_default_value)
77
+ ]
78
+ cls = lambda x: f'"{x}"'
79
+ client_params = {
80
+ p.client_name: special_param.get(
81
+ p.client_name,
82
+ cls(
83
+ self.sample["parameters"].get(p.rest_api_name)
84
+ or p.client_name.upper()
85
+ ),
86
+ )
87
+ for p in params_positional
88
+ }
89
+
90
+ return client_params
91
+
92
+ # prepare operation parameters
93
+ def _operation_params(self) -> Dict[str, Any]:
94
+ params_positional = [
95
+ p
96
+ for p in self.operation.parameters.positional
97
+ if not p.client_default_value
98
+ ]
99
+ cls = lambda x: f'"{x}"' if isinstance(x, str) else str(x)
100
+ failure_info = '"fail to find required param named {%s} in example file {%s}"'
101
+ operation_params = {}
102
+ for param in params_positional:
103
+ name = param.rest_api_name
104
+ param_value = self.sample["parameters"].get(name)
105
+ if not param.optional:
106
+ if not param_value:
107
+ raise Exception(failure_info.format(name, self.sample_origin_name))
108
+ operation_params[param.client_name] = cls(param_value)
109
+ return operation_params
110
+
111
+ def _operation_group_name(self) -> str:
112
+ if self.operation_group.is_mixin:
113
+ return ""
114
+ return f".{self.operation_group.property_name}"
115
+
116
+ def _operation_result(self) -> str:
117
+ lro = ".result()"
118
+ paging = "\n for item in response:\n print(item)"
119
+ normal_print = "\n print(response)"
120
+ if self.operation.operation_type == "paging":
121
+ return paging
122
+ if self.operation.operation_type == "lro":
123
+ return lro + normal_print
124
+ if self.operation.operation_type == "lropaging":
125
+ return lro + paging
126
+ return normal_print
127
+
128
+ def _operation_name(self) -> str:
129
+ return f".{self.operation.name}"
130
+
131
+ def _origin_file(self) -> str:
132
+ name = self.sample.get("x-ms-original-file", "").split("specification")[-1]
133
+ return "specification" + name if name else name
134
+
135
+ def serialize(self) -> str:
136
+ return self.env.get_template("sample.py.jinja2").render(
137
+ namespace_model=self.namespace_model,
138
+ file_name=self.file_name,
139
+ operation_result=self._operation_result(),
140
+ operation_params=self._operation_params(),
141
+ operation_group_name=self._operation_group_name(),
142
+ operation_name=self._operation_name(),
143
+ imports=self._imports(),
144
+ client_params=self._client_params(),
145
+ origin_file=self._origin_file(),
146
+ )
@@ -1,24 +1,16 @@
1
- {% import 'keywords.jinja2' as keywords with context %}
2
- {% import 'operation_tools.jinja2' as op_tools %}
3
- {# actual template starts here #}
4
- # coding=utf-8
5
- {{ code_model.options['license_header'] }}
6
-
7
- {{ imports }}
8
-
9
1
  {{ serializer.class_definition }}
10
- """{{ op_tools.wrap_string(code_model.client.description, "\n") | indent }}
2
+ """{{ op_tools.wrap_string(client.description, "\n") | indent }}
11
3
 
12
4
  {{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
13
5
  {{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
14
6
  {% if serializer.should_init_super %}
15
7
  super().__init__()
16
8
  {% endif %}
17
- {% if code_model.client.parameters.kwargs_to_pop %}
9
+ {% if client.parameters.kwargs_to_pop %}
18
10
  {{ op_tools.serialize(serializer.pop_kwargs_from_signature()) | indent(8) }}
19
11
  {% endif %}
20
- {% if code_model.client.has_parameterized_host %}
21
- {{ serializer.host_variable_name }} = {{ keywords.escape_str(code_model.client.url) }}
12
+ {% if client.has_parameterized_host %}
13
+ {{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}
22
14
  {% endif %}
23
15
  {{ serializer.initialize_config() }}
24
16
  {{ serializer.initialize_pipeline_client(async_mode) }}
@@ -29,7 +21,7 @@
29
21
  {{ serializer.send_request_signature_and_response_type_annotation(async_mode) | indent }}
30
22
  {{ op_tools.serialize(serializer.send_request_description(async_mode)) | indent(8) }}
31
23
  request_copy = deepcopy(request)
32
- {% if code_model.client.parameters.path %}
24
+ {% if client.parameters.path %}
33
25
  {{ op_tools.serialize(serializer.serialize_path()) | indent(8) }}
34
26
  request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
35
27
  {% else %}
@@ -43,9 +35,9 @@
43
35
  {% endif %}
44
36
  {{ keywords.await }}self._client.close()
45
37
 
46
- {{ keywords.def }} __{{ keywords.async_prefix }}enter__(self){{ (" -> \"" + code_model.client.name + "\"") if async_mode else "" }}:
38
+ {{ keywords.def }} __{{ keywords.async_prefix }}enter__(self){{ (" -> \"" + client.name + "\"") if async_mode else "" }}:
47
39
  {% if not async_mode %}
48
- # type: () -> {{ code_model.client.name }}
40
+ # type: () -> {{ client.name }}
49
41
  {% endif %}
50
42
  {{ keywords.await }}self._client.__{{ keywords.async_prefix }}enter__()
51
43
  return self
@@ -0,0 +1,12 @@
1
+ {% import 'keywords.jinja2' as keywords with context %}
2
+ {% import 'operation_tools.jinja2' as op_tools %}
3
+ {# actual template starts here #}
4
+ # coding=utf-8
5
+ {{ namespace_model.options['license_header'] }}
6
+
7
+ {{ imports }}
8
+
9
+ {% for client in namespace_model.clients %}
10
+ {% set serializer = get_serializer(client) %}
11
+ {% include "client.py.jinja2" %}
12
+ {% endfor %}
@@ -1,44 +1,31 @@
1
- {% import 'keywords.jinja2' as keywords with context %}
2
- {% import 'operation_tools.jinja2' as op_tools %}
3
- {% set version_import = ".._version" if async_mode else "._version" %}
4
- {# actual template starts here #}
5
- # coding=utf-8
6
- {{ code_model.options['license_header'] }}
7
-
8
- {{ imports }}
9
-
10
- {% if not code_model.options['package_version'] %}
11
- VERSION = "unknown"
12
- {% endif %}
13
-
14
- class {{ code_model.client.name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
15
- """Configuration for {{ code_model.client.name }}.
1
+ class {{ client.name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
2
+ """Configuration for {{ client.name }}.
16
3
 
17
4
  Note that all parameters used to create this instance are saved as instance
18
5
  attributes.
19
- {% if code_model.config.parameters.method | first %}
6
+ {% if client.config.parameters.method | first %}
20
7
 
21
8
  {% endif %}
22
9
  {{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
23
10
  {{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
24
- super({{ code_model.client.name }}Configuration, self).__init__(**kwargs)
25
- {% if code_model.config.parameters.kwargs_to_pop %}
11
+ super({{ client.name }}Configuration, self).__init__(**kwargs)
12
+ {% if client.config.parameters.kwargs_to_pop %}
26
13
  {{ op_tools.serialize(serializer.pop_kwargs_from_signature()) | indent(8) }}
27
14
  {% endif %}
28
15
  {% if serializer.check_required_parameters() %}
29
16
  {{ op_tools.serialize(serializer.check_required_parameters()) | indent(8) -}}
30
17
  {% endif %}
31
18
 
32
- {% for parameter in code_model.config.parameters.method %}
19
+ {% for parameter in client.config.parameters.method %}
33
20
  self.{{ parameter.client_name }} = {{ parameter.client_name }}
34
21
  {% endfor %}
35
22
  {% if serializer.set_constants() %}
36
23
  {{ op_tools.serialize(serializer.set_constants()) | indent(8) -}}
37
24
  {% endif %}
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 }})
25
+ {% if client.credential and client.credential.type.policy.credential_scopes is defined %}
26
+ self.credential_scopes = kwargs.pop('credential_scopes', {{ client.credential.type.policy.credential_scopes }})
40
27
  {% endif %}
41
- kwargs.setdefault('sdk_moniker', '{{ sdk_moniker }}/{}'.format(VERSION))
28
+ kwargs.setdefault('sdk_moniker', '{{ client.config.sdk_moniker }}/{}'.format(VERSION))
42
29
  self._configure(**kwargs)
43
30
 
44
31
  def _configure(
@@ -52,17 +39,17 @@ class {{ code_model.client.name }}Configuration(Configuration): # pylint: disab
52
39
  self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
53
40
  self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
54
41
  self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
55
- self.http_logging_policy = kwargs.get('http_logging_policy') or {{ "ARM" if code_model.options['azure_arm'] else "policies." }}HttpLoggingPolicy(**kwargs)
42
+ self.http_logging_policy = kwargs.get('http_logging_policy') or {{ "ARM" if client.namespace_model.options['azure_arm'] else "policies." }}HttpLoggingPolicy(**kwargs)
56
43
  self.retry_policy = kwargs.get('retry_policy') or policies.{{ keywords.async_class }}RetryPolicy(**kwargs)
57
44
  self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
58
45
  self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ keywords.async_class }}RedirectPolicy(**kwargs)
59
46
  self.authentication_policy = kwargs.get('authentication_policy')
60
- {% if code_model.credential %}
47
+ {% if client.credential %}
61
48
  {# only adding this if credential_scopes is not passed during code generation #}
62
- {% if code_model.credential.type.policy.credential_scopes is defined and code_model.credential.type.policy.credential_scopes | length == 0 %}
49
+ {% if client.credential.type.policy.credential_scopes is defined and client.credential.type.policy.credential_scopes | length == 0 %}
63
50
  if not self.credential_scopes and not self.authentication_policy:
64
51
  raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs")
65
52
  {% endif %}
66
53
  if self.credential and not self.authentication_policy:
67
- self.authentication_policy = {{ code_model.credential.type.policy.call(async_mode) }}
54
+ self.authentication_policy = {{ client.credential.type.policy.call(async_mode) }}
68
55
  {% endif %}
@@ -0,0 +1,16 @@
1
+ {% import 'keywords.jinja2' as keywords with context %}
2
+ {% import 'operation_tools.jinja2' as op_tools %}
3
+ {# actual template starts here #}
4
+ # coding=utf-8
5
+ {{ namespace_model.options['license_header'] }}
6
+
7
+ {{ imports }}
8
+
9
+ {% if not namespace_model.options['package_version'] %}
10
+ VERSION = "unknown"
11
+ {% endif %}
12
+
13
+ {% for client in namespace_model.clients %}
14
+ {% set serializer = get_serializer(client) %}
15
+ {% include "config.py.jinja2" %}
16
+ {% endfor %}
@@ -1,9 +1,9 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {{ namespace_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 code_model.enums | sort %}
7
+ {% for enum in namespace_model.enums | sort %}
8
8
  {% include "enum.py.jinja2" %}
9
- {% endfor %}
9
+ {% endfor %}
@@ -1,18 +1,24 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {{ namespace_model.options['license_header'] }}
4
4
 
5
- {% if code_model.request_builders %}
6
- from .{{ code_model.client.filename }} import {{ code_model.client.name }}
5
+ {% if clients %}
6
+ {% for client in clients %}
7
+ from .{{ client.filename }} import {{ client.name }}
8
+ {% endfor %}
7
9
  {% endif %}
8
- {% if not async_mode and code_model.options['package_version']%}
10
+ {% if not async_mode and namespace_model.options['package_version']%}
9
11
  from ._version import VERSION
10
12
 
11
13
  __version__ = VERSION
12
14
  {% endif %}
13
15
 
14
16
  {{ keywords.patch_imports(try_except=True) }}
15
- __all__ = [{{("'" + code_model.client.name + "'") if code_model.request_builders else ""}}]
17
+ __all__ = [
18
+ {% for client in clients %}
19
+ {{ keywords.escape_str(client.name) }},
20
+ {% endfor %}
21
+ ]
16
22
  {{ keywords.extend_all }}
17
23
 
18
24
  _patch_sdk()
@@ -14,6 +14,6 @@
14
14
 
15
15
  {{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
16
16
  {% endif %}
17
- {% if not code_model.options["version_tolerant"] %}
17
+ {% if not namespace_model.options["version_tolerant"] %}
18
18
  {{ operation_serializer.get_metadata_url(operation) -}}
19
- {% endif %}
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 code_model.options["version_tolerant"] %}
19
+ {% if not namespace_model.options["version_tolerant"] %}
20
20
  {{ operation_serializer.get_metadata_url(operation) }}
21
21
  {% endif %}
@@ -1,18 +1,17 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  {% import 'keywords.jinja2' as keywords %}
3
- {% set client = code_model.client %}
4
3
  {
5
4
  "chosen_version": {{ chosen_version | tojson }},
6
5
  "total_api_version_list": {{ total_api_version_list | tojson }},
7
6
  "client": {
8
- "name": {{ code_model.client.name | tojson }},
9
- "filename": {{ ("_" + code_model.module_name) | tojson }},
10
- "description": {{ code_model.client.description | tojson }},
7
+ "name": {{ client.name | tojson }},
8
+ "filename": {{ ("_" + client.legacy_filename) | tojson }},
9
+ "description": {{ client.description | tojson }},
11
10
  "host_value": {{ (client.parameters.host.client_default_value_declaration if not client.has_parameterized_host else None) | tojson }},
12
11
  "parameterized_host_template": {{ (keywords.escape_str(client.url) if client.has_parameterized_host else None) | tojson }},
13
- "azure_arm": {{ code_model.options["azure_arm"] | tojson }},
14
- "has_lro_operations": {{ code_model.has_lro_operations | tojson }},
15
- "client_side_validation": {{ code_model.options["client_side_validation"] | tojson }},
12
+ "azure_arm": {{ client.namespace_model.options["azure_arm"] | tojson }},
13
+ "has_lro_operations": {{ client.has_lro_operations | tojson }},
14
+ "client_side_validation": {{ client.namespace_model.options["client_side_validation"] | tojson }},
16
15
  "sync_imports": {{ sync_client_imports | tojson }},
17
16
  "async_imports": {{ async_client_imports | tojson }}
18
17
  },
@@ -38,11 +37,11 @@
38
37
  {% endfor %}
39
38
  },
40
39
  "constant": {
41
- {% for gp in code_model.client.parameters.constant | rejectattr("client_name", "equalto", "api_version") %}
40
+ {% for gp in client.parameters.constant | rejectattr("client_name", "equalto", "api_version") %}
42
41
  {{ gp.client_name | tojson }}: {{ gp.constant_declaration | tojson }}{{ "," if not loop.last else "" }}
43
42
  {% endfor %}
44
43
  },
45
- "call": {{ code_model.client.parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") | map(attribute="client_name") | join(', ') | tojson }},
44
+ "call": {{ client.parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") | map(attribute="client_name") | join(', ') | tojson }},
46
45
  "service_client_specific": {
47
46
  "sync": {
48
47
  "api_version": {
@@ -92,14 +91,14 @@
92
91
  },
93
92
  "config": {
94
93
  "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 }},
94
+ "credential_scopes": {{ (client.credential.type.policy.credential_scopes if has_credential and client.credential.type.policy.credential_scopes is defined else None)| tojson}},
95
+ "credential_call_sync": {{ (client.credential.type.policy.call(async_mode=False) if has_credential else None) | tojson }},
96
+ "credential_call_async": {{ (client.credential.type.policy.call(async_mode=True) if has_credential else None) | tojson }},
98
97
  "sync_imports": {{ sync_config_imports | tojson }},
99
98
  "async_imports": {{ async_config_imports | tojson }}
100
99
  },
101
100
  "operation_groups": {
102
- {% for operation_group in code_model.operation_groups | rejectattr('is_mixin') %}
101
+ {% for operation_group in client.operation_groups | rejectattr('is_mixin') %}
103
102
  {{ operation_group.property_name | tojson }}: {{ operation_group.class_name | tojson }}{{ "," if not loop.last else "" }}
104
103
  {% endfor %}
105
104
  }{{ "," if mixin_operations }}
@@ -156,4 +155,4 @@
156
155
  }
157
156
  }
158
157
  {% endif %}
159
- }
158
+ }
@@ -1,10 +1,10 @@
1
1
  # coding=utf-8
2
2
  # pylint: disable=too-many-lines
3
- {{ code_model.options['license_header'] }}
3
+ {{ namespace_model.options['license_header'] }}
4
4
 
5
5
  {{ imports }}
6
- {% for model in code_model.model_types %}
7
- {% if code_model.options["models_mode"] == "dpg" %}
6
+ {% for model in namespace_model.model_types %}
7
+ {% if namespace_model.options["models_mode"] == "dpg" %}
8
8
  {% include "model_dpg.py.jinja2" %}
9
9
  {% else %}
10
10
  {% include "model_msrest.py.jinja2" %}
@@ -1,16 +1,16 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {{ namespace_model.options['license_header'] }}
4
4
  {% if schemas %}
5
5
 
6
6
  {% for schema in schemas %}
7
- from .{{ code_model.models_filename }} import {{ schema }}
7
+ from .{{ namespace_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 .{{ code_model.enums_filename }} import {{ enum }}
13
+ from .{{ namespace_model.enums_filename }} import {{ enum }}
14
14
  {% endfor %}
15
15
  {% endif %}
16
16
  {{ keywords.patch_imports() }}
@@ -25,4 +25,4 @@ __all__ = [
25
25
  {% endif %}
26
26
  ]
27
27
  {{ keywords.extend_all }}
28
- _patch_sdk()
28
+ _patch_sdk()
@@ -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 code_model.options["version_tolerant"] %}
22
+ {% if not namespace_model.options["version_tolerant"] %}
23
23
  {{ operation_serializer.get_metadata_url(operation) }}
24
- {% endif %}
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:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.client.name }}`'s
19
+ :class:`{{ "~" + namespace_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 code_model.public_model_types and code_model.options["models_mode"] == "msrest" %}
23
+ {% if namespace_model.public_model_types and namespace_model.options["models_mode"] == "msrest" %}
24
24
  models = _models
25
25
 
26
26
  {% endif %}
@@ -50,4 +50,4 @@ class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
50
50
  {% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %}
51
51
  {% endif %}
52
52
  {{ someop()|indent }}
53
- {% endfor %}
53
+ {% endfor %}
@@ -3,17 +3,17 @@
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
- {{ code_model.options['license_header'] }}
6
+ {{ namespace_model.options['license_header'] }}
7
7
  {{ imports }}
8
8
 
9
- {% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
10
- {{ op_tools.declare_serializer(code_model, request_builders) }}
11
- {% for operation_group in operation_groups %}
12
- {% for request_builder in request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
9
+ {% if namespace_model.options["builders_visibility"] == "embedded" and not async_mode %}
10
+ {{ op_tools.declare_serializer(namespace_model) }}
11
+ {% for operation_group in operation_groups %}
12
+ {% for request_builder in get_request_builders(operation_group) %}
13
13
 
14
- {% include "request_builder.py.jinja2" %}
14
+ {% include "request_builder.py.jinja2" %}
15
+ {% endfor %}
15
16
  {% endfor %}
16
- {% endfor %}
17
17
  {% endif %}
18
18
  {% for operation_group in operation_groups %}
19
19
  {% include "operation_group.py.jinja2" %}
@@ -50,10 +50,10 @@ Example:
50
50
  {% endif %}
51
51
  {% endfor %}{% endmacro %}
52
52
 
53
- {% macro declare_serializer(code_model, request_builders) %}
54
- {% if request_builders %}
53
+ {% macro declare_serializer(namespace_model) %}
54
+ {% if namespace_model.request_builders | rejectattr("abstract") | first %}
55
55
  _SERIALIZER = Serializer()
56
- {% if not code_model.options["client_side_validation"] %}
56
+ {% if not namespace_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
- {{ code_model.options['license_header'] }}
5
+ {{ namespace_model.options['license_header'] }}
6
6
 
7
7
  {{ op_tools.serialize(operation_group_imports()) }}
8
8
  {{ keywords.patch_imports() }}
9
- {% if operation_groups %}
9
+ {% if namespace_model.operation_groups %}
10
10
  __all__ = [
11
- {% for operation_group in operation_groups %}
11
+ {% for operation_group in namespace_model.operation_groups %}
12
12
  '{{ operation_group.class_name }}',
13
13
  {% endfor %}
14
14
  ]
15
15
  {% endif %}
16
16
  {{ keywords.extend_all }}
17
- _patch_sdk()
17
+ _patch_sdk()
@@ -7,9 +7,9 @@ import re
7
7
  {% endif -%}
8
8
  from setuptools import setup, find_packages
9
9
 
10
- {% set package_name_render = package_name or code_model.client.name %}
10
+ {% set package_name = package_name or code_model.namespace_models[0].clients[0].name %}
11
11
 
12
- PACKAGE_NAME = "{{ package_name_render|lower }}"
12
+ PACKAGE_NAME = "{{ package_name|lower }}"
13
13
  {% if package_mode -%}
14
14
  PACKAGE_PPRINT_NAME = "{{ package_pprint_name }}"
15
15
 
@@ -28,9 +28,9 @@ if not version:
28
28
  {% set author_email = "azpysdkhelp@microsoft.com" %}
29
29
  {% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
30
30
  {% else %}
31
- version = "{{ code_model.options['package_version'] }}"
32
- {% set description = "%s"|format(package_name_render) %}
33
- {% set long_description = code_model.client.description %}
31
+ version = "{{ package_version }}"
32
+ {% set description = "%s"|format(package_name) %}
33
+ {% set long_description = code_model.description %}
34
34
  {% set author_email = "" %}
35
35
  {% set url = "" %}
36
36
  {% endif -%}
@@ -82,21 +82,21 @@ setup(
82
82
  {% endif %}
83
83
  install_requires=[
84
84
  {% if code_model.is_legacy %}
85
- "{{ dependency_msrest }}",
85
+ "msrest>=0.7.1",
86
86
  {% else %}
87
87
  "isodate<1.0.0,>=0.6.1",
88
88
  {% endif %}
89
89
  {% if azure_arm %}
90
- "{{ dependency_azure_mgmt_core }}",
90
+ "azure-mgmt-core<2.0.0,>=1.3.2",
91
91
  {% else %}
92
- "{{ dependency_azure_core }}",
92
+ "azure-core<2.0.0,>=1.24.0",
93
93
  {% endif %}
94
94
  ],
95
95
  {% if package_mode %}
96
96
  python_requires=">=3.7",
97
97
  {% else %}
98
98
  long_description="""\
99
- {{ code_model.client.description }}
99
+ {{ code_model.description }}
100
100
  """
101
101
  {% endif %}
102
102
  )
@@ -19,6 +19,6 @@
19
19
  get_next, extract_data
20
20
  )
21
21
  {% endif %}
22
- {% if not code_model.options["version_tolerant"] %}
22
+ {% if not namespace_model.options["version_tolerant"] %}
23
23
  {{ operation_serializer.get_metadata_url(operation) -}}
24
24
  {% endif %}
@@ -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 code_model.options["builders_visibility"] == "public" %}
4
+ {% if namespace_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 %}