@autorest/python 5.15.0 → 5.18.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 (118) hide show
  1. package/ChangeLog.md +98 -4
  2. package/README.md +30 -4
  3. package/autorest/__init__.py +2 -3
  4. package/autorest/black/__init__.py +12 -5
  5. package/autorest/codegen/__init__.py +122 -211
  6. package/autorest/codegen/models/__init__.py +122 -78
  7. package/autorest/codegen/models/base_builder.py +70 -72
  8. package/autorest/codegen/models/base_model.py +7 -5
  9. package/autorest/codegen/models/{base_schema.py → base_type.py} +68 -45
  10. package/autorest/codegen/models/client.py +193 -40
  11. package/autorest/codegen/models/code_model.py +145 -245
  12. package/autorest/codegen/models/combined_type.py +107 -0
  13. package/autorest/codegen/models/constant_type.py +122 -0
  14. package/autorest/codegen/models/credential_types.py +224 -0
  15. package/autorest/codegen/models/dictionary_type.py +131 -0
  16. package/autorest/codegen/models/enum_type.py +195 -0
  17. package/autorest/codegen/models/imports.py +93 -41
  18. package/autorest/codegen/models/list_type.py +149 -0
  19. package/autorest/codegen/models/lro_operation.py +90 -133
  20. package/autorest/codegen/models/lro_paging_operation.py +28 -12
  21. package/autorest/codegen/models/model_type.py +262 -0
  22. package/autorest/codegen/models/operation.py +412 -259
  23. package/autorest/codegen/models/operation_group.py +80 -91
  24. package/autorest/codegen/models/paging_operation.py +101 -117
  25. package/autorest/codegen/models/parameter.py +302 -341
  26. package/autorest/codegen/models/parameter_list.py +373 -357
  27. package/autorest/codegen/models/primitive_types.py +544 -0
  28. package/autorest/codegen/models/property.py +136 -134
  29. package/autorest/codegen/models/request_builder.py +138 -86
  30. package/autorest/codegen/models/request_builder_parameter.py +122 -86
  31. package/autorest/codegen/models/response.py +325 -0
  32. package/autorest/codegen/models/utils.py +13 -17
  33. package/autorest/codegen/serializers/__init__.py +212 -112
  34. package/autorest/codegen/serializers/builder_serializer.py +931 -1040
  35. package/autorest/codegen/serializers/client_serializer.py +140 -84
  36. package/autorest/codegen/serializers/general_serializer.py +26 -50
  37. package/autorest/codegen/serializers/import_serializer.py +96 -31
  38. package/autorest/codegen/serializers/metadata_serializer.py +39 -79
  39. package/autorest/codegen/serializers/model_base_serializer.py +62 -34
  40. package/autorest/codegen/serializers/model_generic_serializer.py +9 -10
  41. package/autorest/codegen/serializers/model_init_serializer.py +4 -2
  42. package/autorest/codegen/serializers/model_python3_serializer.py +29 -22
  43. package/autorest/codegen/serializers/operation_groups_serializer.py +21 -19
  44. package/autorest/codegen/serializers/operations_init_serializer.py +23 -11
  45. package/autorest/codegen/serializers/parameter_serializer.py +174 -0
  46. package/autorest/codegen/serializers/patch_serializer.py +4 -1
  47. package/autorest/codegen/serializers/request_builders_serializer.py +57 -0
  48. package/autorest/codegen/serializers/utils.py +0 -126
  49. package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
  50. package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
  51. package/autorest/codegen/templates/config.py.jinja2 +13 -13
  52. package/autorest/codegen/templates/enum.py.jinja2 +4 -4
  53. package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
  54. package/autorest/codegen/templates/init.py.jinja2 +3 -3
  55. package/autorest/codegen/templates/lro_operation.py.jinja2 +6 -5
  56. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +6 -5
  57. package/autorest/codegen/templates/metadata.json.jinja2 +36 -35
  58. package/autorest/codegen/templates/model.py.jinja2 +23 -24
  59. package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
  60. package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
  61. package/autorest/codegen/templates/operation.py.jinja2 +10 -14
  62. package/autorest/codegen/templates/operation_group.py.jinja2 +9 -15
  63. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
  64. package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
  65. package/autorest/codegen/templates/paging_operation.py.jinja2 +7 -8
  66. package/autorest/codegen/templates/request_builder.py.jinja2 +19 -10
  67. package/autorest/codegen/templates/setup.py.jinja2 +9 -3
  68. package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
  69. package/autorest/jsonrpc/__init__.py +7 -12
  70. package/autorest/jsonrpc/localapi.py +4 -3
  71. package/autorest/jsonrpc/server.py +28 -9
  72. package/autorest/jsonrpc/stdstream.py +13 -6
  73. package/autorest/m2r/__init__.py +5 -8
  74. package/autorest/m4reformatter/__init__.py +1126 -0
  75. package/autorest/multiapi/__init__.py +24 -14
  76. package/autorest/multiapi/models/client.py +21 -11
  77. package/autorest/multiapi/models/code_model.py +23 -10
  78. package/autorest/multiapi/models/config.py +4 -1
  79. package/autorest/multiapi/models/constant_global_parameter.py +1 -0
  80. package/autorest/multiapi/models/global_parameter.py +2 -1
  81. package/autorest/multiapi/models/global_parameters.py +14 -8
  82. package/autorest/multiapi/models/imports.py +24 -17
  83. package/autorest/multiapi/models/mixin_operation.py +5 -5
  84. package/autorest/multiapi/models/operation_group.py +2 -1
  85. package/autorest/multiapi/models/operation_mixin_group.py +21 -10
  86. package/autorest/multiapi/serializers/__init__.py +20 -25
  87. package/autorest/multiapi/serializers/import_serializer.py +47 -17
  88. package/autorest/multiapi/serializers/multiapi_serializer.py +17 -17
  89. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
  90. package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
  91. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +4 -4
  92. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
  93. package/autorest/multiapi/utils.py +3 -3
  94. package/autorest/postprocess/__init__.py +202 -0
  95. package/autorest/postprocess/get_all.py +19 -0
  96. package/autorest/postprocess/venvtools.py +73 -0
  97. package/autorest/preprocess/__init__.py +210 -0
  98. package/autorest/preprocess/helpers.py +54 -0
  99. package/autorest/{namer → preprocess}/python_mappings.py +25 -32
  100. package/package.json +3 -3
  101. package/run-python3.js +2 -3
  102. package/venvtools.py +1 -1
  103. package/autorest/codegen/models/constant_schema.py +0 -101
  104. package/autorest/codegen/models/credential_model.py +0 -47
  105. package/autorest/codegen/models/credential_schema.py +0 -91
  106. package/autorest/codegen/models/credential_schema_policy.py +0 -77
  107. package/autorest/codegen/models/dictionary_schema.py +0 -103
  108. package/autorest/codegen/models/enum_schema.py +0 -215
  109. package/autorest/codegen/models/list_schema.py +0 -123
  110. package/autorest/codegen/models/object_schema.py +0 -253
  111. package/autorest/codegen/models/primitive_schemas.py +0 -466
  112. package/autorest/codegen/models/request_builder_parameter_list.py +0 -280
  113. package/autorest/codegen/models/rest.py +0 -42
  114. package/autorest/codegen/models/schema_request.py +0 -45
  115. package/autorest/codegen/models/schema_response.py +0 -136
  116. package/autorest/codegen/serializers/rest_serializer.py +0 -57
  117. package/autorest/namer/__init__.py +0 -25
  118. 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.class_name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
15
- """Configuration for {{ code_model.class_name }}.
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.global_parameters.config_method | first %}
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.class_name }}Configuration, self).__init__(**kwargs)
25
- {% if code_model.service_client.parameters.config_kwargs_to_pop(async_mode) %}
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.global_parameters.config_method %}
33
- self.{{ parameter.serialized_name }} = {{ parameter.serialized_name }}
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.options['credential'] and code_model.credential_model.credential_schema_policy.credential_scopes is defined %}
39
- self.credential_scopes = kwargs.pop('credential_scopes', {{ code_model.credential_model.credential_schema_policy.credential_scopes }})
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.options['credential'] %}
60
+ {% if code_model.credential %}
61
61
  {# only adding this if credential_scopes is not passed during code generation #}
62
- {% if code_model.credential_model.credential_schema_policy.credential_scopes is defined and code_model.credential_model.credential_schema_policy.credential_scopes|length == 0 %}
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.credential_model.credential_schema_policy.call(async_mode) }}
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 }}({{ enum.enum_type.type_annotation() }}, Enum, metaclass=CaseInsensitiveEnumMeta):
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 }}({{ enum.enum_type.type_annotation() }}, Enum, metaclass=Ca
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.enum_type.get_declaration(value.value) }}
12
+ {{ value.name }} = {{ enum.value_type.get_declaration(value.value) }}
13
13
  {% endfor %}
@@ -4,6 +4,6 @@
4
4
  from enum import Enum
5
5
  from azure.core import CaseInsensitiveEnumMeta
6
6
 
7
- {% for enum in code_model.enums.values() | sort %}
7
+ {% for enum in code_model.enums | sort %}
8
8
  {% include "enum.py.jinja2" %}
9
9
  {% endfor %}
@@ -2,8 +2,8 @@
2
2
  # coding=utf-8
3
3
  {{ code_model.options['license_header'] }}
4
4
 
5
- {% if code_model.rest.request_builders %}
6
- from .{{ code_model.service_client.filename }} import {{ code_model.class_name }}
5
+ {% if code_model.request_builders %}
6
+ from .{{ code_model.client.filename }} import {{ code_model.client.name }}
7
7
  {% endif %}
8
8
  {% if not async_mode and code_model.options['package_version']%}
9
9
  from ._version import VERSION
@@ -12,7 +12,7 @@ __version__ = VERSION
12
12
  {% endif %}
13
13
 
14
14
  {{ keywords.patch_imports(try_except=True) }}
15
- __all__ = [{{("'" + code_model.class_name + "'") if code_model.rest.request_builders else ""}}]
15
+ __all__ = [{{("'" + code_model.client.name + "'") if code_model.request_builders else ""}}]
16
16
  {{ keywords.extend_all }}
17
17
 
18
18
  _patch_sdk()
@@ -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 code_model.options['tracing'] %}
5
- {{ trace_decorator }}
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_serializer.pop_kwargs_from_signature(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
- {%- endif %}
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 code_model.options['tracing'] %}
6
- {{ trace_decorator }}
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_serializer.pop_kwargs_from_signature(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
- {% endif %}
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 service_client = code_model.service_client %}
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.class_name | tojson }},
8
+ "name": {{ code_model.client.name | tojson }},
9
9
  "filename": {{ ("_" + code_model.module_name) | tojson }},
10
- "description": {{ code_model.description | tojson }},
11
- "host_value": {{ (service_client.parameters.host.default_value_declaration if not service_client.has_parameterized_host else None) | tojson }},
12
- "parameterized_host_template": {{ (keywords.escape_str(service_client.parameterized_host_template) if service_client.has_parameterized_host else None) | tojson }},
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 sync_global_parameters.config_method | rejectattr("serialized_name", "equalto", "api_version") %}
22
- {{ gp.serialized_name | tojson }}: {
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.required | tojson }}
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 async_global_parameters.config_method | rejectattr("serialized_name", "equalto", "api_version") %}
32
- {{ gp.serialized_name | tojson }}: {
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.required | tojson }}
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.global_parameters.constant | rejectattr("serialized_name", "equalto", "api_version") %}
42
- {{ gp.serialized_name | tojson }}: {{ gp.constant_declaration | tojson }}{{ "," if not loop.last else "" }}
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.global_parameters.config_method | rejectattr("serialized_name", "equalto", "api_version") | map(attribute="serialized_name") | join(', ') | tojson }},
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 service_client.has_parameterized_host %}
54
+ {% if not client.has_parameterized_host %}
55
55
  "base_url": {
56
- "signature": {{ service_client.parameters.host.method_signature(False) | tojson }},
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 service_client.has_parameterized_host %}
76
+ {% if not client.has_parameterized_host %}
77
77
  "base_url": {
78
- "signature": {{ service_client.parameters.host.method_signature(True) | tojson }},
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": {{ code_model.options['credential'] | tojson }},
95
- "credential_scopes": {{ (code_model.credential_model.credential_schema_policy.credential_scopes if code_model.options['credential'] and code_model.credential_model.credential_schema_policy.credential_scopes is defined else None)| tojson}},
96
- "credential_call_sync": {{ (code_model.credential_model.credential_schema_policy.call(async_mode=False) if code_model.options['credential'] else None) | tojson }},
97
- "credential_call_async": {{ (code_model.credential_model.credential_schema_policy.call(async_mode=True) if code_model.options['credential'] else None) | tojson }},
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('is_empty_operation_group') %}
103
- {{ operation_group.name | tojson }}: {{ operation_group.class_name | tojson }}{{ "," if not loop.last else "" }}
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.python_name | tojson }} : {
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
- "call": {{ operation.parameters.method | rejectattr("is_kwarg") | map(attribute="serialized_name") | rejectattr("is_kwarg") | join(', ') | tojson }}
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,25 +1,24 @@
1
1
  {# actual template starts here #}
2
2
 
3
3
 
4
- {{ declare_model(model) }}
5
- """{{ model.description }}
6
- {% if model.discriminator_name %}
4
+ {{ serializer.declare_model(model) }}
5
+ """{{ model.description(is_operation_file=False) }}
6
+ {% if model.discriminated_subtypes %}
7
7
 
8
- You probably want to use the sub-classes and not this class directly. Known
9
- 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 ') }}
10
9
  {% endif %}
11
10
  {% if model.has_readonly_or_constant_property %}
12
11
 
13
12
  Variables are only populated by the server, and will be ignored when sending a request.
14
13
  {% endif %}
15
- {% if (model.properties | selectattr('required') | first) is defined %}
14
+ {% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
16
15
 
17
16
  All required parameters must be populated in order to send to Azure.
18
17
  {% endif %}
19
18
 
20
19
  {% if model.properties != None %}
21
20
  {% for p in model.properties %}
22
- {% for line in variable_documentation_string(p) %}
21
+ {% for line in serializer.variable_documentation_string(p) %}
23
22
  {% for doc_string in line.replace('\n', '\n ').split('\n') %}
24
23
  {{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
25
24
  {% endfor %}
@@ -27,45 +26,44 @@
27
26
  {% endfor %}
28
27
  {% endif %}
29
28
  """
30
- {% if (model.properties | selectattr('validation_map') ) | first %}
29
+ {% if (model.properties | selectattr('validation') ) | first %}
31
30
 
32
31
  _validation = {
33
- {% for p in model.properties | selectattr('validation_map')%}
34
- '{{ p.name }}': {{ str(p.validation_map) }},
32
+ {% for p in model.properties | selectattr('validation')%}
33
+ '{{ p.client_name }}': {{ str(p.validation) }},
35
34
  {% endfor %}
36
35
  }
37
36
  {% endif %}
38
37
 
39
38
  _attribute_map = {
40
- {% if model.properties != None %}
39
+ {% if model.properties %}
41
40
  {% for p in model.properties %}
42
- '{{ p.name }}': {'key': '{{ p.escaped_swagger_name }}', 'type': '{{ p.serialization_type}}'{{ p.xml_metadata }}},
41
+ {{ p.attribute_map }}
43
42
  {% endfor %}
44
- {% else%}
45
43
  {% endif %}
46
44
  }
47
- {% if model.discriminator_name %}
45
+ {% if model.discriminated_subtypes %}
48
46
 
49
47
  _subtype_map = {
50
- '{{ model.discriminator_name }}': {{ str(model.subtype_map) }}
48
+ '{{ model.discriminator.client_name }}': {{ str(model.discriminated_subtypes_name_mapping) }}
51
49
  }
52
50
  {% endif %}
53
- {% if model.xml_metadata %}
51
+ {% if model.xml_map_content %}
54
52
  _xml_map = {
55
- {{ model.xml_map_content() }}
53
+ {{ model.xml_map_content }}
56
54
  }
57
55
  {% endif %}
58
56
  {% if (model.properties | selectattr('constant') | first) is defined %}
59
57
 
60
58
  {% for p in model.properties | selectattr('constant')%}
61
- {{ p.name }} = {{ p.constant_declaration }}
59
+ {{ p.client_name }} = {{ p.type.get_declaration() }}
62
60
  {% endfor %}
63
61
  {% endif %}
64
62
 
65
- def __init__(
63
+ def __init__({{ model.init_pylint_disable }}
66
64
  self,
67
- {% for param_signature in init_line(model) %}
68
- {{ param_signature }},
65
+ {% for param_signature in serializer.init_line(model) %}
66
+ {{ param_signature }}
69
67
  {% endfor %}
70
68
  **kwargs
71
69
  ):
@@ -73,7 +71,7 @@
73
71
  {% if model.properties %}
74
72
  {% for p in model.properties %}
75
73
  {% if p.is_input %}
76
- {% for line in input_documentation_string(p) %}
74
+ {% for line in serializer.input_documentation_string(p) %}
77
75
  {% for doc_string in line.replace('\n', '\n ').split('\n') %}
78
76
  {{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
79
77
  {% endfor %}
@@ -82,6 +80,7 @@
82
80
  {% endfor %}
83
81
  {% endif %}
84
82
  """
85
- {% for arg in init_args(model) %}
86
- {{ arg }}
83
+ {{ serializer.super_call(model) }}
84
+ {% for initialize_property in serializer.initialize_properties(model) %}
85
+ {{ initialize_property }}
87
86
  {% endfor %}
@@ -1,7 +1,8 @@
1
1
  # coding=utf-8
2
+ # pylint: disable=too-many-lines
2
3
  {{ code_model.options['license_header'] }}
3
4
 
4
5
  {{ imports }}
5
- {% for model in code_model.sorted_schemas %}
6
+ {% for model in code_model.model_types %}
6
7
  {% include "model.py.jinja2" %}
7
8
  {% endfor %}
@@ -21,11 +21,9 @@ except (SyntaxError, ImportError):
21
21
  {% endif %}
22
22
  {% if enums %}
23
23
 
24
- from .{{ code_model.enums_filename }} import (
25
- {% for enum in enums %}
26
- {{ enum }},
27
- {% endfor %}
28
- )
24
+ {% for enum in enums %}
25
+ from .{{ code_model.enums_filename }} import {{ enum }}
26
+ {% endfor %}
29
27
  {% endif %}
30
28
  {{ keywords.patch_imports() }}
31
29
  __all__ = [
@@ -1,28 +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
- {%- if code_model.options['tracing'] and operation.want_tracing -%}
7
- {{ trace_decorator }}
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.want_description_docstring %}
8
+ {% if operation.public %}
11
9
  {{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
12
- {% if operation.deprecated %}
10
+ {% if not operation.abstract %}
11
+ {% if operation.deprecated %}
13
12
  warnings.warn('Method {{operation.name}} is deprecated', DeprecationWarning)
14
- {% endif %}
13
+ {% endif %}
15
14
  {{ op_tools.serialize(operation_serializer.error_map(operation)) | indent }}
16
- {% if operation_serializer.pop_kwargs_from_signature(operation) %}
15
+ {% if operation_serializer.pop_kwargs_from_signature(operation) %}
17
16
  {{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
18
- {% endif %}
17
+ {% endif %}
19
18
  {{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }}
20
- pipeline_response = {{ keywords.await }}self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
21
- request,
22
- {{ stream_request_parameter }},
23
- **kwargs
24
- )
19
+ {{ op_tools.serialize(operation_serializer.make_pipeline_call(operation)) | indent }}
25
20
  {{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
21
+ {% endif %}
26
22
  {% if not code_model.options["version_tolerant"] %}
27
23
  {{ operation_serializer.get_metadata_url(operation) }}
28
24
  {% endif %}
@@ -1,23 +1,17 @@
1
1
  {% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
2
- {% if operation_group.is_empty_operation_group and code_model.need_mixin_abc %}
3
- {% set object_base_class = "(MixinABC)" %}
4
- {% elif not (async_mode or code_model.options["python3_only"]) %}
5
- {% set object_base_class = "(object)" %}
6
- {% else %}
7
- {% set object_base_class = "" %}
8
- {% endif %}
9
- class {{ operation_group.class_name }}{{ object_base_class }}:{{ disable }}
10
- {% if not operation_group.is_empty_operation_group %}
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 %}
11
5
  """
12
6
  .. warning::
13
7
  **DO NOT** instantiate this class directly.
14
8
 
15
9
  Instead, you should access the following operations through
16
- :class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.class_name }}`'s
17
- :attr:`{{ operation_group.name }}` attribute.
10
+ :class:`{{ "~" + code_model.namespace + (".aio." if async_mode else ".") + code_model.client.name }}`'s
11
+ :attr:`{{ operation_group.property_name }}` attribute.
18
12
  """
19
13
 
20
- {% if code_model.schemas and code_model.options["models_mode"] %}
14
+ {% if code_model.public_model_types and code_model.options["models_mode"] %}
21
15
  models = _models
22
16
 
23
17
  {% endif %}
@@ -33,11 +27,11 @@ class {{ operation_group.class_name }}{{ object_base_class }}:{{ disable }}
33
27
 
34
28
  {% set request_builder = operation.request_builder %}
35
29
  {% set operation_serializer = get_operation_serializer(operation) %}
36
- {% if is_lro(operation) and is_paging(operation) %}
30
+ {% if operation.operation_type == "lropaging" %}
37
31
  {%- macro someop() %}{% include "lro_paging_operation.py.jinja2" %}{% endmacro %}
38
- {% elif is_lro(operation) %}
32
+ {% elif operation.operation_type == "lro" %}
39
33
  {%- macro someop() %}{% include "lro_operation.py.jinja2" %}{% endmacro %}
40
- {% elif is_paging(operation) %}
34
+ {% elif operation.operation_type == "paging" %}
41
35
  {% macro someop() %}{% include "paging_operation.py.jinja2" %}{% endmacro %}
42
36
  {% else %}
43
37
  {% macro someop() %}{% include "operation.py.jinja2" %}{% endmacro %}
@@ -12,7 +12,7 @@
12
12
  # fmt: off
13
13
  {% endif %}
14
14
  {% for operation_group in operation_groups %}
15
- {% for request_builder in code_model.rest.request_builders | selectattr("operation_group_name", "equalto", operation_group.name) %}
15
+ {% for request_builder in code_model.request_builders | selectattr("group_name", "equalto", operation_group.property_name) | rejectattr("is_overload") %}
16
16
 
17
17
  {% include "request_builder.py.jinja2" %}
18
18
  {% endfor %}
@@ -16,11 +16,11 @@
16
16
 
17
17
  {% endif %}
18
18
  {% endfor %}
19
- {% if serializer.want_example_template(builder) %}
19
+ {% if serializer.example_template(builder) %}
20
20
 
21
21
  Example:
22
22
  .. code-block:: python
23
- {% for template_line in serializer.get_example_template(builder) %}
23
+ {% for template_line in serializer.example_template(builder) %}
24
24
  {% if template_line %}
25
25
  {% set wrap_amount = (template_line | length) - (template_line.lstrip() | length) + 10 %}
26
26
  {{ wrap_string(template_line, wrapstring='\n' + " " * wrap_amount, width=(95 - wrap_amount)) }}
@@ -56,3 +56,9 @@ _SERIALIZER = Serializer()
56
56
  _SERIALIZER.client_side_validation = False
57
57
  {% endif %}
58
58
  {% endmacro %}
59
+
60
+ {% macro generate_overloads(operation_serializer, operation) %}
61
+ {% for overload in operation.overloads %}
62
+ {{ operation_serializer.method_signature_and_response_type_annotation(overload) }}
63
+ {{ description(overload, operation_serializer) | indent }}
64
+ {% endfor %}{% endmacro %}
@@ -1,22 +1,21 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools with context %}
2
2
  {# actual template starts here #}
3
- {% if code_model.options['tracing'] and operation.want_tracing %}
4
- @distributed_trace
5
- {% endif %}
6
3
  {{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
7
- {% if operation.want_description_docstring %}
4
+ {% if operation.public %}
8
5
  {{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
9
- {% if operation.deprecated %}
6
+ {% if not operation.abstract %}
7
+ {% if operation.deprecated %}
10
8
  warnings.warn('Method {{operation.name}} is deprecated', DeprecationWarning)
11
- {% endif %}
12
- {% if operation_serializer.pop_kwargs_from_signature(operation) %}
9
+ {% endif %}
10
+ {% if operation_serializer.pop_kwargs_from_signature(operation) %}
13
11
  {{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
14
- {% endif %}
12
+ {% endif %}
15
13
  {{ op_tools.serialize(operation_serializer.set_up_params_for_pager(operation)) | indent }}
16
14
 
17
15
  return {{ operation.get_pager(async_mode) }}(
18
16
  get_next, extract_data
19
17
  )
18
+ {% endif %}
20
19
  {% if not code_model.options["version_tolerant"] %}
21
20
  {{ operation_serializer.get_metadata_url(operation) -}}
22
21
  {% endif %}