@autorest/python 6.1.5 → 6.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autorest/__init__.py +10 -3
- package/autorest/black/__init__.py +2 -8
- package/autorest/codegen/__init__.py +4 -2
- package/autorest/codegen/models/__init__.py +1 -1
- package/autorest/codegen/models/base_builder.py +4 -1
- package/autorest/codegen/models/client.py +5 -3
- package/autorest/codegen/models/combined_type.py +6 -4
- package/autorest/codegen/models/enum_type.py +6 -4
- package/autorest/codegen/models/model_type.py +30 -9
- package/autorest/codegen/models/operation.py +32 -0
- package/autorest/codegen/models/operation_group.py +11 -7
- package/autorest/codegen/models/parameter.py +44 -0
- package/autorest/codegen/models/property.py +8 -15
- package/autorest/codegen/models/request_builder_parameter.py +4 -2
- package/autorest/codegen/serializers/__init__.py +18 -2
- package/autorest/codegen/serializers/builder_serializer.py +64 -22
- package/autorest/codegen/serializers/client_serializer.py +3 -4
- package/autorest/codegen/serializers/general_serializer.py +8 -0
- package/autorest/codegen/serializers/model_serializer.py +159 -61
- package/autorest/codegen/templates/model_base.py.jinja2 +636 -0
- package/autorest/codegen/templates/model_container.py.jinja2 +6 -2
- package/autorest/codegen/templates/model_dpg.py.jinja2 +62 -0
- package/autorest/codegen/templates/model_init.py.jinja2 +0 -5
- package/autorest/codegen/templates/{model.py.jinja2 → model_msrest.py.jinja2} +1 -1
- package/autorest/codegen/templates/operation_group.py.jinja2 +1 -1
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/validation.py.jinja2 +38 -0
- package/package.json +9 -10
- package/ChangeLog.md +0 -1284
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{# actual template starts here #}
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
{{ serializer.declare_model(model) }}
|
|
5
|
+
"""{{ model.description(is_operation_file=False) }}
|
|
6
|
+
{% if model.discriminated_subtypes %}
|
|
7
|
+
|
|
8
|
+
{{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
9
|
+
{% endif %}
|
|
10
|
+
{% if model.has_readonly_or_constant_property %}
|
|
11
|
+
|
|
12
|
+
Variables are only populated by the server, and will be ignored when sending a request.
|
|
13
|
+
{% endif %}
|
|
14
|
+
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
15
|
+
|
|
16
|
+
All required parameters must be populated in order to send to Azure.
|
|
17
|
+
{% endif %}
|
|
18
|
+
|
|
19
|
+
{% if model.properties != None %}
|
|
20
|
+
{% for p in model.properties %}
|
|
21
|
+
{% for line in serializer.variable_documentation_string(p) %}
|
|
22
|
+
{% for doc_string in line.replace('\n', '\n ').split('\n') %}
|
|
23
|
+
{{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
|
|
24
|
+
{% endfor %}
|
|
25
|
+
{% endfor %}
|
|
26
|
+
{% endfor %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
{% if model.is_polymorphic %}
|
|
31
|
+
__mapping__ = {}
|
|
32
|
+
{% endif %}
|
|
33
|
+
{% for p in serializer.get_properties_to_initialize(model)%}
|
|
34
|
+
{% for line in serializer.declare_property(p) %}
|
|
35
|
+
{{ line }}
|
|
36
|
+
{% endfor %}
|
|
37
|
+
{% endfor %}
|
|
38
|
+
|
|
39
|
+
{% if model.is_public and serializer.init_line(model) %}
|
|
40
|
+
@overload
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
{% for param_signature in serializer.init_line(model) %}
|
|
44
|
+
{{ param_signature }}
|
|
45
|
+
{% endfor %}
|
|
46
|
+
):
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
@overload
|
|
50
|
+
def __init__(self, mapping: Mapping[str, Any]):
|
|
51
|
+
"""
|
|
52
|
+
:param mapping: raw JSON to initialize the model.
|
|
53
|
+
:type mapping: Mapping[str, Any]
|
|
54
|
+
"""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
{% endif %}
|
|
58
|
+
def __init__(self, *args, **kwargs):
|
|
59
|
+
super().__init__(*args, **kwargs)
|
|
60
|
+
{% if model.discriminator_value %}
|
|
61
|
+
{{ serializer.initialize_discriminator_property(model, model.discriminator_property) }}
|
|
62
|
+
{% endif %}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
{% import 'keywords.jinja2' as keywords %}
|
|
2
2
|
# coding=utf-8
|
|
3
3
|
{{ code_model.options['license_header'] }}
|
|
4
|
-
{% macro iterate_models_py3() %}
|
|
5
|
-
{% for schema in schemas %}
|
|
6
|
-
from .{{ code_model.models_filename }} import {{ schema }}
|
|
7
|
-
{% endfor %}
|
|
8
|
-
{% endmacro %}
|
|
9
4
|
{% if schemas %}
|
|
10
5
|
|
|
11
6
|
{% for schema in schemas %}
|
|
@@ -20,7 +20,7 @@ class {{ operation_group.class_name }}{{ base_class }}:{{ disable }}
|
|
|
20
20
|
:attr:`{{ operation_group.property_name }}` attribute.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
{% if code_model.public_model_types and code_model.options["models_mode"]%}
|
|
23
|
+
{% if code_model.public_model_types and code_model.options["models_mode"] == "msrest" %}
|
|
24
24
|
models = _models
|
|
25
25
|
|
|
26
26
|
{% endif %}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{{ code_model.options['license_header'] }}
|
|
2
|
+
import functools
|
|
3
|
+
|
|
4
|
+
def api_version_validation(**kwargs):
|
|
5
|
+
params_added_on = kwargs.pop("params_added_on", {})
|
|
6
|
+
method_added_on = kwargs.pop("method_added_on", "")
|
|
7
|
+
|
|
8
|
+
def decorator(func):
|
|
9
|
+
@functools.wraps(func)
|
|
10
|
+
def wrapper(*args, **kwargs):
|
|
11
|
+
try:
|
|
12
|
+
# this assumes the client has an _api_version attribute
|
|
13
|
+
client = args[0]
|
|
14
|
+
client_api_version = client._config.api_version # pylint: disable=protected-access
|
|
15
|
+
except AttributeError:
|
|
16
|
+
return func(*args, **kwargs)
|
|
17
|
+
|
|
18
|
+
if method_added_on > client_api_version:
|
|
19
|
+
raise ValueError(
|
|
20
|
+
f"'{func.__name__}' is not available in API version "
|
|
21
|
+
f"{client_api_version}. Pass service API version {method_added_on} or newer to your client."
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
unsupported = {
|
|
25
|
+
parameter: api_version
|
|
26
|
+
for api_version, parameters in params_added_on.items()
|
|
27
|
+
for parameter in parameters
|
|
28
|
+
if parameter in kwargs and api_version > client_api_version
|
|
29
|
+
}
|
|
30
|
+
if unsupported:
|
|
31
|
+
raise ValueError("".join([
|
|
32
|
+
f"'{param}' is not available in API version {client_api_version}. "
|
|
33
|
+
f"Use service API version {version} or newer.\n"
|
|
34
|
+
for param, version in unsupported.items()
|
|
35
|
+
]))
|
|
36
|
+
return func(*args, **kwargs)
|
|
37
|
+
return wrapper
|
|
38
|
+
return decorator
|
package/package.json
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.7",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"prepare": "node run-python3.js prepare.py",
|
|
7
|
-
"start": "node run-python3.js start.py",
|
|
8
|
-
"install": "node run-python3.js install.py",
|
|
9
|
-
"debug": "node run-python3.js start.py --debug"
|
|
10
|
-
},
|
|
11
5
|
"repository": {
|
|
12
6
|
"type": "git",
|
|
13
7
|
"url": "https://github.com/Azure/autorest.python/tree/autorestv3"
|
|
@@ -28,7 +22,7 @@
|
|
|
28
22
|
},
|
|
29
23
|
"devDependencies": {
|
|
30
24
|
"@microsoft.azure/autorest.testserver": "^3.3.38",
|
|
31
|
-
"typescript": "^4.
|
|
25
|
+
"typescript": "^4.8.3"
|
|
32
26
|
},
|
|
33
27
|
"files": [
|
|
34
28
|
"autorest/**/*.py",
|
|
@@ -41,5 +35,10 @@
|
|
|
41
35
|
"run-python3.js",
|
|
42
36
|
"requirements.txt",
|
|
43
37
|
"run_cadl.py"
|
|
44
|
-
]
|
|
45
|
-
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"start": "node run-python3.js start.py",
|
|
41
|
+
"install": "node run-python3.js install.py",
|
|
42
|
+
"debug": "node run-python3.js start.py --debug"
|
|
43
|
+
}
|
|
44
|
+
}
|