@autorest/python 6.9.6 → 6.9.8
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/codegen/__init__.py +27 -8
- package/autorest/codegen/models/base.py +2 -5
- package/autorest/codegen/models/client.py +12 -8
- package/autorest/codegen/models/code_model.py +5 -1
- package/autorest/codegen/models/combined_type.py +1 -1
- package/autorest/codegen/models/constant_type.py +1 -1
- package/autorest/codegen/models/credential_types.py +21 -11
- package/autorest/codegen/models/dictionary_type.py +1 -1
- package/autorest/codegen/models/enum_type.py +2 -2
- package/autorest/codegen/models/imports.py +18 -69
- package/autorest/codegen/models/list_type.py +1 -1
- package/autorest/codegen/models/model_type.py +1 -1
- package/autorest/codegen/models/operation.py +11 -15
- package/autorest/codegen/models/operation_group.py +2 -2
- package/autorest/codegen/models/paging_operation.py +4 -4
- package/autorest/codegen/models/parameter.py +1 -1
- package/autorest/codegen/models/primitive_types.py +12 -16
- package/autorest/codegen/models/property.py +1 -1
- package/autorest/codegen/models/request_builder.py +4 -4
- package/autorest/codegen/models/response.py +32 -10
- package/autorest/codegen/serializers/__init__.py +1 -1
- package/autorest/codegen/serializers/builder_serializer.py +15 -11
- package/autorest/codegen/serializers/client_serializer.py +4 -7
- package/autorest/codegen/serializers/enum_serializer.py +2 -1
- package/autorest/codegen/serializers/general_serializer.py +9 -10
- package/autorest/codegen/serializers/model_serializer.py +2 -2
- package/autorest/codegen/serializers/operation_groups_serializer.py +2 -1
- package/autorest/codegen/serializers/patch_serializer.py +2 -2
- package/autorest/codegen/serializers/request_builders_serializer.py +1 -1
- package/autorest/codegen/serializers/sample_serializer.py +17 -13
- package/autorest/codegen/serializers/types_serializer.py +1 -1
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_base.py.jinja2 +12 -9
- package/autorest/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_msrest.py.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +4 -4
- package/autorest/codegen/templates/patch.py.jinja2 +1 -1
- package/autorest/codegen/templates/serialization.py.jinja2 +4 -7
- package/autorest/multiapi/models/code_model.py +2 -0
- package/autorest/multiapi/serializers/__init__.py +1 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# coding=utf-8
|
|
2
2
|
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
|
|
4
4
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
5
5
|
# license information.
|
|
6
6
|
# --------------------------------------------------------------------------
|
|
@@ -19,10 +19,10 @@ import email
|
|
|
19
19
|
from datetime import datetime, date, time, timedelta, timezone
|
|
20
20
|
from json import JSONEncoder
|
|
21
21
|
import isodate
|
|
22
|
-
from {{
|
|
23
|
-
from {{
|
|
24
|
-
from {{
|
|
25
|
-
from {{
|
|
22
|
+
from {{ code_model.core_library }}.exceptions import DeserializationError
|
|
23
|
+
from {{ code_model.core_library }}{{ ".utils" if code_model.options["unbranded"] else "" }} import CaseInsensitiveEnumMeta
|
|
24
|
+
from {{ code_model.core_library }}.{{ "runtime." if code_model.options["unbranded"] else "" }}pipeline import PipelineResponse
|
|
25
|
+
from {{ code_model.core_library }}.serialization import _Null
|
|
26
26
|
|
|
27
27
|
if sys.version_info >= (3, 9):
|
|
28
28
|
from collections.abc import MutableMapping
|
|
@@ -31,7 +31,7 @@ else:
|
|
|
31
31
|
|
|
32
32
|
_LOGGER = logging.getLogger(__name__)
|
|
33
33
|
|
|
34
|
-
__all__ = ["
|
|
34
|
+
__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"]
|
|
35
35
|
|
|
36
36
|
TZ_UTC = timezone.utc
|
|
37
37
|
|
|
@@ -125,7 +125,7 @@ def _is_readonly(p):
|
|
|
125
125
|
return False
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
class
|
|
128
|
+
class SdkJSONEncoder(JSONEncoder):
|
|
129
129
|
"""A JSON encoder that's capable of serializing datetime objects and bytes."""
|
|
130
130
|
|
|
131
131
|
def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs):
|
|
@@ -140,7 +140,7 @@ class AzureJSONEncoder(JSONEncoder):
|
|
|
140
140
|
return {k: v for k, v in o.items() if k not in readonly_props}
|
|
141
141
|
return dict(o.items())
|
|
142
142
|
try:
|
|
143
|
-
return super(
|
|
143
|
+
return super(SdkJSONEncoder, self).default(o)
|
|
144
144
|
except TypeError:
|
|
145
145
|
if isinstance(o, _Null):
|
|
146
146
|
return None
|
|
@@ -157,7 +157,7 @@ class AzureJSONEncoder(JSONEncoder):
|
|
|
157
157
|
except AttributeError:
|
|
158
158
|
# This will be raised when it hits value.total_seconds in the method above
|
|
159
159
|
pass
|
|
160
|
-
return super(
|
|
160
|
+
return super(SdkJSONEncoder, self).default(o)
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")
|
|
@@ -754,9 +754,12 @@ def _deserialize(
|
|
|
754
754
|
value: typing.Any,
|
|
755
755
|
module: typing.Optional[str] = None,
|
|
756
756
|
rf: typing.Optional["_RestField"] = None,
|
|
757
|
+
format: typing.Optional[str] = None,
|
|
757
758
|
) -> typing.Any:
|
|
758
759
|
if isinstance(value, PipelineResponse):
|
|
759
760
|
value = value.http_response.json()
|
|
761
|
+
if rf is None and format:
|
|
762
|
+
rf = _RestField(format=format)
|
|
760
763
|
deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf)
|
|
761
764
|
return _deserialize_with_callable(deserializer, value)
|
|
762
765
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{% endif %}
|
|
15
15
|
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
16
16
|
|
|
17
|
-
All required parameters must be populated in order to send to
|
|
17
|
+
All required parameters must be populated in order to send to server.
|
|
18
18
|
{% endif %}
|
|
19
19
|
|
|
20
20
|
{% if model.properties != None %}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{% endif %}
|
|
16
16
|
{% if (model.properties | selectattr('optional', "equalto", false) | first) is defined %}
|
|
17
17
|
|
|
18
|
-
All required parameters must be populated in order to send to
|
|
18
|
+
All required parameters must be populated in order to send to server.
|
|
19
19
|
{% endif %}
|
|
20
20
|
|
|
21
21
|
{% if model.properties != None %}
|
|
@@ -67,7 +67,7 @@ Use the returned token credential to authenticate the client:
|
|
|
67
67
|
```python
|
|
68
68
|
>>> from {{ namespace }} import {{ client_name }}
|
|
69
69
|
>>> from azure.identity import DefaultAzureCredential
|
|
70
|
-
>>> from {{
|
|
70
|
+
>>> from {{ code_model.core_library }}.exceptions import HttpResponseError
|
|
71
71
|
|
|
72
72
|
>>> client = {{ client_name }}(endpoint='<endpoint>', credential=DefaultAzureCredential())
|
|
73
73
|
>>> try:
|
|
@@ -24,7 +24,7 @@ with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
|
|
|
24
24
|
|
|
25
25
|
if not version:
|
|
26
26
|
raise RuntimeError("Cannot find version information")
|
|
27
|
-
{% set description = "\"" + company_name + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
|
|
27
|
+
{% set description = "\"" + code_model.options["company_name"] + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
|
|
28
28
|
{% set author_email = "azpysdkhelp@microsoft.com" %}
|
|
29
29
|
{% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
|
|
30
30
|
{% else %}
|
|
@@ -43,10 +43,10 @@ setup(
|
|
|
43
43
|
long_description=open("README.md", "r").read(),
|
|
44
44
|
long_description_content_type="text/markdown",
|
|
45
45
|
license="MIT License",
|
|
46
|
-
author="{{ company_name }} Corporation",
|
|
46
|
+
author="{{ code_model.options["company_name"] }} Corporation",
|
|
47
47
|
{% endif %}
|
|
48
|
-
author_email="{{ author_email }}",
|
|
49
48
|
{% if not unbranded %}
|
|
49
|
+
author_email="{{ author_email }}",
|
|
50
50
|
url="{{ url }}",
|
|
51
51
|
keywords="azure, azure sdk",
|
|
52
52
|
{% endif %}
|
|
@@ -90,7 +90,7 @@ setup(
|
|
|
90
90
|
"isodate<1.0.0,>=0.6.1",
|
|
91
91
|
{% endif %}
|
|
92
92
|
{% if unbranded %}
|
|
93
|
-
"corehttp",
|
|
93
|
+
"corehttp[requests]",
|
|
94
94
|
{% elif azure_arm %}
|
|
95
95
|
"azure-mgmt-core<2.0.0,>=1.3.2",
|
|
96
96
|
{% else %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# --------------------------------------------------------------------------
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
|
|
4
4
|
#
|
|
5
5
|
# The MIT License (MIT)
|
|
6
6
|
#
|
|
@@ -63,8 +63,8 @@ import xml.etree.ElementTree as ET
|
|
|
63
63
|
|
|
64
64
|
import isodate # type: ignore
|
|
65
65
|
|
|
66
|
-
from {{
|
|
67
|
-
from {{
|
|
66
|
+
from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
|
|
67
|
+
from {{ code_model.core_library }}.serialization import NULL as CoreNull
|
|
68
68
|
|
|
69
69
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
70
70
|
|
|
@@ -732,7 +732,6 @@ class Serializer(object):
|
|
|
732
732
|
|
|
733
733
|
if kwargs.get("skip_quote") is True:
|
|
734
734
|
output = str(output)
|
|
735
|
-
# https://github.com/Azure/autorest.python/issues/2063
|
|
736
735
|
output = output.replace("{", quote("{")).replace("}", quote("}"))
|
|
737
736
|
else:
|
|
738
737
|
output = quote(str(output), safe="")
|
|
@@ -808,7 +807,7 @@ class Serializer(object):
|
|
|
808
807
|
raise ValueError("No value for given attribute")
|
|
809
808
|
|
|
810
809
|
try:
|
|
811
|
-
if data is
|
|
810
|
+
if data is CoreNull:
|
|
812
811
|
return None
|
|
813
812
|
if data_type in self.basic_types.values():
|
|
814
813
|
return self.serialize_basic(data, data_type, **kwargs)
|
|
@@ -1217,7 +1216,6 @@ def rest_key_extractor(attr, attr_desc, data):
|
|
|
1217
1216
|
if working_data is None:
|
|
1218
1217
|
# If at any point while following flatten JSON path see None, it means
|
|
1219
1218
|
# that all properties under are None as well
|
|
1220
|
-
# https://github.com/Azure/msrest-for-python/issues/197
|
|
1221
1219
|
return None
|
|
1222
1220
|
key = ".".join(dict_keys[1:])
|
|
1223
1221
|
|
|
@@ -1238,7 +1236,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data):
|
|
|
1238
1236
|
if working_data is None:
|
|
1239
1237
|
# If at any point while following flatten JSON path see None, it means
|
|
1240
1238
|
# that all properties under are None as well
|
|
1241
|
-
# https://github.com/Azure/msrest-for-python/issues/197
|
|
1242
1239
|
return None
|
|
1243
1240
|
key = ".".join(dict_keys[1:])
|
|
1244
1241
|
|
|
@@ -45,6 +45,8 @@ class CodeModel: # pylint: disable=too-many-instance-attributes
|
|
|
45
45
|
default_version_metadata["global_parameters"]
|
|
46
46
|
)
|
|
47
47
|
self.user_specified_default_api = user_specified_default_api
|
|
48
|
+
self.options: Dict[str, Any] = {"unbranded": False, "company_name": "Microsoft"}
|
|
49
|
+
self.core_library = "azure.core"
|
|
48
50
|
|
|
49
51
|
@property
|
|
50
52
|
def operation_groups(self) -> List[OperationGroup]:
|
|
@@ -150,8 +150,7 @@ class MultiAPISerializer(ReaderAndWriter): # pylint: disable=abstract-method
|
|
|
150
150
|
self.write_file(
|
|
151
151
|
Path("_serialization.py"),
|
|
152
152
|
codegen_env.get_template("serialization.py.jinja2").render(
|
|
153
|
-
|
|
154
|
-
import_core_serialization="azure.core.serialization",
|
|
153
|
+
code_model=code_model,
|
|
155
154
|
),
|
|
156
155
|
)
|
|
157
156
|
|