ignos-internal-api-client 20240925.0.10440__py3-none-any.whl → 20250905.0.12525__py3-none-any.whl
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.
- ignos/internal/api/client/__init__.py +9 -3
- ignos/internal/api/client/_client.py +2 -2
- ignos/internal/api/client/_configuration.py +1 -2
- ignos/internal/api/client/_patch.py +7 -6
- ignos/internal/api/client/_utils/__init__.py +6 -0
- ignos/internal/api/client/{_serialization.py → _utils/serialization.py} +70 -155
- ignos/internal/api/client/_version.py +1 -1
- ignos/internal/api/client/aio/__init__.py +9 -3
- ignos/internal/api/client/aio/_client.py +2 -2
- ignos/internal/api/client/aio/_configuration.py +1 -2
- ignos/internal/api/client/aio/_patch.py +7 -6
- ignos/internal/api/client/aio/operations/__init__.py +21 -15
- ignos/internal/api/client/aio/operations/_operations.py +191 -181
- ignos/internal/api/client/aio/operations/_patch.py +7 -6
- ignos/internal/api/client/models/__init__.py +58 -47
- ignos/internal/api/client/models/_models.py +68 -11
- ignos/internal/api/client/models/_patch.py +7 -6
- ignos/internal/api/client/operations/__init__.py +21 -15
- ignos/internal/api/client/operations/_operations.py +191 -174
- ignos/internal/api/client/operations/_patch.py +7 -6
- ignos_internal_api_client-20250905.0.12525.dist-info/METADATA +17 -0
- ignos_internal_api_client-20250905.0.12525.dist-info/RECORD +29 -0
- {ignos_internal_api_client-20240925.0.10440.dist-info → ignos_internal_api_client-20250905.0.12525.dist-info}/WHEEL +1 -1
- ignos_internal_api_client-20240925.0.10440.dist-info/METADATA +0 -13
- ignos_internal_api_client-20240925.0.10440.dist-info/RECORD +0 -28
- {ignos_internal_api_client-20240925.0.10440.dist-info → ignos_internal_api_client-20250905.0.12525.dist-info}/top_level.txt +0 -0
|
@@ -5,15 +5,21 @@
|
|
|
5
5
|
# Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
6
|
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
7
|
# --------------------------------------------------------------------------
|
|
8
|
+
# pylint: disable=wrong-import-position
|
|
8
9
|
|
|
9
|
-
from
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from ._patch import * # pylint: disable=unused-wildcard-import
|
|
14
|
+
|
|
15
|
+
from ._client import IgnosInternalApi # type: ignore
|
|
10
16
|
from ._version import VERSION
|
|
11
17
|
|
|
12
18
|
__version__ = VERSION
|
|
13
19
|
|
|
14
20
|
try:
|
|
15
21
|
from ._patch import __all__ as _patch_all
|
|
16
|
-
from ._patch import *
|
|
22
|
+
from ._patch import *
|
|
17
23
|
except ImportError:
|
|
18
24
|
_patch_all = []
|
|
19
25
|
from ._patch import patch_sdk as _patch_sdk
|
|
@@ -21,6 +27,6 @@ from ._patch import patch_sdk as _patch_sdk
|
|
|
21
27
|
__all__ = [
|
|
22
28
|
"IgnosInternalApi",
|
|
23
29
|
]
|
|
24
|
-
__all__.extend([p for p in _patch_all if p not in __all__])
|
|
30
|
+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
|
|
25
31
|
|
|
26
32
|
_patch_sdk()
|
|
@@ -16,7 +16,7 @@ from azure.core.rest import HttpRequest, HttpResponse
|
|
|
16
16
|
|
|
17
17
|
from . import models as _models
|
|
18
18
|
from ._configuration import IgnosInternalApiConfiguration
|
|
19
|
-
from .
|
|
19
|
+
from ._utils.serialization import Deserializer, Serializer
|
|
20
20
|
from .operations import (
|
|
21
21
|
AppsOperations,
|
|
22
22
|
AzureRegionsOperations,
|
|
@@ -34,7 +34,6 @@ from .operations import (
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
if TYPE_CHECKING:
|
|
37
|
-
# pylint: disable=unused-import,ungrouped-imports
|
|
38
37
|
from azure.core.credentials import TokenCredential
|
|
39
38
|
|
|
40
39
|
|
|
@@ -76,6 +75,7 @@ class IgnosInternalApi: # pylint: disable=client-accepts-api-version-keyword,to
|
|
|
76
75
|
|
|
77
76
|
def __init__(self, credential: "TokenCredential", *, endpoint: str = "", **kwargs: Any) -> None:
|
|
78
77
|
self._config = IgnosInternalApiConfiguration(credential=credential, **kwargs)
|
|
78
|
+
|
|
79
79
|
_policies = kwargs.pop("policies", None)
|
|
80
80
|
if _policies is None:
|
|
81
81
|
_policies = [
|
|
@@ -13,11 +13,10 @@ from azure.core.pipeline import policies
|
|
|
13
13
|
from ._version import VERSION
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
16
|
-
# pylint: disable=unused-import,ungrouped-imports
|
|
17
16
|
from azure.core.credentials import TokenCredential
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
class IgnosInternalApiConfiguration: # pylint: disable=too-many-instance-attributes
|
|
19
|
+
class IgnosInternalApiConfiguration: # pylint: disable=too-many-instance-attributes
|
|
21
20
|
"""Configuration for IgnosInternalApi.
|
|
22
21
|
|
|
23
22
|
Note that all parameters used to create this instance are saved as instance
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# --------------------------------------------------------------------------
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
5
6
|
"""Customize generated code here.
|
|
6
7
|
|
|
7
8
|
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
|
|
8
9
|
"""
|
|
9
|
-
from typing import List
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
__all__: list[str] = [] # Add all objects you want publicly available to users at this package level
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def patch_sdk():
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
|
5
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
6
|
+
# --------------------------------------------------------------------------
|
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
# pylint: disable=too-many-lines
|
|
1
|
+
# pylint: disable=line-too-long,useless-suppression,too-many-lines
|
|
2
|
+
# coding=utf-8
|
|
2
3
|
# --------------------------------------------------------------------------
|
|
3
|
-
#
|
|
4
4
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
# of this software and associated documentation files (the ""Software""), to
|
|
10
|
-
# deal in the Software without restriction, including without limitation the
|
|
11
|
-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
12
|
-
# sell copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
# furnished to do so, subject to the following conditions:
|
|
14
|
-
#
|
|
15
|
-
# The above copyright notice and this permission notice shall be included in
|
|
16
|
-
# all copies or substantial portions of the Software.
|
|
17
|
-
#
|
|
18
|
-
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
|
-
# IN THE SOFTWARE.
|
|
25
|
-
#
|
|
5
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
|
7
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
26
8
|
# --------------------------------------------------------------------------
|
|
27
9
|
|
|
28
10
|
# pyright: reportUnnecessaryTypeIgnoreComment=false
|
|
@@ -39,7 +21,6 @@ import re
|
|
|
39
21
|
import sys
|
|
40
22
|
import codecs
|
|
41
23
|
from typing import (
|
|
42
|
-
Dict,
|
|
43
24
|
Any,
|
|
44
25
|
cast,
|
|
45
26
|
Optional,
|
|
@@ -48,10 +29,7 @@ from typing import (
|
|
|
48
29
|
IO,
|
|
49
30
|
Mapping,
|
|
50
31
|
Callable,
|
|
51
|
-
TypeVar,
|
|
52
32
|
MutableMapping,
|
|
53
|
-
Type,
|
|
54
|
-
List,
|
|
55
33
|
)
|
|
56
34
|
|
|
57
35
|
try:
|
|
@@ -61,13 +39,13 @@ except ImportError:
|
|
|
61
39
|
import xml.etree.ElementTree as ET
|
|
62
40
|
|
|
63
41
|
import isodate # type: ignore
|
|
42
|
+
from typing_extensions import Self
|
|
64
43
|
|
|
65
44
|
from azure.core.exceptions import DeserializationError, SerializationError
|
|
66
45
|
from azure.core.serialization import NULL as CoreNull
|
|
67
46
|
|
|
68
47
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
69
48
|
|
|
70
|
-
ModelType = TypeVar("ModelType", bound="Model")
|
|
71
49
|
JSON = MutableMapping[str, Any]
|
|
72
50
|
|
|
73
51
|
|
|
@@ -185,73 +163,7 @@ try:
|
|
|
185
163
|
except NameError:
|
|
186
164
|
_long_type = int
|
|
187
165
|
|
|
188
|
-
|
|
189
|
-
class UTC(datetime.tzinfo):
|
|
190
|
-
"""Time Zone info for handling UTC"""
|
|
191
|
-
|
|
192
|
-
def utcoffset(self, dt):
|
|
193
|
-
"""UTF offset for UTC is 0.
|
|
194
|
-
|
|
195
|
-
:param datetime.datetime dt: The datetime
|
|
196
|
-
:returns: The offset
|
|
197
|
-
:rtype: datetime.timedelta
|
|
198
|
-
"""
|
|
199
|
-
return datetime.timedelta(0)
|
|
200
|
-
|
|
201
|
-
def tzname(self, dt):
|
|
202
|
-
"""Timestamp representation.
|
|
203
|
-
|
|
204
|
-
:param datetime.datetime dt: The datetime
|
|
205
|
-
:returns: The timestamp representation
|
|
206
|
-
:rtype: str
|
|
207
|
-
"""
|
|
208
|
-
return "Z"
|
|
209
|
-
|
|
210
|
-
def dst(self, dt):
|
|
211
|
-
"""No daylight saving for UTC.
|
|
212
|
-
|
|
213
|
-
:param datetime.datetime dt: The datetime
|
|
214
|
-
:returns: The daylight saving time
|
|
215
|
-
:rtype: datetime.timedelta
|
|
216
|
-
"""
|
|
217
|
-
return datetime.timedelta(hours=1)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
try:
|
|
221
|
-
from datetime import timezone as _FixedOffset # type: ignore
|
|
222
|
-
except ImportError: # Python 2.7
|
|
223
|
-
|
|
224
|
-
class _FixedOffset(datetime.tzinfo): # type: ignore
|
|
225
|
-
"""Fixed offset in minutes east from UTC.
|
|
226
|
-
Copy/pasted from Python doc
|
|
227
|
-
:param datetime.timedelta offset: offset in timedelta format
|
|
228
|
-
"""
|
|
229
|
-
|
|
230
|
-
def __init__(self, offset):
|
|
231
|
-
self.__offset = offset
|
|
232
|
-
|
|
233
|
-
def utcoffset(self, dt):
|
|
234
|
-
return self.__offset
|
|
235
|
-
|
|
236
|
-
def tzname(self, dt):
|
|
237
|
-
return str(self.__offset.total_seconds() / 3600)
|
|
238
|
-
|
|
239
|
-
def __repr__(self):
|
|
240
|
-
return "<FixedOffset {}>".format(self.tzname(None))
|
|
241
|
-
|
|
242
|
-
def dst(self, dt):
|
|
243
|
-
return datetime.timedelta(0)
|
|
244
|
-
|
|
245
|
-
def __getinitargs__(self):
|
|
246
|
-
return (self.__offset,)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
try:
|
|
250
|
-
from datetime import timezone
|
|
251
|
-
|
|
252
|
-
TZ_UTC = timezone.utc
|
|
253
|
-
except ImportError:
|
|
254
|
-
TZ_UTC = UTC() # type: ignore
|
|
166
|
+
TZ_UTC = datetime.timezone.utc
|
|
255
167
|
|
|
256
168
|
_FLATTEN = re.compile(r"(?<!\\)\.")
|
|
257
169
|
|
|
@@ -310,17 +222,17 @@ def _create_xml_node(tag, prefix=None, ns=None):
|
|
|
310
222
|
return ET.Element(tag)
|
|
311
223
|
|
|
312
224
|
|
|
313
|
-
class Model
|
|
225
|
+
class Model:
|
|
314
226
|
"""Mixin for all client request body/response body models to support
|
|
315
227
|
serialization and deserialization.
|
|
316
228
|
"""
|
|
317
229
|
|
|
318
|
-
_subtype_map:
|
|
319
|
-
_attribute_map:
|
|
320
|
-
_validation:
|
|
230
|
+
_subtype_map: dict[str, dict[str, Any]] = {}
|
|
231
|
+
_attribute_map: dict[str, dict[str, Any]] = {}
|
|
232
|
+
_validation: dict[str, dict[str, Any]] = {}
|
|
321
233
|
|
|
322
234
|
def __init__(self, **kwargs: Any) -> None:
|
|
323
|
-
self.additional_properties: Optional[
|
|
235
|
+
self.additional_properties: Optional[dict[str, Any]] = {}
|
|
324
236
|
for k in kwargs: # pylint: disable=consider-using-dict-items
|
|
325
237
|
if k not in self._attribute_map:
|
|
326
238
|
_LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__)
|
|
@@ -397,7 +309,7 @@ class Model(object):
|
|
|
397
309
|
def as_dict(
|
|
398
310
|
self,
|
|
399
311
|
keep_readonly: bool = True,
|
|
400
|
-
key_transformer: Callable[[str,
|
|
312
|
+
key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer,
|
|
401
313
|
**kwargs: Any
|
|
402
314
|
) -> JSON:
|
|
403
315
|
"""Return a dict that can be serialized using json.dump.
|
|
@@ -450,25 +362,25 @@ class Model(object):
|
|
|
450
362
|
return client_models
|
|
451
363
|
|
|
452
364
|
@classmethod
|
|
453
|
-
def deserialize(cls
|
|
365
|
+
def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self:
|
|
454
366
|
"""Parse a str using the RestAPI syntax and return a model.
|
|
455
367
|
|
|
456
368
|
:param str data: A str using RestAPI structure. JSON by default.
|
|
457
369
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
458
370
|
:returns: An instance of this model
|
|
459
|
-
:raises
|
|
460
|
-
:rtype:
|
|
371
|
+
:raises DeserializationError: if something went wrong
|
|
372
|
+
:rtype: Self
|
|
461
373
|
"""
|
|
462
374
|
deserializer = Deserializer(cls._infer_class_models())
|
|
463
375
|
return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
|
|
464
376
|
|
|
465
377
|
@classmethod
|
|
466
378
|
def from_dict(
|
|
467
|
-
cls
|
|
379
|
+
cls,
|
|
468
380
|
data: Any,
|
|
469
|
-
key_extractors: Optional[Callable[[str,
|
|
381
|
+
key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None,
|
|
470
382
|
content_type: Optional[str] = None,
|
|
471
|
-
) ->
|
|
383
|
+
) -> Self:
|
|
472
384
|
"""Parse a dict using given key extractor return a model.
|
|
473
385
|
|
|
474
386
|
By default consider key
|
|
@@ -479,8 +391,8 @@ class Model(object):
|
|
|
479
391
|
:param function key_extractors: A key extractor function.
|
|
480
392
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
481
393
|
:returns: An instance of this model
|
|
482
|
-
:raises
|
|
483
|
-
:rtype:
|
|
394
|
+
:raises DeserializationError: if something went wrong
|
|
395
|
+
:rtype: Self
|
|
484
396
|
"""
|
|
485
397
|
deserializer = Deserializer(cls._infer_class_models())
|
|
486
398
|
deserializer.key_extractors = ( # type: ignore
|
|
@@ -500,14 +412,13 @@ class Model(object):
|
|
|
500
412
|
return {}
|
|
501
413
|
result = dict(cls._subtype_map[key])
|
|
502
414
|
for valuetype in cls._subtype_map[key].values():
|
|
503
|
-
result
|
|
415
|
+
result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access
|
|
504
416
|
return result
|
|
505
417
|
|
|
506
418
|
@classmethod
|
|
507
419
|
def _classify(cls, response, objects):
|
|
508
420
|
"""Check the class _subtype_map for any child classes.
|
|
509
421
|
We want to ignore any inherited _subtype_maps.
|
|
510
|
-
Remove the polymorphic key from the initial data.
|
|
511
422
|
|
|
512
423
|
:param dict response: The initial data
|
|
513
424
|
:param dict objects: The class objects
|
|
@@ -519,7 +430,7 @@ class Model(object):
|
|
|
519
430
|
|
|
520
431
|
if not isinstance(response, ET.Element):
|
|
521
432
|
rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1]
|
|
522
|
-
subtype_value = response.
|
|
433
|
+
subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None)
|
|
523
434
|
else:
|
|
524
435
|
subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response)
|
|
525
436
|
if subtype_value:
|
|
@@ -564,7 +475,7 @@ def _decode_attribute_map_key(key):
|
|
|
564
475
|
return key.replace("\\.", ".")
|
|
565
476
|
|
|
566
477
|
|
|
567
|
-
class Serializer
|
|
478
|
+
class Serializer: # pylint: disable=too-many-public-methods
|
|
568
479
|
"""Request object model serializer."""
|
|
569
480
|
|
|
570
481
|
basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
|
|
@@ -599,7 +510,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
599
510
|
"multiple": lambda x, y: x % y != 0,
|
|
600
511
|
}
|
|
601
512
|
|
|
602
|
-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
|
|
513
|
+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
|
|
603
514
|
self.serialize_type = {
|
|
604
515
|
"iso-8601": Serializer.serialize_iso,
|
|
605
516
|
"rfc-1123": Serializer.serialize_rfc,
|
|
@@ -615,7 +526,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
615
526
|
"[]": self.serialize_iter,
|
|
616
527
|
"{}": self.serialize_dict,
|
|
617
528
|
}
|
|
618
|
-
self.dependencies:
|
|
529
|
+
self.dependencies: dict[str, type] = dict(classes) if classes else {}
|
|
619
530
|
self.key_transformer = full_restapi_key_transformer
|
|
620
531
|
self.client_side_validation = True
|
|
621
532
|
|
|
@@ -627,7 +538,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
627
538
|
:param object target_obj: The data to be serialized.
|
|
628
539
|
:param str data_type: The type to be serialized from.
|
|
629
540
|
:rtype: str, dict
|
|
630
|
-
:raises
|
|
541
|
+
:raises SerializationError: if serialization fails.
|
|
631
542
|
:returns: The serialized data.
|
|
632
543
|
"""
|
|
633
544
|
key_transformer = kwargs.get("key_transformer", self.key_transformer)
|
|
@@ -666,7 +577,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
666
577
|
|
|
667
578
|
if attr_name == "additional_properties" and attr_desc["key"] == "":
|
|
668
579
|
if target_obj.additional_properties is not None:
|
|
669
|
-
serialized
|
|
580
|
+
serialized |= target_obj.additional_properties
|
|
670
581
|
continue
|
|
671
582
|
try:
|
|
672
583
|
|
|
@@ -737,8 +648,8 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
737
648
|
:param object data: The data to be serialized.
|
|
738
649
|
:param str data_type: The type to be serialized from.
|
|
739
650
|
:rtype: dict
|
|
740
|
-
:raises
|
|
741
|
-
:raises
|
|
651
|
+
:raises SerializationError: if serialization fails.
|
|
652
|
+
:raises ValueError: if data is None
|
|
742
653
|
:returns: The serialized request body
|
|
743
654
|
"""
|
|
744
655
|
|
|
@@ -782,8 +693,8 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
782
693
|
:param str data_type: The type to be serialized from.
|
|
783
694
|
:rtype: str
|
|
784
695
|
:returns: The serialized URL path
|
|
785
|
-
:raises
|
|
786
|
-
:raises
|
|
696
|
+
:raises TypeError: if serialization fails.
|
|
697
|
+
:raises ValueError: if data is None
|
|
787
698
|
"""
|
|
788
699
|
try:
|
|
789
700
|
output = self.serialize_data(data, data_type, **kwargs)
|
|
@@ -806,8 +717,8 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
806
717
|
:param object data: The data to be serialized.
|
|
807
718
|
:param str data_type: The type to be serialized from.
|
|
808
719
|
:rtype: str, list
|
|
809
|
-
:raises
|
|
810
|
-
:raises
|
|
720
|
+
:raises TypeError: if serialization fails.
|
|
721
|
+
:raises ValueError: if data is None
|
|
811
722
|
:returns: The serialized query parameter
|
|
812
723
|
"""
|
|
813
724
|
try:
|
|
@@ -836,8 +747,8 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
836
747
|
:param object data: The data to be serialized.
|
|
837
748
|
:param str data_type: The type to be serialized from.
|
|
838
749
|
:rtype: str
|
|
839
|
-
:raises
|
|
840
|
-
:raises
|
|
750
|
+
:raises TypeError: if serialization fails.
|
|
751
|
+
:raises ValueError: if data is None
|
|
841
752
|
:returns: The serialized header
|
|
842
753
|
"""
|
|
843
754
|
try:
|
|
@@ -856,9 +767,9 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
856
767
|
|
|
857
768
|
:param object data: The data to be serialized.
|
|
858
769
|
:param str data_type: The type to be serialized from.
|
|
859
|
-
:raises
|
|
860
|
-
:raises
|
|
861
|
-
:raises
|
|
770
|
+
:raises AttributeError: if required data is None.
|
|
771
|
+
:raises ValueError: if data is None
|
|
772
|
+
:raises SerializationError: if serialization fails.
|
|
862
773
|
:returns: The serialized data.
|
|
863
774
|
:rtype: str, int, float, bool, dict, list
|
|
864
775
|
"""
|
|
@@ -1193,7 +1104,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
1193
1104
|
|
|
1194
1105
|
:param Datetime attr: Object to be serialized.
|
|
1195
1106
|
:rtype: str
|
|
1196
|
-
:raises
|
|
1107
|
+
:raises TypeError: if format invalid.
|
|
1197
1108
|
:return: serialized rfc
|
|
1198
1109
|
"""
|
|
1199
1110
|
try:
|
|
@@ -1219,7 +1130,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
1219
1130
|
|
|
1220
1131
|
:param Datetime attr: Object to be serialized.
|
|
1221
1132
|
:rtype: str
|
|
1222
|
-
:raises
|
|
1133
|
+
:raises SerializationError: if format invalid.
|
|
1223
1134
|
:return: serialized iso
|
|
1224
1135
|
"""
|
|
1225
1136
|
if isinstance(attr, str):
|
|
@@ -1252,7 +1163,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
|
|
|
1252
1163
|
|
|
1253
1164
|
:param Datetime attr: Object to be serialized.
|
|
1254
1165
|
:rtype: int
|
|
1255
|
-
:raises
|
|
1166
|
+
:raises SerializationError: if format invalid
|
|
1256
1167
|
:return: serialied unix
|
|
1257
1168
|
"""
|
|
1258
1169
|
if isinstance(attr, int):
|
|
@@ -1271,7 +1182,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen
|
|
|
1271
1182
|
|
|
1272
1183
|
while "." in key:
|
|
1273
1184
|
# Need the cast, as for some reasons "split" is typed as list[str | Any]
|
|
1274
|
-
dict_keys = cast(
|
|
1185
|
+
dict_keys = cast(list[str], _FLATTEN.split(key))
|
|
1275
1186
|
if len(dict_keys) == 1:
|
|
1276
1187
|
key = _decode_attribute_map_key(dict_keys[0])
|
|
1277
1188
|
break
|
|
@@ -1430,7 +1341,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
|
|
|
1430
1341
|
# Iter and wrapped, should have found one node only (the wrap one)
|
|
1431
1342
|
if len(children) != 1:
|
|
1432
1343
|
raise DeserializationError(
|
|
1433
|
-
"Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format(
|
|
1344
|
+
"Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format(
|
|
1434
1345
|
xml_name
|
|
1435
1346
|
)
|
|
1436
1347
|
)
|
|
@@ -1442,7 +1353,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
|
|
|
1442
1353
|
return children[0]
|
|
1443
1354
|
|
|
1444
1355
|
|
|
1445
|
-
class Deserializer
|
|
1356
|
+
class Deserializer:
|
|
1446
1357
|
"""Response object model deserializer.
|
|
1447
1358
|
|
|
1448
1359
|
:param dict classes: Class type dictionary for deserializing complex types.
|
|
@@ -1453,7 +1364,7 @@ class Deserializer(object):
|
|
|
1453
1364
|
|
|
1454
1365
|
valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")
|
|
1455
1366
|
|
|
1456
|
-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
|
|
1367
|
+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
|
|
1457
1368
|
self.deserialize_type = {
|
|
1458
1369
|
"iso-8601": Deserializer.deserialize_iso,
|
|
1459
1370
|
"rfc-1123": Deserializer.deserialize_rfc,
|
|
@@ -1473,7 +1384,7 @@ class Deserializer(object):
|
|
|
1473
1384
|
"duration": (isodate.Duration, datetime.timedelta),
|
|
1474
1385
|
"iso-8601": (datetime.datetime),
|
|
1475
1386
|
}
|
|
1476
|
-
self.dependencies:
|
|
1387
|
+
self.dependencies: dict[str, type] = dict(classes) if classes else {}
|
|
1477
1388
|
self.key_extractors = [rest_key_extractor, xml_key_extractor]
|
|
1478
1389
|
# Additional properties only works if the "rest_key_extractor" is used to
|
|
1479
1390
|
# extract the keys. Making it to work whatever the key extractor is too much
|
|
@@ -1489,7 +1400,7 @@ class Deserializer(object):
|
|
|
1489
1400
|
:param str target_obj: Target data type to deserialize to.
|
|
1490
1401
|
:param requests.Response response_data: REST response object.
|
|
1491
1402
|
:param str content_type: Swagger "produces" if available.
|
|
1492
|
-
:raises
|
|
1403
|
+
:raises DeserializationError: if deserialization fails.
|
|
1493
1404
|
:return: Deserialized object.
|
|
1494
1405
|
:rtype: object
|
|
1495
1406
|
"""
|
|
@@ -1503,7 +1414,7 @@ class Deserializer(object):
|
|
|
1503
1414
|
|
|
1504
1415
|
:param str target_obj: Target data type to deserialize to.
|
|
1505
1416
|
:param object data: Object to deserialize.
|
|
1506
|
-
:raises
|
|
1417
|
+
:raises DeserializationError: if deserialization fails.
|
|
1507
1418
|
:return: Deserialized object.
|
|
1508
1419
|
:rtype: object
|
|
1509
1420
|
"""
|
|
@@ -1684,17 +1595,21 @@ class Deserializer(object):
|
|
|
1684
1595
|
subtype = getattr(response, "_subtype_map", {})
|
|
1685
1596
|
try:
|
|
1686
1597
|
readonly = [
|
|
1687
|
-
k
|
|
1598
|
+
k
|
|
1599
|
+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
|
|
1600
|
+
if v.get("readonly")
|
|
1688
1601
|
]
|
|
1689
1602
|
const = [
|
|
1690
|
-
k
|
|
1603
|
+
k
|
|
1604
|
+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
|
|
1605
|
+
if v.get("constant")
|
|
1691
1606
|
]
|
|
1692
1607
|
kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const}
|
|
1693
1608
|
response_obj = response(**kwargs)
|
|
1694
1609
|
for attr in readonly:
|
|
1695
1610
|
setattr(response_obj, attr, attrs.get(attr))
|
|
1696
1611
|
if additional_properties:
|
|
1697
|
-
response_obj.additional_properties = additional_properties
|
|
1612
|
+
response_obj.additional_properties = additional_properties # type: ignore
|
|
1698
1613
|
return response_obj
|
|
1699
1614
|
except TypeError as err:
|
|
1700
1615
|
msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore
|
|
@@ -1714,7 +1629,7 @@ class Deserializer(object):
|
|
|
1714
1629
|
|
|
1715
1630
|
:param str data: The response string to be deserialized.
|
|
1716
1631
|
:param str data_type: The type to deserialize to.
|
|
1717
|
-
:raises
|
|
1632
|
+
:raises DeserializationError: if deserialization fails.
|
|
1718
1633
|
:return: Deserialized object.
|
|
1719
1634
|
:rtype: object
|
|
1720
1635
|
"""
|
|
@@ -1796,7 +1711,7 @@ class Deserializer(object):
|
|
|
1796
1711
|
:param dict attr: Dictionary to be deserialized.
|
|
1797
1712
|
:return: Deserialized object.
|
|
1798
1713
|
:rtype: dict
|
|
1799
|
-
:raises
|
|
1714
|
+
:raises TypeError: if non-builtin datatype encountered.
|
|
1800
1715
|
"""
|
|
1801
1716
|
if attr is None:
|
|
1802
1717
|
return None
|
|
@@ -1842,7 +1757,7 @@ class Deserializer(object):
|
|
|
1842
1757
|
:param str data_type: deserialization data type.
|
|
1843
1758
|
:return: Deserialized basic type.
|
|
1844
1759
|
:rtype: str, int, float or bool
|
|
1845
|
-
:raises
|
|
1760
|
+
:raises TypeError: if string format is not valid.
|
|
1846
1761
|
"""
|
|
1847
1762
|
# If we're here, data is supposed to be a basic type.
|
|
1848
1763
|
# If it's still an XML node, take the text
|
|
@@ -1933,7 +1848,7 @@ class Deserializer(object):
|
|
|
1933
1848
|
:param str attr: response string to be deserialized.
|
|
1934
1849
|
:return: Deserialized bytearray
|
|
1935
1850
|
:rtype: bytearray
|
|
1936
|
-
:raises
|
|
1851
|
+
:raises TypeError: if string format invalid.
|
|
1937
1852
|
"""
|
|
1938
1853
|
if isinstance(attr, ET.Element):
|
|
1939
1854
|
attr = attr.text
|
|
@@ -1946,7 +1861,7 @@ class Deserializer(object):
|
|
|
1946
1861
|
:param str attr: response string to be deserialized.
|
|
1947
1862
|
:return: Deserialized base64 string
|
|
1948
1863
|
:rtype: bytearray
|
|
1949
|
-
:raises
|
|
1864
|
+
:raises TypeError: if string format invalid.
|
|
1950
1865
|
"""
|
|
1951
1866
|
if isinstance(attr, ET.Element):
|
|
1952
1867
|
attr = attr.text
|
|
@@ -1961,7 +1876,7 @@ class Deserializer(object):
|
|
|
1961
1876
|
|
|
1962
1877
|
:param str attr: response string to be deserialized.
|
|
1963
1878
|
:return: Deserialized decimal
|
|
1964
|
-
:raises
|
|
1879
|
+
:raises DeserializationError: if string format invalid.
|
|
1965
1880
|
:rtype: decimal
|
|
1966
1881
|
"""
|
|
1967
1882
|
if isinstance(attr, ET.Element):
|
|
@@ -1979,7 +1894,7 @@ class Deserializer(object):
|
|
|
1979
1894
|
:param str attr: response string to be deserialized.
|
|
1980
1895
|
:return: Deserialized int
|
|
1981
1896
|
:rtype: long or int
|
|
1982
|
-
:raises
|
|
1897
|
+
:raises ValueError: if string format invalid.
|
|
1983
1898
|
"""
|
|
1984
1899
|
if isinstance(attr, ET.Element):
|
|
1985
1900
|
attr = attr.text
|
|
@@ -1992,7 +1907,7 @@ class Deserializer(object):
|
|
|
1992
1907
|
:param str attr: response string to be deserialized.
|
|
1993
1908
|
:return: Deserialized duration
|
|
1994
1909
|
:rtype: TimeDelta
|
|
1995
|
-
:raises
|
|
1910
|
+
:raises DeserializationError: if string format invalid.
|
|
1996
1911
|
"""
|
|
1997
1912
|
if isinstance(attr, ET.Element):
|
|
1998
1913
|
attr = attr.text
|
|
@@ -2010,7 +1925,7 @@ class Deserializer(object):
|
|
|
2010
1925
|
:param str attr: response string to be deserialized.
|
|
2011
1926
|
:return: Deserialized date
|
|
2012
1927
|
:rtype: Date
|
|
2013
|
-
:raises
|
|
1928
|
+
:raises DeserializationError: if string format invalid.
|
|
2014
1929
|
"""
|
|
2015
1930
|
if isinstance(attr, ET.Element):
|
|
2016
1931
|
attr = attr.text
|
|
@@ -2026,7 +1941,7 @@ class Deserializer(object):
|
|
|
2026
1941
|
:param str attr: response string to be deserialized.
|
|
2027
1942
|
:return: Deserialized time
|
|
2028
1943
|
:rtype: datetime.time
|
|
2029
|
-
:raises
|
|
1944
|
+
:raises DeserializationError: if string format invalid.
|
|
2030
1945
|
"""
|
|
2031
1946
|
if isinstance(attr, ET.Element):
|
|
2032
1947
|
attr = attr.text
|
|
@@ -2041,14 +1956,14 @@ class Deserializer(object):
|
|
|
2041
1956
|
:param str attr: response string to be deserialized.
|
|
2042
1957
|
:return: Deserialized RFC datetime
|
|
2043
1958
|
:rtype: Datetime
|
|
2044
|
-
:raises
|
|
1959
|
+
:raises DeserializationError: if string format invalid.
|
|
2045
1960
|
"""
|
|
2046
1961
|
if isinstance(attr, ET.Element):
|
|
2047
1962
|
attr = attr.text
|
|
2048
1963
|
try:
|
|
2049
1964
|
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
|
|
2050
1965
|
date_obj = datetime.datetime(
|
|
2051
|
-
*parsed_date[:6], tzinfo=
|
|
1966
|
+
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
|
|
2052
1967
|
)
|
|
2053
1968
|
if not date_obj.tzinfo:
|
|
2054
1969
|
date_obj = date_obj.astimezone(tz=TZ_UTC)
|
|
@@ -2064,7 +1979,7 @@ class Deserializer(object):
|
|
|
2064
1979
|
:param str attr: response string to be deserialized.
|
|
2065
1980
|
:return: Deserialized ISO datetime
|
|
2066
1981
|
:rtype: Datetime
|
|
2067
|
-
:raises
|
|
1982
|
+
:raises DeserializationError: if string format invalid.
|
|
2068
1983
|
"""
|
|
2069
1984
|
if isinstance(attr, ET.Element):
|
|
2070
1985
|
attr = attr.text
|
|
@@ -2102,7 +2017,7 @@ class Deserializer(object):
|
|
|
2102
2017
|
:param int attr: Object to be serialized.
|
|
2103
2018
|
:return: Deserialized datetime
|
|
2104
2019
|
:rtype: Datetime
|
|
2105
|
-
:raises
|
|
2020
|
+
:raises DeserializationError: if format invalid
|
|
2106
2021
|
"""
|
|
2107
2022
|
if isinstance(attr, ET.Element):
|
|
2108
2023
|
attr = int(attr.text) # type: ignore
|