diracx-client 0.0.1a10__py3-none-any.whl → 0.0.1a12__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.
diracx/client/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # coding=utf-8
2
2
  # --------------------------------------------------------------------------
3
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
3
+ # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
4
4
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
5
5
  # --------------------------------------------------------------------------
6
6
 
diracx/client/_client.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # coding=utf-8
2
2
  # --------------------------------------------------------------------------
3
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
3
+ # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
4
4
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
5
5
  # --------------------------------------------------------------------------
6
6
 
@@ -8,6 +8,7 @@ from copy import deepcopy
8
8
  from typing import Any
9
9
 
10
10
  from azure.core import PipelineClient
11
+ from azure.core.pipeline import policies
11
12
  from azure.core.rest import HttpRequest, HttpResponse
12
13
 
13
14
  from . import models as _models
@@ -40,8 +41,29 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
40
41
  self, *, endpoint: str = "", **kwargs: Any
41
42
  ) -> None:
42
43
  self._config = DiracConfiguration(**kwargs)
44
+ _policies = kwargs.pop("policies", None)
45
+ if _policies is None:
46
+ _policies = [
47
+ policies.RequestIdPolicy(**kwargs),
48
+ self._config.headers_policy,
49
+ self._config.user_agent_policy,
50
+ self._config.proxy_policy,
51
+ policies.ContentDecodePolicy(**kwargs),
52
+ self._config.redirect_policy,
53
+ self._config.retry_policy,
54
+ self._config.authentication_policy,
55
+ self._config.custom_hook_policy,
56
+ self._config.logging_policy,
57
+ policies.DistributedTracingPolicy(**kwargs),
58
+ (
59
+ policies.SensitiveHeaderCleanupPolicy(**kwargs)
60
+ if self._config.redirect_policy
61
+ else None
62
+ ),
63
+ self._config.http_logging_policy,
64
+ ]
43
65
  self._client: PipelineClient = PipelineClient(
44
- base_url=endpoint, config=self._config, **kwargs
66
+ base_url=endpoint, policies=_policies, **kwargs
45
67
  )
46
68
 
47
69
  client_models = {
@@ -53,7 +75,7 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
53
75
  self.well_known = WellKnownOperations(
54
76
  self._client, self._config, self._serialize, self._deserialize
55
77
  )
56
- self.auth = AuthOperations( # pylint: disable=abstract-class-instantiated
78
+ self.auth = AuthOperations(
57
79
  self._client, self._config, self._serialize, self._deserialize
58
80
  )
59
81
  self.config = ConfigOperations(
@@ -63,7 +85,9 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
63
85
  self._client, self._config, self._serialize, self._deserialize
64
86
  )
65
87
 
66
- def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
88
+ def send_request(
89
+ self, request: HttpRequest, *, stream: bool = False, **kwargs: Any
90
+ ) -> HttpResponse:
67
91
  """Runs the network request through the client's chained policies.
68
92
 
69
93
  >>> from azure.core.rest import HttpRequest
@@ -83,7 +107,7 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
83
107
 
84
108
  request_copy = deepcopy(request)
85
109
  request_copy.url = self._client.format_url(request_copy.url)
86
- return self._client.send_request(request_copy, **kwargs)
110
+ return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
87
111
 
88
112
  def close(self) -> None:
89
113
  self._client.close()
@@ -1,18 +1,17 @@
1
1
  # coding=utf-8
2
2
  # --------------------------------------------------------------------------
3
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
3
+ # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
4
4
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
5
5
  # --------------------------------------------------------------------------
6
6
 
7
7
  from typing import Any
8
8
 
9
- from azure.core.configuration import Configuration
10
9
  from azure.core.pipeline import policies
11
10
 
12
11
  VERSION = "unknown"
13
12
 
14
13
 
15
- class DiracConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
14
+ class DiracConfiguration: # pylint: disable=too-many-instance-attributes
16
15
  """Configuration for Dirac.
17
16
 
18
17
  Note that all parameters used to create this instance are saved as instance
@@ -20,9 +19,9 @@ class DiracConfiguration(Configuration): # pylint: disable=too-many-instance-at
20
19
  """
21
20
 
22
21
  def __init__(self, **kwargs: Any) -> None:
23
- super(DiracConfiguration, self).__init__(**kwargs)
24
22
 
25
23
  kwargs.setdefault("sdk_moniker", "dirac/{}".format(VERSION))
24
+ self.polling_interval = kwargs.get("polling_interval", 30)
26
25
  self._configure(**kwargs)
27
26
 
28
27
  def _configure(self, **kwargs: Any) -> None:
@@ -39,11 +38,11 @@ class DiracConfiguration(Configuration): # pylint: disable=too-many-instance-at
39
38
  self.http_logging_policy = kwargs.get(
40
39
  "http_logging_policy"
41
40
  ) or policies.HttpLoggingPolicy(**kwargs)
42
- self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
43
41
  self.custom_hook_policy = kwargs.get(
44
42
  "custom_hook_policy"
45
43
  ) or policies.CustomHookPolicy(**kwargs)
46
44
  self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(
47
45
  **kwargs
48
46
  )
47
+ self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
49
48
  self.authentication_policy = kwargs.get("authentication_policy")
@@ -63,12 +63,8 @@ import xml.etree.ElementTree as ET
63
63
 
64
64
  import isodate # type: ignore
65
65
 
66
- from azure.core.exceptions import (
67
- DeserializationError,
68
- SerializationError,
69
- raise_with_traceback,
70
- )
71
- from azure.core.serialization import NULL as AzureCoreNull
66
+ from azure.core.exceptions import DeserializationError, SerializationError
67
+ from azure.core.serialization import NULL as CoreNull
72
68
 
73
69
  _BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
74
70
 
@@ -77,6 +73,7 @@ JSON = MutableMapping[str, Any]
77
73
 
78
74
 
79
75
  class RawDeserializer:
76
+
80
77
  # Accept "text" because we're open minded people...
81
78
  JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$")
82
79
 
@@ -120,6 +117,7 @@ class RawDeserializer:
120
117
  raise DeserializationError("JSON is invalid: {}".format(err), err)
121
118
  elif "xml" in (content_type or []):
122
119
  try:
120
+
123
121
  try:
124
122
  if isinstance(data, unicode): # type: ignore
125
123
  # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string
@@ -128,7 +126,7 @@ class RawDeserializer:
128
126
  pass
129
127
 
130
128
  return ET.fromstring(data_as_str) # nosec
131
- except ET.ParseError:
129
+ except ET.ParseError as err:
132
130
  # It might be because the server has an issue, and returned JSON with
133
131
  # content-type XML....
134
132
  # So let's try a JSON load, and if it's still broken
@@ -147,7 +145,7 @@ class RawDeserializer:
147
145
  # The function hack is because Py2.7 messes up with exception
148
146
  # context otherwise.
149
147
  _LOGGER.critical("Wasn't XML not JSON, failing")
150
- raise_with_traceback(DeserializationError, "XML is invalid")
148
+ raise DeserializationError("XML is invalid") from err
151
149
  raise DeserializationError(
152
150
  "Cannot deserialize content-type: {}".format(content_type)
153
151
  )
@@ -178,13 +176,6 @@ class RawDeserializer:
178
176
  return None
179
177
 
180
178
 
181
- try:
182
- basestring # type: ignore
183
- unicode_str = unicode # type: ignore
184
- except NameError:
185
- basestring = str
186
- unicode_str = str
187
-
188
179
  _LOGGER = logging.getLogger(__name__)
189
180
 
190
181
  try:
@@ -303,7 +294,7 @@ class Model(object):
303
294
  _validation: Dict[str, Dict[str, Any]] = {}
304
295
 
305
296
  def __init__(self, **kwargs: Any) -> None:
306
- self.additional_properties: Dict[str, Any] = {}
297
+ self.additional_properties: Optional[Dict[str, Any]] = {}
307
298
  for k in kwargs:
308
299
  if k not in self._attribute_map:
309
300
  _LOGGER.warning(
@@ -360,7 +351,7 @@ class Model(object):
360
351
  )
361
352
 
362
353
  def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON:
363
- """Return the JSON that would be sent to azure from this model.
354
+ """Return the JSON that would be sent to server from this model.
364
355
 
365
356
  This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`.
366
357
 
@@ -371,7 +362,7 @@ class Model(object):
371
362
  :rtype: dict
372
363
  """
373
364
  serializer = Serializer(self._infer_class_models())
374
- return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs)
365
+ return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore
375
366
 
376
367
  def as_dict(
377
368
  self,
@@ -412,9 +403,7 @@ class Model(object):
412
403
  :rtype: dict
413
404
  """
414
405
  serializer = Serializer(self._infer_class_models())
415
- return serializer._serialize(
416
- self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs
417
- )
406
+ return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore
418
407
 
419
408
  @classmethod
420
409
  def _infer_class_models(cls):
@@ -443,7 +432,7 @@ class Model(object):
443
432
  :raises: DeserializationError if something went wrong
444
433
  """
445
434
  deserializer = Deserializer(cls._infer_class_models())
446
- return deserializer(cls.__name__, data, content_type=content_type)
435
+ return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
447
436
 
448
437
  @classmethod
449
438
  def from_dict(
@@ -473,7 +462,7 @@ class Model(object):
473
462
  if key_extractors is None
474
463
  else key_extractors
475
464
  )
476
- return deserializer(cls.__name__, data, content_type=content_type)
465
+ return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
477
466
 
478
467
  @classmethod
479
468
  def _flatten_subtype(cls, key, objects):
@@ -581,7 +570,7 @@ class Serializer(object):
581
570
  "multiple": lambda x, y: x % y != 0,
582
571
  }
583
572
 
584
- def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
573
+ def __init__(self, classes: Optional[Mapping[str, type]] = None):
585
574
  self.serialize_type = {
586
575
  "iso-8601": Serializer.serialize_iso,
587
576
  "rfc-1123": Serializer.serialize_rfc,
@@ -597,7 +586,7 @@ class Serializer(object):
597
586
  "[]": self.serialize_iter,
598
587
  "{}": self.serialize_dict,
599
588
  }
600
- self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
589
+ self.dependencies: Dict[str, type] = dict(classes) if classes else {}
601
590
  self.key_transformer = full_restapi_key_transformer
602
591
  self.client_side_validation = True
603
592
 
@@ -650,6 +639,7 @@ class Serializer(object):
650
639
  serialized.update(target_obj.additional_properties)
651
640
  continue
652
641
  try:
642
+
653
643
  orig_attr = getattr(target_obj, attr)
654
644
  if is_xml_model_serialization:
655
645
  pass # Don't provide "transformer" for XML for now. Keep "orig_attr"
@@ -692,7 +682,7 @@ class Serializer(object):
692
682
  else: # That's a basic type
693
683
  # Integrate namespace if necessary
694
684
  local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
695
- local_node.text = unicode_str(new_attr)
685
+ local_node.text = str(new_attr)
696
686
  serialized.append(local_node) # type: ignore
697
687
  else: # JSON
698
688
  for k in reversed(keys): # type: ignore
@@ -705,14 +695,15 @@ class Serializer(object):
705
695
  _serialized.update(_new_attr) # type: ignore
706
696
  _new_attr = _new_attr[k] # type: ignore
707
697
  _serialized = _serialized[k]
708
- except ValueError:
709
- continue
698
+ except ValueError as err:
699
+ if isinstance(err, SerializationError):
700
+ raise
710
701
 
711
702
  except (AttributeError, KeyError, TypeError) as err:
712
703
  msg = "Attribute {} in object {} cannot be serialized.\n{}".format(
713
704
  attr_name, class_name, str(target_obj)
714
705
  )
715
- raise_with_traceback(SerializationError, msg, err)
706
+ raise SerializationError(msg) from err
716
707
  else:
717
708
  return serialized
718
709
 
@@ -756,9 +747,9 @@ class Serializer(object):
756
747
  ]
757
748
  data = deserializer._deserialize(data_type, data)
758
749
  except DeserializationError as err:
759
- raise_with_traceback(
760
- SerializationError, "Unable to build a model: " + str(err), err
761
- )
750
+ raise SerializationError(
751
+ "Unable to build a model: " + str(err)
752
+ ) from err
762
753
 
763
754
  return self._serialize(data, data_type, **kwargs)
764
755
 
@@ -778,6 +769,7 @@ class Serializer(object):
778
769
 
779
770
  if kwargs.get("skip_quote") is True:
780
771
  output = str(output)
772
+ output = output.replace("{", quote("{")).replace("}", quote("}"))
781
773
  else:
782
774
  output = quote(str(output), safe="")
783
775
  except SerializationError:
@@ -790,7 +782,9 @@ class Serializer(object):
790
782
 
791
783
  :param data: The data to be serialized.
792
784
  :param str data_type: The type to be serialized from.
793
- :rtype: str
785
+ :keyword bool skip_quote: Whether to skip quote the serialized result.
786
+ Defaults to False.
787
+ :rtype: str, list
794
788
  :raises: TypeError if serialization fails.
795
789
  :raises: ValueError if data is None
796
790
  """
@@ -798,15 +792,10 @@ class Serializer(object):
798
792
  # Treat the list aside, since we don't want to encode the div separator
799
793
  if data_type.startswith("["):
800
794
  internal_data_type = data_type[1:-1]
801
- data = [
802
- self.serialize_data(d, internal_data_type, **kwargs)
803
- if d is not None
804
- else ""
805
- for d in data
806
- ]
807
- if not kwargs.get("skip_quote", False):
808
- data = [quote(str(d), safe="") for d in data]
809
- return str(self.serialize_iter(data, internal_data_type, **kwargs))
795
+ do_quote = not kwargs.get("skip_quote", False)
796
+ return self.serialize_iter(
797
+ data, internal_data_type, do_quote=do_quote, **kwargs
798
+ )
810
799
 
811
800
  # Not a list, regular serialization
812
801
  output = self.serialize_data(data, data_type, **kwargs)
@@ -857,7 +846,7 @@ class Serializer(object):
857
846
  raise ValueError("No value for given attribute")
858
847
 
859
848
  try:
860
- if data is AzureCoreNull:
849
+ if data is CoreNull:
861
850
  return None
862
851
  if data_type in self.basic_types.values():
863
852
  return self.serialize_basic(data, data_type, **kwargs)
@@ -877,7 +866,7 @@ class Serializer(object):
877
866
 
878
867
  except (ValueError, TypeError) as err:
879
868
  msg = "Unable to serialize value: {!r} as type: {!r}."
880
- raise_with_traceback(SerializationError, msg.format(data, data_type), err)
869
+ raise SerializationError(msg.format(data, data_type)) from err
881
870
  else:
882
871
  return self._serialize(data, **kwargs)
883
872
 
@@ -945,6 +934,8 @@ class Serializer(object):
945
934
  not be None or empty.
946
935
  :param str div: If set, this str will be used to combine the elements
947
936
  in the iterable into a combined string. Default is 'None'.
937
+ :keyword bool do_quote: Whether to quote the serialized result of each iterable element.
938
+ Defaults to False.
948
939
  :rtype: list, str
949
940
  """
950
941
  if isinstance(data, str):
@@ -957,9 +948,16 @@ class Serializer(object):
957
948
  for d in data:
958
949
  try:
959
950
  serialized.append(self.serialize_data(d, iter_type, **kwargs))
960
- except ValueError:
951
+ except ValueError as err:
952
+ if isinstance(err, SerializationError):
953
+ raise
961
954
  serialized.append(None)
962
955
 
956
+ if kwargs.get("do_quote", False):
957
+ serialized = [
958
+ "" if s is None else quote(str(s), safe="") for s in serialized
959
+ ]
960
+
963
961
  if div:
964
962
  serialized = ["" if s is None else str(s) for s in serialized]
965
963
  serialized = div.join(serialized)
@@ -1012,7 +1010,9 @@ class Serializer(object):
1012
1010
  serialized[self.serialize_unicode(key)] = self.serialize_data(
1013
1011
  value, dict_type, **kwargs
1014
1012
  )
1015
- except ValueError:
1013
+ except ValueError as err:
1014
+ if isinstance(err, SerializationError):
1015
+ raise
1016
1016
  serialized[self.serialize_unicode(key)] = None
1017
1017
 
1018
1018
  if "xml" in serialization_ctxt:
@@ -1047,7 +1047,7 @@ class Serializer(object):
1047
1047
  return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
1048
1048
  if obj_type is _long_type:
1049
1049
  return self.serialize_long(attr)
1050
- if obj_type is unicode_str:
1050
+ if obj_type is str:
1051
1051
  return self.serialize_unicode(attr)
1052
1052
  if obj_type is datetime.datetime:
1053
1053
  return self.serialize_iso(attr)
@@ -1231,10 +1231,10 @@ class Serializer(object):
1231
1231
  return date + microseconds + "Z"
1232
1232
  except (ValueError, OverflowError) as err:
1233
1233
  msg = "Unable to serialize datetime object."
1234
- raise_with_traceback(SerializationError, msg, err)
1234
+ raise SerializationError(msg) from err
1235
1235
  except AttributeError as err:
1236
1236
  msg = "ISO-8601 object must be valid Datetime object."
1237
- raise_with_traceback(TypeError, msg, err)
1237
+ raise TypeError(msg) from err
1238
1238
 
1239
1239
  @staticmethod
1240
1240
  def serialize_unix(attr, **kwargs):
@@ -1270,7 +1270,6 @@ def rest_key_extractor(attr, attr_desc, data):
1270
1270
  if working_data is None:
1271
1271
  # If at any point while following flatten JSON path see None, it means
1272
1272
  # that all properties under are None as well
1273
- # https://github.com/Azure/msrest-for-python/issues/197
1274
1273
  return None
1275
1274
  key = ".".join(dict_keys[1:])
1276
1275
 
@@ -1293,7 +1292,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data):
1293
1292
  if working_data is None:
1294
1293
  # If at any point while following flatten JSON path see None, it means
1295
1294
  # that all properties under are None as well
1296
- # https://github.com/Azure/msrest-for-python/issues/197
1297
1295
  return None
1298
1296
  key = ".".join(dict_keys[1:])
1299
1297
 
@@ -1443,7 +1441,7 @@ class Deserializer(object):
1443
1441
  r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?"
1444
1442
  )
1445
1443
 
1446
- def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
1444
+ def __init__(self, classes: Optional[Mapping[str, type]] = None):
1447
1445
  self.deserialize_type = {
1448
1446
  "iso-8601": Deserializer.deserialize_iso,
1449
1447
  "rfc-1123": Deserializer.deserialize_rfc,
@@ -1463,7 +1461,7 @@ class Deserializer(object):
1463
1461
  "duration": (isodate.Duration, datetime.timedelta),
1464
1462
  "iso-8601": (datetime.datetime),
1465
1463
  }
1466
- self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
1464
+ self.dependencies: Dict[str, type] = dict(classes) if classes else {}
1467
1465
  self.key_extractors = [rest_key_extractor, xml_key_extractor]
1468
1466
  # Additional properties only works if the "rest_key_extractor" is used to
1469
1467
  # extract the keys. Making it to work whatever the key extractor is too much
@@ -1522,7 +1520,7 @@ class Deserializer(object):
1522
1520
 
1523
1521
  response, class_name = self._classify_target(target_obj, data)
1524
1522
 
1525
- if isinstance(response, basestring):
1523
+ if isinstance(response, str):
1526
1524
  return self.deserialize_data(data, response)
1527
1525
  elif isinstance(response, type) and issubclass(response, Enum):
1528
1526
  return self.deserialize_enum(data, response)
@@ -1559,7 +1557,7 @@ class Deserializer(object):
1559
1557
  d_attrs[attr] = value
1560
1558
  except (AttributeError, TypeError, KeyError) as err:
1561
1559
  msg = "Unable to deserialize to object: " + class_name # type: ignore
1562
- raise_with_traceback(DeserializationError, msg, err)
1560
+ raise DeserializationError(msg) from err
1563
1561
  else:
1564
1562
  additional_properties = self._build_additional_properties(attributes, data)
1565
1563
  return self._instantiate_model(response, d_attrs, additional_properties)
@@ -1596,14 +1594,14 @@ class Deserializer(object):
1596
1594
  if target is None:
1597
1595
  return None, None
1598
1596
 
1599
- if isinstance(target, basestring):
1597
+ if isinstance(target, str):
1600
1598
  try:
1601
1599
  target = self.dependencies[target]
1602
1600
  except KeyError:
1603
1601
  return target, target
1604
1602
 
1605
1603
  try:
1606
- target = target._classify(data, self.dependencies)
1604
+ target = target._classify(data, self.dependencies) # type: ignore
1607
1605
  except AttributeError:
1608
1606
  pass # Target is not a Model, no classify
1609
1607
  return target, target.__class__.__name__ # type: ignore
@@ -1666,7 +1664,7 @@ class Deserializer(object):
1666
1664
  raw_data.text, raw_data.headers
1667
1665
  )
1668
1666
 
1669
- if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
1667
+ if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
1670
1668
  return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
1671
1669
  return raw_data
1672
1670
 
@@ -1754,7 +1752,7 @@ class Deserializer(object):
1754
1752
  except (ValueError, TypeError, AttributeError) as err:
1755
1753
  msg = "Unable to deserialize response data."
1756
1754
  msg += " Data: {}, {}".format(data, data_type)
1757
- raise_with_traceback(DeserializationError, msg, err)
1755
+ raise DeserializationError(msg) from err
1758
1756
  else:
1759
1757
  return self._deserialize(obj_type, data)
1760
1758
 
@@ -1810,7 +1808,7 @@ class Deserializer(object):
1810
1808
  if isinstance(attr, ET.Element):
1811
1809
  # Do no recurse on XML, just return the tree as-is
1812
1810
  return attr
1813
- if isinstance(attr, basestring):
1811
+ if isinstance(attr, str):
1814
1812
  return self.deserialize_basic(attr, "str")
1815
1813
  obj_type = type(attr)
1816
1814
  if obj_type in self.basic_types:
@@ -1867,7 +1865,7 @@ class Deserializer(object):
1867
1865
  if data_type == "bool":
1868
1866
  if attr in [True, False, 1, 0]:
1869
1867
  return bool(attr)
1870
- elif isinstance(attr, basestring):
1868
+ elif isinstance(attr, str):
1871
1869
  if attr.lower() in ["true", "1"]:
1872
1870
  return True
1873
1871
  elif attr.lower() in ["false", "0"]:
@@ -1918,7 +1916,6 @@ class Deserializer(object):
1918
1916
  data = data.value
1919
1917
  if isinstance(data, int):
1920
1918
  # Workaround. We might consider remove it in the future.
1921
- # https://github.com/Azure/azure-rest-api-specs/issues/141
1922
1919
  try:
1923
1920
  return list(enum_obj.__members__.values())[data]
1924
1921
  except IndexError:
@@ -1976,10 +1973,10 @@ class Deserializer(object):
1976
1973
  if isinstance(attr, ET.Element):
1977
1974
  attr = attr.text
1978
1975
  try:
1979
- return decimal.Decimal(attr) # type: ignore
1976
+ return decimal.Decimal(str(attr)) # type: ignore
1980
1977
  except decimal.DecimalException as err:
1981
1978
  msg = "Invalid decimal {}".format(attr)
1982
- raise_with_traceback(DeserializationError, msg, err)
1979
+ raise DeserializationError(msg) from err
1983
1980
 
1984
1981
  @staticmethod
1985
1982
  def deserialize_long(attr):
@@ -2007,7 +2004,7 @@ class Deserializer(object):
2007
2004
  duration = isodate.parse_duration(attr)
2008
2005
  except (ValueError, OverflowError, AttributeError) as err:
2009
2006
  msg = "Cannot deserialize duration object."
2010
- raise_with_traceback(DeserializationError, msg, err)
2007
+ raise DeserializationError(msg) from err
2011
2008
  else:
2012
2009
  return duration
2013
2010
 
@@ -2026,7 +2023,7 @@ class Deserializer(object):
2026
2023
  "Date must have only digits and -. Received: %s" % attr
2027
2024
  )
2028
2025
  # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception.
2029
- return isodate.parse_date(attr, defaultmonth=None, defaultday=None)
2026
+ return isodate.parse_date(attr, defaultmonth=0, defaultday=0)
2030
2027
 
2031
2028
  @staticmethod
2032
2029
  def deserialize_time(attr):
@@ -2066,7 +2063,7 @@ class Deserializer(object):
2066
2063
  date_obj = date_obj.astimezone(tz=TZ_UTC)
2067
2064
  except ValueError as err:
2068
2065
  msg = "Cannot deserialize to rfc datetime object."
2069
- raise_with_traceback(DeserializationError, msg, err)
2066
+ raise DeserializationError(msg) from err
2070
2067
  else:
2071
2068
  return date_obj
2072
2069
 
@@ -2103,7 +2100,7 @@ class Deserializer(object):
2103
2100
  raise OverflowError("Hit max or min date")
2104
2101
  except (ValueError, OverflowError, AttributeError) as err:
2105
2102
  msg = "Cannot deserialize datetime object."
2106
- raise_with_traceback(DeserializationError, msg, err)
2103
+ raise DeserializationError(msg) from err
2107
2104
  else:
2108
2105
  return date_obj
2109
2106
 
@@ -2119,9 +2116,10 @@ class Deserializer(object):
2119
2116
  if isinstance(attr, ET.Element):
2120
2117
  attr = int(attr.text) # type: ignore
2121
2118
  try:
2119
+ attr = int(attr)
2122
2120
  date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC)
2123
2121
  except ValueError as err:
2124
2122
  msg = "Cannot deserialize to unix datetime object."
2125
- raise_with_traceback(DeserializationError, msg, err)
2123
+ raise DeserializationError(msg) from err
2126
2124
  else:
2127
2125
  return date_obj
diracx/client/_vendor.py CHANGED
@@ -1,23 +1,11 @@
1
1
  # --------------------------------------------------------------------------
2
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
2
+ # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
3
3
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
4
4
  # --------------------------------------------------------------------------
5
5
 
6
- from typing import List, cast
6
+ from typing import Optional
7
7
 
8
-
9
- def _format_url_section(template, **kwargs):
10
- components = template.split("/")
11
- while components:
12
- try:
13
- return template.format(**kwargs)
14
- except KeyError as key:
15
- # Need the cast, as for some reasons "split" is typed as list[str | Any]
16
- formatted_components = cast(List[str], template.split("/"))
17
- components = [
18
- c for c in formatted_components if "{}".format(key.args[0]) not in c
19
- ]
20
- template = "/".join(components)
8
+ from azure.core import MatchConditions
21
9
 
22
10
 
23
11
  def raise_if_not_implemented(cls, abstract_methods):
@@ -31,3 +19,37 @@ def raise_if_not_implemented(cls, abstract_methods):
31
19
  cls.__name__, "', '".join(not_implemented)
32
20
  )
33
21
  )
22
+
23
+
24
+ def quote_etag(etag: Optional[str]) -> Optional[str]:
25
+ if not etag or etag == "*":
26
+ return etag
27
+ if etag.startswith("W/"):
28
+ return etag
29
+ if etag.startswith('"') and etag.endswith('"'):
30
+ return etag
31
+ if etag.startswith("'") and etag.endswith("'"):
32
+ return etag
33
+ return '"' + etag + '"'
34
+
35
+
36
+ def prep_if_match(
37
+ etag: Optional[str], match_condition: Optional[MatchConditions]
38
+ ) -> Optional[str]:
39
+ if match_condition == MatchConditions.IfNotModified:
40
+ if_match = quote_etag(etag) if etag else None
41
+ return if_match
42
+ if match_condition == MatchConditions.IfPresent:
43
+ return "*"
44
+ return None
45
+
46
+
47
+ def prep_if_none_match(
48
+ etag: Optional[str], match_condition: Optional[MatchConditions]
49
+ ) -> Optional[str]:
50
+ if match_condition == MatchConditions.IfModified:
51
+ if_none_match = quote_etag(etag) if etag else None
52
+ return if_none_match
53
+ if match_condition == MatchConditions.IfMissing:
54
+ return "*"
55
+ return None
@@ -1,6 +1,6 @@
1
1
  # coding=utf-8
2
2
  # --------------------------------------------------------------------------
3
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
3
+ # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
4
4
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
5
5
  # --------------------------------------------------------------------------
6
6