@autorest/python 5.16.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.
Files changed (92) hide show
  1. package/ChangeLog.md +43 -3
  2. package/README.md +30 -4
  3. package/autorest/__init__.py +1 -1
  4. package/autorest/codegen/__init__.py +48 -209
  5. package/autorest/codegen/models/__init__.py +116 -83
  6. package/autorest/codegen/models/base_builder.py +49 -88
  7. package/autorest/codegen/models/base_model.py +1 -1
  8. package/autorest/codegen/models/{base_schema.py → base_type.py} +56 -40
  9. package/autorest/codegen/models/client.py +157 -48
  10. package/autorest/codegen/models/code_model.py +108 -254
  11. package/autorest/codegen/models/combined_type.py +107 -0
  12. package/autorest/codegen/models/{constant_schema.py → constant_type.py} +49 -40
  13. package/autorest/codegen/models/credential_types.py +224 -0
  14. package/autorest/codegen/models/{dictionary_schema.py → dictionary_type.py} +41 -31
  15. package/autorest/codegen/models/enum_type.py +195 -0
  16. package/autorest/codegen/models/imports.py +23 -0
  17. package/autorest/codegen/models/list_type.py +134 -0
  18. package/autorest/codegen/models/lro_operation.py +77 -156
  19. package/autorest/codegen/models/lro_paging_operation.py +28 -11
  20. package/autorest/codegen/models/model_type.py +239 -0
  21. package/autorest/codegen/models/operation.py +303 -269
  22. package/autorest/codegen/models/operation_group.py +48 -89
  23. package/autorest/codegen/models/paging_operation.py +80 -123
  24. package/autorest/codegen/models/parameter.py +289 -396
  25. package/autorest/codegen/models/parameter_list.py +348 -360
  26. package/autorest/codegen/models/primitive_types.py +544 -0
  27. package/autorest/codegen/models/property.py +109 -139
  28. package/autorest/codegen/models/request_builder.py +105 -88
  29. package/autorest/codegen/models/request_builder_parameter.py +112 -100
  30. package/autorest/codegen/models/response.py +325 -0
  31. package/autorest/codegen/models/utils.py +12 -19
  32. package/autorest/codegen/serializers/__init__.py +46 -37
  33. package/autorest/codegen/serializers/builder_serializer.py +604 -1146
  34. package/autorest/codegen/serializers/client_serializer.py +83 -88
  35. package/autorest/codegen/serializers/general_serializer.py +5 -64
  36. package/autorest/codegen/serializers/import_serializer.py +7 -4
  37. package/autorest/codegen/serializers/metadata_serializer.py +15 -104
  38. package/autorest/codegen/serializers/model_base_serializer.py +40 -32
  39. package/autorest/codegen/serializers/model_generic_serializer.py +8 -6
  40. package/autorest/codegen/serializers/model_init_serializer.py +2 -4
  41. package/autorest/codegen/serializers/model_python3_serializer.py +22 -16
  42. package/autorest/codegen/serializers/operation_groups_serializer.py +4 -13
  43. package/autorest/codegen/serializers/parameter_serializer.py +174 -0
  44. package/autorest/codegen/serializers/request_builders_serializer.py +12 -29
  45. package/autorest/codegen/serializers/utils.py +0 -142
  46. package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
  47. package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
  48. package/autorest/codegen/templates/config.py.jinja2 +13 -13
  49. package/autorest/codegen/templates/enum.py.jinja2 +4 -4
  50. package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
  51. package/autorest/codegen/templates/init.py.jinja2 +2 -2
  52. package/autorest/codegen/templates/lro_operation.py.jinja2 +4 -1
  53. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +4 -1
  54. package/autorest/codegen/templates/metadata.json.jinja2 +33 -33
  55. package/autorest/codegen/templates/model.py.jinja2 +23 -24
  56. package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
  57. package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
  58. package/autorest/codegen/templates/operation.py.jinja2 +6 -8
  59. package/autorest/codegen/templates/operation_group.py.jinja2 +7 -7
  60. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
  61. package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
  62. package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
  63. package/autorest/codegen/templates/request_builder.py.jinja2 +13 -11
  64. package/autorest/codegen/templates/setup.py.jinja2 +9 -3
  65. package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
  66. package/autorest/jsonrpc/server.py +15 -3
  67. package/autorest/m4reformatter/__init__.py +1108 -0
  68. package/autorest/multiapi/models/code_model.py +1 -1
  69. package/autorest/multiapi/serializers/__init__.py +4 -4
  70. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
  71. package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
  72. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +3 -3
  73. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
  74. package/autorest/postprocess/__init__.py +202 -0
  75. package/autorest/postprocess/get_all.py +19 -0
  76. package/autorest/postprocess/venvtools.py +73 -0
  77. package/autorest/preprocess/__init__.py +209 -0
  78. package/autorest/preprocess/helpers.py +54 -0
  79. package/autorest/{namer → preprocess}/python_mappings.py +21 -16
  80. package/package.json +2 -2
  81. package/autorest/codegen/models/credential_model.py +0 -55
  82. package/autorest/codegen/models/credential_schema.py +0 -95
  83. package/autorest/codegen/models/credential_schema_policy.py +0 -73
  84. package/autorest/codegen/models/enum_schema.py +0 -225
  85. package/autorest/codegen/models/list_schema.py +0 -135
  86. package/autorest/codegen/models/object_schema.py +0 -303
  87. package/autorest/codegen/models/primitive_schemas.py +0 -495
  88. package/autorest/codegen/models/request_builder_parameter_list.py +0 -249
  89. package/autorest/codegen/models/schema_request.py +0 -55
  90. package/autorest/codegen/models/schema_response.py +0 -141
  91. package/autorest/namer/__init__.py +0 -23
  92. package/autorest/namer/name_converter.py +0 -509
package/ChangeLog.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Change Log
2
2
 
3
+ ### 2022-06-02 - 5.17.0
4
+
5
+ | Library | Min Version |
6
+ | ----------------------------------------------------------------------- | ----------- |
7
+ | `@autorest/core` | `3.8.1` |
8
+ | `@autorest/modelerfour` | `4.23.5` |
9
+ | `azure-core` dep of generated code | `1.23.0` |
10
+ | `msrest` dep of generated code | `0.6.21` |
11
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
12
+
13
+ **New Features**
14
+
15
+ - Hide `api_version` in doc string for singleapi SDK even if contains multi api versions #1239
16
+ - Add overloads for operations with different body types. We now sniff bodies and assign content type based off of body type. #1230
17
+ - Add flag `--postprocess`. Run this after doing customizations for full mypy support
18
+
19
+ **Breaking Changes in Version Tolerant**
20
+
21
+ - Have stream responses directly return an iterator of bytes, so you don't need to call `.iter_bytes()` on the response object. #1254
22
+ - If generating with `--models-mode=msrest` in version tolerant, we hide paging models #1259
23
+
24
+ **Breaking Changes in Request Builders**
25
+
26
+ - Request builders for LRO operations have the `_initial` suffix removed from their name #1241
27
+ - Request builders from groups with reserved words will now be padded with the word "Operations" instead of "Builders" #1243
28
+
29
+ **Bug Fixes**
30
+
31
+ - Make sure `any-object` schemas from swagger are typed with `MutableMapping`s #1243
32
+ - Make typing for parameters `Optional` only if `None` is a valid input, not only if it is specified as `optional` in swagger #1244
33
+ - Fix for render failure of `README.md` when `--package-mode==dataplane` #1247
34
+ - Fix typing for stream responses to iterators of bytes. #1254
35
+ - Additional linting support #1265
36
+ - Fix Sphinx documentation for raised exception #1264
37
+ - Use `api_version` in `_config` as default value for operation function #1268
38
+
39
+ **Other Changes**
40
+
41
+ - Update template files for `--package-mode` # 1248
42
+
3
43
  ### 2022-04-18 - 5.16.0
4
44
 
5
45
  | Library | Min Version |
@@ -45,7 +85,7 @@
45
85
 
46
86
  **Breaking Changes in Version Tolerant Generation**
47
87
 
48
- - Change client filenames to `_client.py` #1206
88
+ - Change client filenames to `_client.py` #1206
49
89
  - Change the models filename from `_models_py3.py` to `_models.py` #1204
50
90
  - Change the enums filename to `_enums.py` #1204
51
91
 
@@ -716,7 +756,7 @@ Modelerfour version: 4.13.351
716
756
  **Bug Fixes**
717
757
 
718
758
  - Corrected ordering of summary and description in generated methods #640
719
- - Have `IOSchema` call super init to get all of the properties shared in `BaseSchema` #642
759
+ - Have `IOSchema` call super init to get all of the properties shared in `BaseType` #642
720
760
 
721
761
  ### 2020-05-15 - 5.0.0-preview.7
722
762
 
@@ -861,7 +901,7 @@ Modelerfour version: 4.12.276
861
901
 
862
902
  - Will no longer permit generated enums and models to have the same name #504
863
903
  - No longer exposing models from operation groups without importing them #486
864
- - Now correctly deserializes error's that have an empty object (AnySchema) as a model #516
904
+ - Now correctly deserializes error's that have an empty object (AnyType) as a model #516
865
905
  - Added a list of parameter names to reserved parameter words, so there won't be clashes #525
866
906
  - If a property's schema is readonly, we will show that property as being readonly (taken from m4 update #234)
867
907
  - Remove `"azure-"` prefix from user agent name #523
package/README.md CHANGED
@@ -30,13 +30,17 @@ modelerfour:
30
30
  flatten-payloads: true
31
31
  ```
32
32
 
33
+ ```yaml $(postprocess)
34
+ allow-no-input: true
35
+ ```
36
+
33
37
  ```yaml !$(multiapiscript)
34
38
  pass-thru:
35
39
  - model-deduplicator
36
40
  - subset-reducer
37
- version: ~3.6.2
41
+ version: ~3.8.1
38
42
  use-extension:
39
- "@autorest/modelerfour": ~4.19.1
43
+ "@autorest/modelerfour": ~4.23.5
40
44
 
41
45
  modelerfour:
42
46
  resolve-schema-name-collisons: true
@@ -69,11 +73,14 @@ pipeline:
69
73
  python/m2r:
70
74
  input: python
71
75
 
72
- python/namer:
76
+ python/m4reformatter:
73
77
  input: python/m2r
74
78
 
79
+ python/preprocess:
80
+ input: python/m4reformatter
81
+
75
82
  python/codegen:
76
- input: python/namer
83
+ input: python/preprocess
77
84
  output-artifact: python-files
78
85
 
79
86
  python/codegen/emitter:
@@ -126,6 +133,25 @@ scope-black/emitter:
126
133
  output-artifact: python-files
127
134
  ```
128
135
 
136
+ # Post-process customized code for mypy pipeline
137
+
138
+ ```yaml $(postprocess)
139
+ pipeline:
140
+ python/postprocess:
141
+ scope: postprocess
142
+ output-artifact: python-files
143
+
144
+ python/postprocess/emitter:
145
+ input: postprocess
146
+ scope: scope-postprocess/emitter
147
+
148
+ scope-postprocess/emitter:
149
+ input-artifact: python-files
150
+ output-uri-expr: $key
151
+
152
+ output-artifact: python-files
153
+ ```
154
+
129
155
  # Help
130
156
 
131
157
  ```yaml
@@ -61,7 +61,7 @@ class YamlUpdatePlugin(Plugin):
61
61
  def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
62
62
  """The code-model-v4-no-tags yaml model tree.
63
63
 
64
- :rtype: None
64
+ :rtype: updated yaml
65
65
  :raises Exception: Could raise any exception, stacktrace will be sent to autorest API
66
66
  """
67
67
  raise NotImplementedError()
@@ -5,29 +5,18 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
7
  import sys
8
- from typing import Dict, Any, Union, Type
8
+ from typing import Dict, Any, Union, cast
9
9
  from pathlib import Path
10
10
  import yaml
11
11
 
12
+
12
13
  from .. import Plugin
14
+ from .models.client import Client, Config
13
15
  from .models.code_model import CodeModel
14
- from .models import build_schema, RequestBuilder
16
+ from .models import build_type
17
+ from .models.request_builder import get_request_builder
15
18
  from .models.operation_group import OperationGroup
16
- from .models.parameter import Parameter
17
- from .models.parameter_list import GlobalParameterList
18
19
  from .serializers import JinjaSerializer
19
- from .models.credential_schema_policy import (
20
- CredentialSchemaPolicy,
21
- get_credential_schema_policy_type,
22
- )
23
- from .models.credential_schema_policy import (
24
- BearerTokenCredentialPolicy,
25
- AzureKeyCredentialPolicy,
26
- )
27
- from .models.credential_model import CredentialModel
28
-
29
- _AAD_TYPE = "AADToken"
30
- _KEY_TYPE = "AzureKey"
31
20
 
32
21
 
33
22
  def _build_convenience_layer(yaml_data: Dict[str, Any], code_model: CodeModel) -> None:
@@ -37,17 +26,13 @@ def _build_convenience_layer(yaml_data: Dict[str, Any], code_model: CodeModel) -
37
26
  OperationGroup.from_yaml(op_group, code_model)
38
27
  for op_group in yaml_data["operationGroups"]
39
28
  ]
40
- if yaml_data.get("schemas"):
41
- code_model.add_inheritance_to_models()
29
+ if yaml_data.get("types"):
42
30
  if code_model.options["models_mode"]:
43
- code_model.sort_schemas()
31
+ code_model.sort_model_types()
44
32
 
45
33
  if code_model.options["show_operations"]:
46
- code_model.generate_single_parameter_from_multiple_content_types_operation()
47
- code_model.link_operation_to_request_builder()
48
34
  # LRO operation
49
35
  code_model.format_lro_operations()
50
- code_model.remove_next_operation()
51
36
 
52
37
 
53
38
  def _validate_code_model_options(options: Dict[str, Any]) -> None:
@@ -149,200 +134,43 @@ class CodeGenerator(Plugin):
149
134
  "dependency_msrest": "msrest>=0.6.21",
150
135
  }
151
136
 
152
- @staticmethod
153
- def _build_with_security_definition(
154
- yaml_data: Dict[str, Any], credential_model: CredentialModel
155
- ):
156
- security_yaml = yaml_data.get("security", {})
157
- if security_yaml.get("authenticationRequired"):
158
- for scheme in security_yaml.get("schemes"):
159
- if _AAD_TYPE == scheme["type"]:
160
- credential_model.credential_scopes.update(scheme["scopes"])
161
- elif _KEY_TYPE == scheme["type"]:
162
- # only accept the last one
163
- credential_model.key_header_name = scheme["headerName"]
164
-
165
- if credential_model.credential_scopes:
166
- credential_model.policy_type = BearerTokenCredentialPolicy
167
- elif credential_model.key_header_name:
168
- credential_model.policy_type = AzureKeyCredentialPolicy
169
-
170
- @staticmethod
171
- def _build_credential_model(
172
- code_model: CodeModel, credential_model: CredentialModel
173
- ):
174
- if credential_model.policy_type:
175
- code_model.options["credential"] = True
176
- credential_model.build_authentication_policy()
177
- code_model.credential_model = credential_model
178
-
179
- def _handle_credential_model(
180
- self, yaml_data: Dict[str, Any], code_model: CodeModel
181
- ):
182
- credential_model = CredentialModel(code_model.options["azure_arm"])
183
-
184
- # credential info with security definition will be overridded by credential flags
185
- self._build_with_security_definition(yaml_data, credential_model)
186
- self._build_with_credential_flags(code_model, credential_model)
187
-
188
- self._build_credential_model(code_model, credential_model)
189
-
190
137
  def _create_code_model(
191
138
  self, yaml_data: Dict[str, Any], options: Dict[str, Union[str, bool]]
192
139
  ) -> CodeModel:
193
140
  # Create a code model
194
141
 
195
142
  code_model = CodeModel(yaml_data, options=options)
196
- self._handle_credential_model(yaml_data, code_model)
197
- code_model.module_name = yaml_data["info"]["python_title"]
198
- code_model.class_name = yaml_data["info"]["pascal_case_title"]
199
- code_model.description = (
200
- yaml_data["info"]["description"]
201
- if yaml_data["info"].get("description")
202
- else ""
203
- )
204
-
205
- # Get my namespace
206
- namespace = self._autorestapi.get_value("namespace")
207
- _LOGGER.debug("Namespace parameter was %s", namespace)
208
- if not namespace:
209
- namespace = yaml_data["info"]["python_title"]
210
- code_model.namespace = namespace
211
-
212
- if yaml_data.get("schemas"):
213
- for type_list in yaml_data["schemas"].values():
214
- for schema in type_list:
215
- build_schema(yaml_data=schema, code_model=code_model)
216
-
217
- # Global parameters
218
- code_model.global_parameters = GlobalParameterList(
219
- code_model,
220
- [
221
- Parameter.from_yaml(param, code_model=code_model)
222
- for param in yaml_data.get("globalParameters", [])
223
- ],
224
- )
143
+ for type_yaml in yaml_data.get("types", []):
144
+ build_type(yaml_data=type_yaml, code_model=code_model)
225
145
 
226
- # Custom URL
227
- code_model.setup_client_input_parameters(yaml_data)
146
+ code_model.client = Client.from_yaml(yaml_data["client"], code_model)
147
+ code_model.config = Config.from_yaml(yaml_data["client"], code_model)
228
148
 
229
149
  # Build request builders
230
150
  if yaml_data.get("operationGroups"):
231
- code_model.request_builders = [
232
- RequestBuilder.from_yaml(operation_yaml, code_model=code_model)
233
- for og_group in yaml_data["operationGroups"]
234
- for operation_yaml in og_group["operations"]
235
- ]
236
- _build_convenience_layer(yaml_data=yaml_data, code_model=code_model)
237
-
238
- if options["credential"]:
239
- code_model.global_parameters.add_credential_global_parameter()
151
+ for og_group in yaml_data["operationGroups"]:
152
+ for operation_yaml in og_group["operations"]:
153
+ request_builder = get_request_builder(
154
+ operation_yaml, code_model=code_model
155
+ )
156
+ if request_builder.overloads:
157
+ code_model.request_builders.extend(request_builder.overloads) # type: ignore
158
+ code_model.request_builders.append(request_builder)
159
+ if operation_yaml.get("nextOperation"):
160
+ # i am a paging operation and i have a next operation. Make sure to include my next operation
161
+ code_model.request_builders.append(
162
+ get_request_builder(
163
+ operation_yaml["nextOperation"], code_model=code_model
164
+ )
165
+ )
240
166
 
167
+ _build_convenience_layer(yaml_data=yaml_data, code_model=code_model)
241
168
  code_model.package_dependency = self._build_package_dependency()
242
169
  return code_model
243
170
 
244
- def _get_credential_scopes(self, credential):
245
- credential_scopes_temp = self._autorestapi.get_value("credential-scopes")
246
- credential_scopes = (
247
- credential_scopes_temp.split(",") if credential_scopes_temp else None
248
- )
249
- if credential_scopes and not credential:
250
- raise ValueError(
251
- "--credential-scopes must be used with the --add-credential flag"
252
- )
253
-
254
- # check to see if user just passes in --credential-scopes with no value
255
- if (
256
- self._autorestapi.get_boolean_value("credential-scopes", False)
257
- and not credential_scopes
258
- ):
259
- raise ValueError(
260
- "--credential-scopes takes a list of scopes in comma separated format. "
261
- "For example: --credential-scopes=https://cognitiveservices.azure.com/.default"
262
- )
263
- return credential_scopes
264
-
265
- def _update_with_credential_flags(
266
- self,
267
- code_model: CodeModel,
268
- credential_schema_policy: Type[CredentialSchemaPolicy],
269
- credential_model: CredentialModel,
270
- ):
271
- credential_model.policy_type = credential_schema_policy
272
- credential_scopes = self._get_credential_scopes(
273
- code_model.options["credential"]
274
- )
275
- credential_key_header_name = self._autorestapi.get_value(
276
- "credential-key-header-name"
277
- )
278
- azure_arm = code_model.options["azure_arm"]
279
- credential = code_model.options["credential"]
280
-
281
- if hasattr(credential_schema_policy, "credential_scopes"):
282
- if not credential_scopes:
283
- if azure_arm:
284
- credential_scopes = ["https://management.azure.com/.default"]
285
- elif credential:
286
- # If add-credential is specified, we still want to add a credential_scopes variable.
287
- # Will make it an empty list so we can differentiate between this case and None
288
- _LOGGER.warning(
289
- "You have default credential policy %s "
290
- "but not the --credential-scopes flag set while generating non-management plane code. "
291
- "This is not recommend because it forces the customer to pass credential scopes "
292
- "through kwargs if they want to authenticate.",
293
- credential_schema_policy.name(),
294
- )
295
- credential_scopes = []
296
-
297
- if credential_key_header_name:
298
- raise ValueError(
299
- "You have passed in a credential key header name with default credential policy type "
300
- f"{credential_schema_policy.name()}. This is not allowed, since credential key header "
301
- "name is tied with AzureKeyCredentialPolicy. Instead, with this policy it is recommend you "
302
- "pass in --credential-scopes."
303
- )
304
- credential_model.credential_scopes = set(credential_scopes)
305
- else:
306
- # currently the only other credential policy is AzureKeyCredentialPolicy
307
- if credential_scopes:
308
- raise ValueError(
309
- "You have passed in credential scopes with default credential policy type "
310
- "AzureKeyCredentialPolicy. This is not allowed, since credential scopes is tied with "
311
- f"{credential_model.default_authentication_policy.name()}. Instead, with this policy "
312
- "you must pass in --credential-key-header-name."
313
- )
314
- if not credential_key_header_name:
315
- credential_key_header_name = "api-key"
316
- _LOGGER.info(
317
- "Defaulting the AzureKeyCredentialPolicy header's name to 'api-key'"
318
- )
319
-
320
- credential_model.key_header_name = credential_key_header_name
321
-
322
- def _build_with_credential_flags(
323
- self, code_model: CodeModel, credential_model: CredentialModel
324
- ):
325
- if not code_model.options["credential"]:
326
- return
327
-
328
- credential_schema_policy_name = (
329
- self._autorestapi.get_value("credential-default-policy-type")
330
- or credential_model.default_authentication_policy.name()
331
- )
332
- credential_schema_policy_type = get_credential_schema_policy_type(
333
- credential_schema_policy_name
334
- )
335
- self._update_with_credential_flags(
336
- code_model, credential_schema_policy_type, credential_model
337
- )
338
-
339
171
  def _build_code_model_options(self) -> Dict[str, Any]:
340
172
  """Build en options dict from the user input while running autorest."""
341
173
  azure_arm = self._autorestapi.get_boolean_value("azure-arm", False)
342
- credential = self._autorestapi.get_boolean_value(
343
- "add-credentials", False
344
- ) or self._autorestapi.get_boolean_value("add-credential", False)
345
-
346
174
  license_header = self._autorestapi.get_value("header-text")
347
175
  if license_header:
348
176
  license_header = license_header.replace("\n", "\n# ")
@@ -352,11 +180,11 @@ class CodeGenerator(Plugin):
352
180
  )
353
181
  license_header += "\n# --------------------------------------------------------------------------"
354
182
 
355
- low_level_client = self._autorestapi.get_boolean_value(
356
- "low-level-client", False
183
+ low_level_client = cast(
184
+ bool, self._autorestapi.get_boolean_value("low-level-client", False)
357
185
  )
358
- version_tolerant = self._autorestapi.get_boolean_value(
359
- "version-tolerant", False
186
+ version_tolerant = cast(
187
+ bool, self._autorestapi.get_boolean_value("version-tolerant", False)
360
188
  )
361
189
  show_operations = self._autorestapi.get_boolean_value(
362
190
  "show-operations", not low_level_client
@@ -364,13 +192,15 @@ class CodeGenerator(Plugin):
364
192
  models_mode_default = (
365
193
  "none" if low_level_client or version_tolerant else "msrest"
366
194
  )
367
- python3_only = self._autorestapi.get_boolean_value(
368
- "python3-only", low_level_client or version_tolerant
195
+ python3_only = cast(
196
+ bool,
197
+ self._autorestapi.get_boolean_value(
198
+ "python3-only", low_level_client or version_tolerant
199
+ ),
369
200
  )
370
201
 
371
202
  options: Dict[str, Any] = {
372
203
  "azure_arm": azure_arm,
373
- "credential": credential,
374
204
  "head_as_boolean": self._autorestapi.get_boolean_value(
375
205
  "head-as-boolean", False
376
206
  ),
@@ -407,7 +237,8 @@ class CodeGenerator(Plugin):
407
237
  low_level_client or version_tolerant,
408
238
  ),
409
239
  "add_python3_operation_files": self._autorestapi.get_boolean_value(
410
- "add-python3-operation-files", python3_only and not low_level_client
240
+ "add-python3-operation-files",
241
+ python3_only and not (low_level_client or version_tolerant),
411
242
  ),
412
243
  "version_tolerant": version_tolerant,
413
244
  "low_level_client": low_level_client,
@@ -444,7 +275,6 @@ class CodeGenerator(Plugin):
444
275
 
445
276
  # Force some options in ARM MODE:
446
277
  if azure_arm:
447
- options["credential"] = True
448
278
  options["head_as_boolean"] = True
449
279
  return options
450
280
 
@@ -455,7 +285,16 @@ class CodeGenerator(Plugin):
455
285
  if "code-model-v4-no-tags.yaml" not in inputs:
456
286
  raise ValueError("code-model-v4-no-tags.yaml must be a possible input")
457
287
 
458
- file_content = self._autorestapi.read_file("code-model-v4-no-tags.yaml")
288
+ if self._autorestapi.get_value("input-yaml"):
289
+ input_yaml = self._autorestapi.get_value("input-yaml")
290
+ file_content = self._autorestapi.read_file(input_yaml)
291
+ else:
292
+ inputs = self._autorestapi.list_inputs()
293
+ _LOGGER.debug("Possible Inputs: %s", inputs)
294
+ if "code-model-v4-no-tags.yaml" not in inputs:
295
+ raise ValueError("code-model-v4-no-tags.yaml must be a possible input")
296
+
297
+ file_content = self._autorestapi.read_file("code-model-v4-no-tags.yaml")
459
298
 
460
299
  # Parse the received YAML
461
300
  yaml_data = yaml.safe_load(file_content)