@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.
- package/ChangeLog.md +43 -3
- package/README.md +30 -4
- package/autorest/__init__.py +1 -1
- package/autorest/codegen/__init__.py +48 -209
- package/autorest/codegen/models/__init__.py +116 -83
- package/autorest/codegen/models/base_builder.py +49 -88
- package/autorest/codegen/models/base_model.py +1 -1
- package/autorest/codegen/models/{base_schema.py → base_type.py} +56 -40
- package/autorest/codegen/models/client.py +157 -48
- package/autorest/codegen/models/code_model.py +108 -254
- package/autorest/codegen/models/combined_type.py +107 -0
- package/autorest/codegen/models/{constant_schema.py → constant_type.py} +49 -40
- package/autorest/codegen/models/credential_types.py +224 -0
- package/autorest/codegen/models/{dictionary_schema.py → dictionary_type.py} +41 -31
- package/autorest/codegen/models/enum_type.py +195 -0
- package/autorest/codegen/models/imports.py +23 -0
- package/autorest/codegen/models/list_type.py +134 -0
- package/autorest/codegen/models/lro_operation.py +77 -156
- package/autorest/codegen/models/lro_paging_operation.py +28 -11
- package/autorest/codegen/models/model_type.py +239 -0
- package/autorest/codegen/models/operation.py +303 -269
- package/autorest/codegen/models/operation_group.py +48 -89
- package/autorest/codegen/models/paging_operation.py +80 -123
- package/autorest/codegen/models/parameter.py +289 -396
- package/autorest/codegen/models/parameter_list.py +348 -360
- package/autorest/codegen/models/primitive_types.py +544 -0
- package/autorest/codegen/models/property.py +109 -139
- package/autorest/codegen/models/request_builder.py +105 -88
- package/autorest/codegen/models/request_builder_parameter.py +112 -100
- package/autorest/codegen/models/response.py +325 -0
- package/autorest/codegen/models/utils.py +12 -19
- package/autorest/codegen/serializers/__init__.py +46 -37
- package/autorest/codegen/serializers/builder_serializer.py +604 -1146
- package/autorest/codegen/serializers/client_serializer.py +83 -88
- package/autorest/codegen/serializers/general_serializer.py +5 -64
- package/autorest/codegen/serializers/import_serializer.py +7 -4
- package/autorest/codegen/serializers/metadata_serializer.py +15 -104
- package/autorest/codegen/serializers/model_base_serializer.py +40 -32
- package/autorest/codegen/serializers/model_generic_serializer.py +8 -6
- package/autorest/codegen/serializers/model_init_serializer.py +2 -4
- package/autorest/codegen/serializers/model_python3_serializer.py +22 -16
- package/autorest/codegen/serializers/operation_groups_serializer.py +4 -13
- package/autorest/codegen/serializers/parameter_serializer.py +174 -0
- package/autorest/codegen/serializers/request_builders_serializer.py +12 -29
- package/autorest/codegen/serializers/utils.py +0 -142
- package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
- package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
- package/autorest/codegen/templates/config.py.jinja2 +13 -13
- package/autorest/codegen/templates/enum.py.jinja2 +4 -4
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/init.py.jinja2 +2 -2
- package/autorest/codegen/templates/lro_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/metadata.json.jinja2 +33 -33
- package/autorest/codegen/templates/model.py.jinja2 +23 -24
- package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
- package/autorest/codegen/templates/operation.py.jinja2 +6 -8
- package/autorest/codegen/templates/operation_group.py.jinja2 +7 -7
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
- package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
- package/autorest/codegen/templates/request_builder.py.jinja2 +13 -11
- package/autorest/codegen/templates/setup.py.jinja2 +9 -3
- package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
- package/autorest/jsonrpc/server.py +15 -3
- package/autorest/m4reformatter/__init__.py +1108 -0
- package/autorest/multiapi/models/code_model.py +1 -1
- package/autorest/multiapi/serializers/__init__.py +4 -4
- package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
- package/autorest/postprocess/__init__.py +202 -0
- package/autorest/postprocess/get_all.py +19 -0
- package/autorest/postprocess/venvtools.py +73 -0
- package/autorest/preprocess/__init__.py +209 -0
- package/autorest/preprocess/helpers.py +54 -0
- package/autorest/{namer → preprocess}/python_mappings.py +21 -16
- package/package.json +2 -2
- package/autorest/codegen/models/credential_model.py +0 -55
- package/autorest/codegen/models/credential_schema.py +0 -95
- package/autorest/codegen/models/credential_schema_policy.py +0 -73
- package/autorest/codegen/models/enum_schema.py +0 -225
- package/autorest/codegen/models/list_schema.py +0 -135
- package/autorest/codegen/models/object_schema.py +0 -303
- package/autorest/codegen/models/primitive_schemas.py +0 -495
- package/autorest/codegen/models/request_builder_parameter_list.py +0 -249
- package/autorest/codegen/models/schema_request.py +0 -55
- package/autorest/codegen/models/schema_response.py +0 -141
- package/autorest/namer/__init__.py +0 -23
- package/autorest/namer/name_converter.py +0 -509
|
@@ -3,96 +3,6 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
from enum import Enum, auto
|
|
7
|
-
from typing import List
|
|
8
|
-
from ..models import ParameterStyle, ListSchema, Parameter, ParameterLocation
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def serialize_method(
|
|
12
|
-
*,
|
|
13
|
-
function_def: str,
|
|
14
|
-
method_name: str,
|
|
15
|
-
is_in_class: bool,
|
|
16
|
-
method_param_signatures: List[str],
|
|
17
|
-
ignore_inconsistent_return_statements: bool = False,
|
|
18
|
-
):
|
|
19
|
-
lines: List[str] = []
|
|
20
|
-
first_line = f"{function_def} {method_name}("
|
|
21
|
-
if ignore_inconsistent_return_statements:
|
|
22
|
-
first_line += " # pylint: disable=inconsistent-return-statements"
|
|
23
|
-
lines.append(first_line)
|
|
24
|
-
if is_in_class:
|
|
25
|
-
lines.append(" self,")
|
|
26
|
-
lines.extend([(" " + line) for line in method_param_signatures])
|
|
27
|
-
lines.append(")")
|
|
28
|
-
return "\n".join(lines)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def build_serialize_data_call(
|
|
32
|
-
parameter: Parameter, function_name: str, serializer_name: str
|
|
33
|
-
) -> str:
|
|
34
|
-
|
|
35
|
-
optional_parameters = []
|
|
36
|
-
|
|
37
|
-
if parameter.skip_url_encoding:
|
|
38
|
-
optional_parameters.append("skip_quote=True")
|
|
39
|
-
|
|
40
|
-
if parameter.style and not parameter.explode:
|
|
41
|
-
if parameter.style in [ParameterStyle.simple, ParameterStyle.form]:
|
|
42
|
-
div_char = ","
|
|
43
|
-
elif parameter.style in [ParameterStyle.spaceDelimited]:
|
|
44
|
-
div_char = " "
|
|
45
|
-
elif parameter.style in [ParameterStyle.pipeDelimited]:
|
|
46
|
-
div_char = "|"
|
|
47
|
-
elif parameter.style in [ParameterStyle.tabDelimited]:
|
|
48
|
-
div_char = "\t"
|
|
49
|
-
else:
|
|
50
|
-
raise ValueError(f"Do not support {parameter.style} yet")
|
|
51
|
-
optional_parameters.append(f"div='{div_char}'")
|
|
52
|
-
|
|
53
|
-
if parameter.explode:
|
|
54
|
-
if not isinstance(parameter.schema, ListSchema):
|
|
55
|
-
raise ValueError("Got a explode boolean on a non-array schema")
|
|
56
|
-
serialization_schema = parameter.schema.element_type
|
|
57
|
-
else:
|
|
58
|
-
serialization_schema = parameter.schema
|
|
59
|
-
|
|
60
|
-
serialization_constraints = serialization_schema.serialization_constraints
|
|
61
|
-
if serialization_constraints:
|
|
62
|
-
optional_parameters += serialization_constraints
|
|
63
|
-
|
|
64
|
-
origin_name = parameter.full_serialized_name
|
|
65
|
-
|
|
66
|
-
parameters = [
|
|
67
|
-
f'"{origin_name.lstrip("_")}"',
|
|
68
|
-
"q" if parameter.explode else origin_name,
|
|
69
|
-
f"'{serialization_schema.serialization_type}'",
|
|
70
|
-
*optional_parameters,
|
|
71
|
-
]
|
|
72
|
-
parameters_line = ", ".join(parameters)
|
|
73
|
-
|
|
74
|
-
serialize_line = f"{serializer_name}.{function_name}({parameters_line})"
|
|
75
|
-
|
|
76
|
-
if parameter.explode:
|
|
77
|
-
return f"[{serialize_line} if q is not None else '' for q in {origin_name}]"
|
|
78
|
-
return serialize_line
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def serialize_path(parameters: List[Parameter], serializer_name: str) -> List[str]:
|
|
82
|
-
retval = ["path_format_arguments = {"]
|
|
83
|
-
retval.extend(
|
|
84
|
-
[
|
|
85
|
-
' "{}": {},'.format(
|
|
86
|
-
path_parameter.rest_api_name,
|
|
87
|
-
build_serialize_data_call(path_parameter, "url", serializer_name),
|
|
88
|
-
)
|
|
89
|
-
for path_parameter in parameters
|
|
90
|
-
]
|
|
91
|
-
)
|
|
92
|
-
retval.append("}")
|
|
93
|
-
return retval
|
|
94
|
-
|
|
95
|
-
|
|
96
6
|
def method_signature_and_response_type_annotation_template(
|
|
97
7
|
*,
|
|
98
8
|
is_python3_file: bool,
|
|
@@ -102,55 +12,3 @@ def method_signature_and_response_type_annotation_template(
|
|
|
102
12
|
if is_python3_file:
|
|
103
13
|
return f"{method_signature} -> {response_type_annotation}:"
|
|
104
14
|
return f"{method_signature}:\n # type: (...) -> {response_type_annotation}"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
class PopKwargType(Enum):
|
|
108
|
-
NO = auto()
|
|
109
|
-
SIMPLE = auto()
|
|
110
|
-
CASE_INSENSITIVE = auto()
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def pop_kwargs_from_signature(
|
|
114
|
-
kwargs_to_pop: List[Parameter],
|
|
115
|
-
check_kwarg_dict: bool,
|
|
116
|
-
pop_headers_kwarg: PopKwargType,
|
|
117
|
-
pop_params_kwarg: PopKwargType,
|
|
118
|
-
) -> List[str]:
|
|
119
|
-
retval = []
|
|
120
|
-
|
|
121
|
-
def append_pop_kwarg(key: str, pop_type: PopKwargType) -> None:
|
|
122
|
-
if PopKwargType.CASE_INSENSITIVE == pop_type:
|
|
123
|
-
retval.append(
|
|
124
|
-
f'_{key} = case_insensitive_dict(kwargs.pop("{key}", {{}}) or {{}})'
|
|
125
|
-
)
|
|
126
|
-
elif PopKwargType.SIMPLE == pop_type:
|
|
127
|
-
retval.append(f'_{key} = kwargs.pop("{key}", {{}}) or {{}}')
|
|
128
|
-
|
|
129
|
-
append_pop_kwarg("headers", pop_headers_kwarg)
|
|
130
|
-
append_pop_kwarg("params", pop_params_kwarg)
|
|
131
|
-
if pop_headers_kwarg != PopKwargType.NO or pop_params_kwarg != PopKwargType.NO:
|
|
132
|
-
retval.append("")
|
|
133
|
-
for kwarg in kwargs_to_pop:
|
|
134
|
-
if kwarg.has_default_value:
|
|
135
|
-
default_value = kwarg.default_value_declaration
|
|
136
|
-
if check_kwarg_dict and (
|
|
137
|
-
kwarg.location in [ParameterLocation.Header, ParameterLocation.Query]
|
|
138
|
-
):
|
|
139
|
-
kwarg_dict = (
|
|
140
|
-
"headers"
|
|
141
|
-
if kwarg.location == ParameterLocation.Header
|
|
142
|
-
else "params"
|
|
143
|
-
)
|
|
144
|
-
default_value = (
|
|
145
|
-
f"_{kwarg_dict}.pop('{kwarg.rest_api_name}', {default_value})"
|
|
146
|
-
)
|
|
147
|
-
retval.append(
|
|
148
|
-
f"{kwarg.serialized_name} = kwargs.pop('{kwarg.serialized_name}', "
|
|
149
|
-
+ f"{default_value}) # type: {kwarg.type_annotation(is_operation_file=True)}"
|
|
150
|
-
)
|
|
151
|
-
else:
|
|
152
|
-
type_annot = kwarg.type_annotation(is_operation_file=True)
|
|
153
|
-
retval.append(
|
|
154
|
-
f"{kwarg.serialized_name} = kwargs.pop('{kwarg.serialized_name}') # type: {type_annot}"
|
|
155
|
-
)
|
|
156
|
-
return retval
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
{{ imports }}
|
|
8
8
|
|
|
9
9
|
{{ serializer.class_definition(async_mode) }}
|
|
10
|
-
"""{{ op_tools.wrap_string(code_model.description, "\n") | indent }}
|
|
10
|
+
"""{{ op_tools.wrap_string(code_model.client.description, "\n") | indent }}
|
|
11
11
|
|
|
12
12
|
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
|
|
13
13
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
14
|
-
{% if code_model.
|
|
14
|
+
{% if code_model.client.parameters.kwargs_to_pop(async_mode) %}
|
|
15
15
|
{{ op_tools.serialize(serializer.pop_kwargs_from_signature(async_mode)) | indent(8) }}
|
|
16
16
|
{% endif %}
|
|
17
|
-
{% if code_model.
|
|
18
|
-
|
|
17
|
+
{% if code_model.client.has_parameterized_host %}
|
|
18
|
+
{{ serializer.host_variable_name }} = {{ keywords.escape_str(code_model.client.url) }}
|
|
19
19
|
{% endif %}
|
|
20
20
|
{{ serializer.initialize_config() }}
|
|
21
21
|
{{ serializer.initialize_pipeline_client(async_mode) }}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
{{ serializer.send_request_signature_and_response_type_annotation(async_mode) | indent }}
|
|
27
27
|
{{ op_tools.serialize(serializer.send_request_description(async_mode)) | indent(8) }}
|
|
28
28
|
request_copy = deepcopy(request)
|
|
29
|
-
{% if code_model.
|
|
29
|
+
{% if code_model.client.parameters.path %}
|
|
30
30
|
{{ op_tools.serialize(serializer.serialize_path()) | indent(8) }}
|
|
31
31
|
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
|
|
32
32
|
{% else %}
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
{% endif %}
|
|
41
41
|
{{ keywords.await }}self._client.close()
|
|
42
42
|
|
|
43
|
-
{{ keywords.def }} __{{ keywords.async_prefix }}enter__(self){{ (" -> \"" + code_model.
|
|
43
|
+
{{ keywords.def }} __{{ keywords.async_prefix }}enter__(self){{ (" -> \"" + code_model.client.name + "\"") if async_mode else "" }}:
|
|
44
44
|
{% if not async_mode %}
|
|
45
|
-
# type: () -> {{ code_model.
|
|
45
|
+
# type: () -> {{ code_model.client.name }}
|
|
46
46
|
{% endif %}
|
|
47
47
|
{{ keywords.await }}self._client.__{{ keywords.async_prefix }}enter__()
|
|
48
48
|
return self
|
|
@@ -11,32 +11,32 @@
|
|
|
11
11
|
VERSION = "unknown"
|
|
12
12
|
{% endif %}
|
|
13
13
|
|
|
14
|
-
class {{ code_model.
|
|
15
|
-
"""Configuration for {{ code_model.
|
|
14
|
+
class {{ code_model.client.name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
|
|
15
|
+
"""Configuration for {{ code_model.client.name }}.
|
|
16
16
|
|
|
17
17
|
Note that all parameters used to create this instance are saved as instance
|
|
18
18
|
attributes.
|
|
19
|
-
{% if code_model.
|
|
19
|
+
{% if code_model.config.parameters.method | first %}
|
|
20
20
|
|
|
21
21
|
{% endif %}
|
|
22
|
-
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(), "\n ") | indent }}
|
|
22
|
+
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
|
|
23
23
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
24
|
-
super({{ code_model.
|
|
25
|
-
{% if code_model.
|
|
24
|
+
super({{ code_model.client.name }}Configuration, self).__init__(**kwargs)
|
|
25
|
+
{% if code_model.config.parameters.kwargs_to_pop(async_mode) %}
|
|
26
26
|
{{ op_tools.serialize(serializer.pop_kwargs_from_signature(async_mode)) | indent(8) }}
|
|
27
27
|
{% endif %}
|
|
28
28
|
{% if serializer.check_required_parameters() %}
|
|
29
29
|
{{ op_tools.serialize(serializer.check_required_parameters()) | indent(8) -}}
|
|
30
30
|
{% endif %}
|
|
31
31
|
|
|
32
|
-
{% for parameter in code_model.
|
|
33
|
-
self.{{ parameter.
|
|
32
|
+
{% for parameter in code_model.config.parameters.method %}
|
|
33
|
+
self.{{ parameter.client_name }} = {{ parameter.client_name }}
|
|
34
34
|
{% endfor %}
|
|
35
35
|
{% if serializer.set_constants() %}
|
|
36
36
|
{{ op_tools.serialize(serializer.set_constants()) | indent(8) -}}
|
|
37
37
|
{% endif %}
|
|
38
|
-
{% if code_model.
|
|
39
|
-
self.credential_scopes = kwargs.pop('credential_scopes', {{ code_model.
|
|
38
|
+
{% if code_model.credential and code_model.credential.type.policy.credential_scopes is defined %}
|
|
39
|
+
self.credential_scopes = kwargs.pop('credential_scopes', {{ code_model.credential.type.policy.credential_scopes }})
|
|
40
40
|
{% endif %}
|
|
41
41
|
kwargs.setdefault('sdk_moniker', '{{ sdk_moniker }}/{}'.format(VERSION))
|
|
42
42
|
self._configure(**kwargs)
|
|
@@ -57,12 +57,12 @@ class {{ code_model.class_name }}Configuration(Configuration): # pylint: disabl
|
|
|
57
57
|
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
|
|
58
58
|
self.redirect_policy = kwargs.get('redirect_policy') or policies.{{ keywords.async_class }}RedirectPolicy(**kwargs)
|
|
59
59
|
self.authentication_policy = kwargs.get('authentication_policy')
|
|
60
|
-
{% if code_model.
|
|
60
|
+
{% if code_model.credential %}
|
|
61
61
|
{# only adding this if credential_scopes is not passed during code generation #}
|
|
62
|
-
{% if code_model.
|
|
62
|
+
{% if code_model.credential.type.policy.credential_scopes is defined and code_model.credential.type.policy.credential_scopes | length == 0 %}
|
|
63
63
|
if not self.credential_scopes and not self.authentication_policy:
|
|
64
64
|
raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs")
|
|
65
65
|
{% endif %}
|
|
66
66
|
if self.credential and not self.authentication_policy:
|
|
67
|
-
self.authentication_policy = {{ code_model.
|
|
67
|
+
self.authentication_policy = {{ code_model.credential.type.policy.call(async_mode) }}
|
|
68
68
|
{% endif %}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
class {{ enum.name }}({{ enum.
|
|
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.
|
|
12
|
+
{{ value.name }} = {{ enum.value_type.get_declaration(value.value) }}
|
|
13
13
|
{% endfor %}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{{ code_model.options['license_header'] }}
|
|
4
4
|
|
|
5
5
|
{% if code_model.request_builders %}
|
|
6
|
-
from .{{ code_model.
|
|
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.
|
|
15
|
+
__all__ = [{{("'" + code_model.client.name + "'") if code_model.request_builders else ""}}]
|
|
16
16
|
{{ keywords.extend_all }}
|
|
17
17
|
|
|
18
18
|
_patch_sdk()
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
2
2
|
{# actual template starts here #}
|
|
3
|
-
{
|
|
3
|
+
{% if operation.overloads and operation.public %}
|
|
4
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
5
|
+
{% endif %}
|
|
6
|
+
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
4
7
|
{{ op_tools.description(operation, operation_serializer) | indent -}}
|
|
5
8
|
{% if not operation.abstract %}
|
|
6
9
|
{% if operation_serializer.pop_kwargs_from_signature(operation) %}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools with context %}
|
|
2
2
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
3
3
|
{# actual template starts here #}
|
|
4
|
-
{
|
|
4
|
+
{% if operation.overloads and operation.public %}
|
|
5
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
6
|
+
{% endif %}
|
|
7
|
+
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
5
8
|
{{ op_tools.description(operation, operation_serializer) | indent }}
|
|
6
9
|
{% if not operation.abstract %}
|
|
7
10
|
{% if operation_serializer.pop_kwargs_from_signature(operation) %}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
2
|
{% import 'keywords.jinja2' as keywords %}
|
|
3
|
-
{% set
|
|
3
|
+
{% set client = code_model.client %}
|
|
4
4
|
{
|
|
5
5
|
"chosen_version": {{ chosen_version | tojson }},
|
|
6
6
|
"total_api_version_list": {{ total_api_version_list | tojson }},
|
|
7
7
|
"client": {
|
|
8
|
-
"name": {{ code_model.
|
|
8
|
+
"name": {{ code_model.client.name | tojson }},
|
|
9
9
|
"filename": {{ ("_" + code_model.module_name) | tojson }},
|
|
10
|
-
"description": {{ code_model.description | tojson }},
|
|
11
|
-
"host_value": {{ (
|
|
12
|
-
"parameterized_host_template": {{ (keywords.escape_str(
|
|
10
|
+
"description": {{ code_model.client.description | tojson }},
|
|
11
|
+
"host_value": {{ (client.parameters.host.client_default_value_declaration if not client.has_parameterized_host else None) | tojson }},
|
|
12
|
+
"parameterized_host_template": {{ (keywords.escape_str(client.url) if client.has_parameterized_host else None) | tojson }},
|
|
13
13
|
"azure_arm": {{ code_model.options["azure_arm"] | tojson }},
|
|
14
14
|
"has_lro_operations": {{ code_model.has_lro_operations | tojson }},
|
|
15
15
|
"client_side_validation": {{ code_model.options["client_side_validation"] | tojson }},
|
|
@@ -18,31 +18,31 @@
|
|
|
18
18
|
},
|
|
19
19
|
"global_parameters": {
|
|
20
20
|
"sync": {
|
|
21
|
-
{% for gp in
|
|
22
|
-
{{ gp.
|
|
23
|
-
"signature": {{ gp.method_signature(is_python3_file=False) | tojson }},
|
|
21
|
+
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
22
|
+
{{ gp.client_name | tojson }}: {
|
|
23
|
+
"signature": {{ gp.method_signature(is_python3_file=False, async_mode=False) | tojson }},
|
|
24
24
|
"description": {{ gp.description | tojson }},
|
|
25
|
-
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
26
|
-
"required": {{ gp.
|
|
25
|
+
"docstring_type": {{ gp.docstring_type(async_mode=False) | tojson }},
|
|
26
|
+
"required": {{ (not gp.optional) | tojson }}
|
|
27
27
|
}{{ "," if not loop.last else "" }}
|
|
28
28
|
{% endfor %}
|
|
29
29
|
},
|
|
30
30
|
"async": {
|
|
31
|
-
{% for gp in
|
|
32
|
-
{{ gp.
|
|
33
|
-
"signature": {{ (gp.method_signature(is_python3_file=True)) | tojson }},
|
|
31
|
+
{% for gp in global_parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") %}
|
|
32
|
+
{{ gp.client_name | tojson }}: {
|
|
33
|
+
"signature": {{ (gp.method_signature(is_python3_file=True, async_mode=True)) | tojson }},
|
|
34
34
|
"description": {{ gp.description | tojson }},
|
|
35
|
-
"docstring_type": {{ gp.docstring_type | tojson }},
|
|
36
|
-
"required": {{ gp.
|
|
35
|
+
"docstring_type": {{ gp.docstring_type(async_mode=True) | tojson }},
|
|
36
|
+
"required": {{ (not gp.optional) | tojson }}
|
|
37
37
|
}{{ "," if not loop.last else "" }}
|
|
38
38
|
{% endfor %}
|
|
39
39
|
},
|
|
40
40
|
"constant": {
|
|
41
|
-
{% for gp in code_model.
|
|
42
|
-
{{ gp.
|
|
41
|
+
{% for gp in code_model.client.parameters.constant | rejectattr("client_name", "equalto", "api_version") %}
|
|
42
|
+
{{ gp.client_name | tojson }}: {{ gp.constant_declaration | tojson }}{{ "," if not loop.last else "" }}
|
|
43
43
|
{% endfor %}
|
|
44
44
|
},
|
|
45
|
-
"call": {{ code_model.
|
|
45
|
+
"call": {{ code_model.client.parameters.method | rejectattr("client_name", "equalto", "api_version") | rejectattr("is_host") | map(attribute="client_name") | join(', ') | tojson }},
|
|
46
46
|
"service_client_specific": {
|
|
47
47
|
"sync": {
|
|
48
48
|
"api_version": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"docstring_type": "str",
|
|
52
52
|
"required": false
|
|
53
53
|
},
|
|
54
|
-
{% if not
|
|
54
|
+
{% if not client.has_parameterized_host %}
|
|
55
55
|
"base_url": {
|
|
56
|
-
"signature": {{
|
|
56
|
+
"signature": {{ client.parameters.host.method_signature(False, async_mode=False) | tojson }},
|
|
57
57
|
"description": "Service URL",
|
|
58
58
|
"docstring_type": "str",
|
|
59
59
|
"required": false
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"docstring_type": "str",
|
|
74
74
|
"required": false
|
|
75
75
|
},
|
|
76
|
-
{% if not
|
|
76
|
+
{% if not client.has_parameterized_host %}
|
|
77
77
|
"base_url": {
|
|
78
|
-
"signature": {{
|
|
78
|
+
"signature": {{ client.parameters.host.method_signature(True, async_mode=True) | tojson }},
|
|
79
79
|
"description": "Service URL",
|
|
80
80
|
"docstring_type": "str",
|
|
81
81
|
"required": false
|
|
@@ -91,16 +91,16 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"config": {
|
|
94
|
-
"credential": {{
|
|
95
|
-
"credential_scopes": {{ (code_model.
|
|
96
|
-
"credential_call_sync": {{ (code_model.
|
|
97
|
-
"credential_call_async": {{ (code_model.
|
|
94
|
+
"credential": {{ has_credential | tojson }},
|
|
95
|
+
"credential_scopes": {{ (code_model.credential.type.policy.credential_scopes if has_credential and code_model.credential.type.policy.credential_scopes is defined else None)| tojson}},
|
|
96
|
+
"credential_call_sync": {{ (code_model.credential.type.policy.call(async_mode=False) if has_credential else None) | tojson }},
|
|
97
|
+
"credential_call_async": {{ (code_model.credential.type.policy.call(async_mode=True) if has_credential else None) | tojson }},
|
|
98
98
|
"sync_imports": {{ sync_config_imports | tojson }},
|
|
99
99
|
"async_imports": {{ async_config_imports | tojson }}
|
|
100
100
|
},
|
|
101
101
|
"operation_groups": {
|
|
102
|
-
{% for operation_group in code_model.operation_groups | rejectattr('
|
|
103
|
-
{{ operation_group.
|
|
102
|
+
{% for operation_group in code_model.operation_groups | rejectattr('is_mixin') %}
|
|
103
|
+
{{ operation_group.property_name | tojson }}: {{ operation_group.class_name | tojson }}{{ "," if not loop.last else "" }}
|
|
104
104
|
{% endfor %}
|
|
105
105
|
}{{ "," if mixin_operations }}
|
|
106
106
|
{% if mixin_operations %}
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"async_imports": {{ str(async_mixin_imports) | tojson }},
|
|
110
110
|
"operations": {
|
|
111
111
|
{% for operation in mixin_operations %}
|
|
112
|
-
{{ operation.
|
|
112
|
+
{{ operation.name | tojson }} : {
|
|
113
113
|
{% set request_builder = operation.request_builder %}
|
|
114
114
|
"sync": {
|
|
115
115
|
{% set operation_serializer = get_sync_operation_serializer(operation) %}
|
|
@@ -126,9 +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,
|
|
129
|
+
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation, want_decorators=False) + "\n") | tojson }},
|
|
130
130
|
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }},
|
|
131
|
-
"call": {{ operation.parameters.call
|
|
131
|
+
"call": {{ operation.parameters.call | join(', ') | tojson }}
|
|
132
132
|
},
|
|
133
133
|
"async": {
|
|
134
134
|
{% set coroutine = False if (is_paging(operation) and not is_lro(operation)) else True %}
|
|
@@ -147,9 +147,9 @@
|
|
|
147
147
|
{% from "operation.py.jinja2" import operation_docstring with context %}
|
|
148
148
|
{% set async_return_type_wrapper = "" %}
|
|
149
149
|
{% endif %}
|
|
150
|
-
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation,
|
|
150
|
+
"signature": {{ (operation_serializer.method_signature_and_response_type_annotation(operation, want_decorators=False) + "\n") | tojson }},
|
|
151
151
|
"doc": {{ op_tools.description(operation, operation_serializer).rstrip("\n") | tojson }},
|
|
152
|
-
"call": {{ operation.parameters.call
|
|
152
|
+
"call": {{ operation.parameters.call | join(', ') | tojson }}
|
|
153
153
|
}
|
|
154
154
|
}{{ "," if not loop.last else "" }}
|
|
155
155
|
{% endfor %}
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{# actual template starts here #}
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
{{ declare_model(model) }}
|
|
5
|
-
"""{{ model.description }}
|
|
6
|
-
{% if model.
|
|
4
|
+
{{ serializer.declare_model(model) }}
|
|
5
|
+
"""{{ model.description(is_operation_file=False) }}
|
|
6
|
+
{% if model.discriminated_subtypes %}
|
|
7
7
|
|
|
8
|
-
|
|
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('
|
|
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('
|
|
29
|
+
{% if (model.properties | selectattr('validation') ) | first %}
|
|
31
30
|
|
|
32
31
|
_validation = {
|
|
33
|
-
{% for p in model.properties | selectattr('
|
|
34
|
-
'{{ p.
|
|
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
|
|
39
|
+
{% if model.properties %}
|
|
41
40
|
{% for p in model.properties %}
|
|
42
|
-
|
|
41
|
+
{{ p.attribute_map }}
|
|
43
42
|
{% endfor %}
|
|
44
|
-
{% else%}
|
|
45
43
|
{% endif %}
|
|
46
44
|
}
|
|
47
|
-
{% if model.
|
|
45
|
+
{% if model.discriminated_subtypes %}
|
|
48
46
|
|
|
49
47
|
_subtype_map = {
|
|
50
|
-
'{{ model.
|
|
48
|
+
'{{ model.discriminator.client_name }}': {{ str(model.discriminated_subtypes) }}
|
|
51
49
|
}
|
|
52
50
|
{% endif %}
|
|
53
|
-
{% if model.
|
|
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.
|
|
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
|
-
|
|
86
|
-
|
|
83
|
+
{{ serializer.super_call(model) }}
|
|
84
|
+
{% for initialize_property in serializer.initialize_properties(model) %}
|
|
85
|
+
{{ initialize_property }}
|
|
87
86
|
{% endfor %}
|
|
@@ -21,11 +21,9 @@ except (SyntaxError, ImportError):
|
|
|
21
21
|
{% endif %}
|
|
22
22
|
{% if enums %}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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,9 +1,11 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords with context %}
|
|
2
2
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
3
|
-
{% set stream_request_parameter = "stream=" ~ ("True" if operation.is_stream_response else "False") %}
|
|
4
3
|
{# actual template starts here #}
|
|
5
|
-
{
|
|
6
|
-
{
|
|
4
|
+
{% if operation.overloads and operation.public %}
|
|
5
|
+
{{ op_tools.generate_overloads(operation_serializer, operation) }}
|
|
6
|
+
{% endif %}
|
|
7
|
+
{{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
|
|
8
|
+
{% if operation.public %}
|
|
7
9
|
{{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
|
|
8
10
|
{% if not operation.abstract %}
|
|
9
11
|
{% if operation.deprecated %}
|
|
@@ -14,11 +16,7 @@
|
|
|
14
16
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
15
17
|
{% endif %}
|
|
16
18
|
{{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }}
|
|
17
|
-
|
|
18
|
-
request,
|
|
19
|
-
{{ stream_request_parameter }},
|
|
20
|
-
**kwargs
|
|
21
|
-
)
|
|
19
|
+
{{ op_tools.serialize(operation_serializer.make_pipeline_call(operation)) | indent }}
|
|
22
20
|
{{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
|
|
23
21
|
{% endif %}
|
|
24
22
|
{% if not code_model.options["version_tolerant"] %}
|