diff --git a/diracx-client/src/diracx/client/__init__.py b/diracx-client/src/diracx/client/__init__.py index cc37da18..ce588f33 100644 --- a/diracx-client/src/diracx/client/__init__.py +++ b/diracx-client/src/diracx/client/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/_client.py b/diracx-client/src/diracx/client/_client.py index 962319fa..644e905f 100644 --- a/diracx-client/src/diracx/client/_client.py +++ b/diracx-client/src/diracx/client/_client.py @@ -1,11 +1,12 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy from typing import Any +from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies @@ -112,7 +113,7 @@ def send_request( def close(self) -> None: self._client.close() - def __enter__(self) -> "Dirac": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/diracx-client/src/diracx/client/_configuration.py b/diracx-client/src/diracx/client/_configuration.py index e1883c55..f35b35e4 100644 --- a/diracx-client/src/diracx/client/_configuration.py +++ b/diracx-client/src/diracx/client/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/_serialization.py b/diracx-client/src/diracx/client/_serialization.py index 5e7b24dc..0ba76b66 100644 --- a/diracx-client/src/diracx/client/_serialization.py +++ b/diracx-client/src/diracx/client/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,7 +25,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +52,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -93,6 +92,8 @@ def deserialize_from_text( :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -114,7 +115,9 @@ def deserialize_from_text( try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError( + "JSON is invalid: {}".format(err), err + ) from err elif "xml" in (content_type or []): try: @@ -146,6 +149,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError( "Cannot deserialize content-type: {}".format(content_type) ) @@ -159,6 +164,11 @@ def deserialize_from_http_generics( Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -188,15 +198,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -239,24 +264,28 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning( "%s is not a known attribute of class %s and will be ignored", @@ -312,13 +348,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -338,7 +384,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -362,7 +412,9 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -398,12 +450,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -415,7 +470,7 @@ def _infer_class_models(cls): } if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -430,6 +485,7 @@ def deserialize( :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @@ -448,9 +504,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -470,7 +528,9 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update( + objects[valuetype]._flatten_subtype(key, objects) + ) # pylint: disable=protected-access return result @classmethod @@ -478,6 +538,11 @@ def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None @@ -531,11 +596,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer(object): # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -590,13 +657,16 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -624,13 +694,18 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = ( + target_obj._create_xml_node() + ) # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get( - "readonly", False + if ( + not keep_readonly + and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False) ): continue @@ -671,7 +746,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -704,17 +780,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): attr_name, class_name, str(target_obj) ) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -745,7 +821,9 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize( + data_type, data + ) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError( "Unable to build a model: " + str(err) @@ -756,9 +834,11 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -772,21 +852,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -805,19 +884,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -826,21 +906,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -851,7 +930,7 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -867,11 +946,12 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers( + cls, data_type, **kwargs + ): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -887,23 +967,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -917,8 +1000,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -928,15 +1010,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -999,9 +1079,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -1029,7 +1108,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object( + self, attr, **kwargs + ): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -1037,6 +1118,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1061,7 +1143,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1094,56 +1176,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1151,11 +1238,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1165,30 +1253,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1201,12 +1291,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1237,13 +1328,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1251,11 +1343,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1276,7 +1368,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1299,17 +1393,31 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor( + attr, attr_desc, data +): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1346,7 +1454,9 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor( + attr, attr_desc, data +): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1403,22 +1513,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1438,7 +1547,7 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} 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}]?" + r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?" ) def __init__(self, classes: Optional[Mapping[str, type]] = None): @@ -1479,11 +1588,14 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize( + self, target_obj, data + ): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1492,6 +1604,7 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): @@ -1501,7 +1614,10 @@ def _deserialize(self, target_obj, data): if config.get("constant") ] try: - for attr, mapconfig in data._attribute_map.items(): + for ( + attr, + mapconfig, + ) in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1522,13 +1638,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1558,9 +1674,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1590,6 +1705,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1601,7 +1718,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1616,10 +1733,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True, @@ -1638,10 +1757,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1671,17 +1792,24 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") + k + for k, v in response._validation.items() + if v.get("readonly") # pylint: disable=protected-access ] const = [ - k for k, v in response._validation.items() if v.get("constant") + k + for k, v in response._validation.items() + if v.get("constant") # pylint: disable=protected-access ] kwargs = { k: v @@ -1696,7 +1824,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1705,15 +1833,18 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data( + self, data, data_type + ): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1729,7 +1860,14 @@ def deserialize_data(self, data, data_type): ): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = ( + lambda x: x + not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + ) if ( isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) @@ -1753,14 +1891,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1783,6 +1921,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1795,11 +1934,14 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object( + self, attr, **kwargs + ): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1834,11 +1976,12 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic( + self, attr, data_type + ): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1846,6 +1989,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1857,24 +2001,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1882,6 +2025,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1895,8 +2039,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1908,6 +2051,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1918,9 +2062,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1940,6 +2084,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1952,6 +2097,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1967,8 +2113,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1983,6 +2130,7 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1995,6 +2143,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -2005,14 +2154,14 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -2030,6 +2179,7 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -2046,6 +2196,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -2064,14 +2215,14 @@ def deserialize_rfc(attr): except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -2101,8 +2252,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -2110,6 +2260,7 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ @@ -2121,5 +2272,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj diff --git a/diracx-client/src/diracx/client/_vendor.py b/diracx-client/src/diracx/client/_vendor.py index 2b77be83..446e9188 100644 --- a/diracx-client/src/diracx/client/_vendor.py +++ b/diracx-client/src/diracx/client/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/__init__.py b/diracx-client/src/diracx/client/aio/__init__.py index cc37da18..ce588f33 100644 --- a/diracx-client/src/diracx/client/aio/__init__.py +++ b/diracx-client/src/diracx/client/aio/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/_client.py b/diracx-client/src/diracx/client/aio/_client.py index e0128831..4350e8c0 100644 --- a/diracx-client/src/diracx/client/aio/_client.py +++ b/diracx-client/src/diracx/client/aio/_client.py @@ -1,11 +1,12 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy from typing import Any, Awaitable +from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.pipeline import policies @@ -112,7 +113,7 @@ def send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "Dirac": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/diracx-client/src/diracx/client/aio/_configuration.py b/diracx-client/src/diracx/client/aio/_configuration.py index 3a48c2b6..b3811428 100644 --- a/diracx-client/src/diracx/client/aio/_configuration.py +++ b/diracx-client/src/diracx/client/aio/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/_vendor.py b/diracx-client/src/diracx/client/aio/_vendor.py index 2b77be83..446e9188 100644 --- a/diracx-client/src/diracx/client/aio/_vendor.py +++ b/diracx-client/src/diracx/client/aio/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/operations/__init__.py b/diracx-client/src/diracx/client/aio/operations/__init__.py index eb877968..62ee157a 100644 --- a/diracx-client/src/diracx/client/aio/operations/__init__.py +++ b/diracx-client/src/diracx/client/aio/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/operations/_operations.py b/diracx-client/src/diracx/client/aio/operations/_operations.py index 8a2f0d53..966ba472 100644 --- a/diracx-client/src/diracx/client/aio/operations/_operations.py +++ b/diracx-client/src/diracx/client/aio/operations/_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -47,8 +47,6 @@ build_auth_userinfo_request, build_config_serve_config_request, build_jobs_assign_sandbox_to_job_request, - build_jobs_delete_bulk_jobs_request, - build_jobs_delete_single_job_request, build_jobs_get_job_sandbox_request, build_jobs_get_job_sandboxes_request, build_jobs_get_job_status_bulk_request, @@ -58,8 +56,6 @@ build_jobs_get_single_job_status_history_request, build_jobs_get_single_job_status_request, build_jobs_initiate_sandbox_upload_request, - build_jobs_kill_bulk_jobs_request, - build_jobs_kill_single_job_request, build_jobs_remove_bulk_jobs_request, build_jobs_remove_single_job_request, build_jobs_reschedule_bulk_jobs_request, @@ -119,12 +115,14 @@ async def openid_configuration(self, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -148,14 +146,12 @@ async def openid_configuration(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -172,12 +168,14 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: :rtype: ~client.models.Metadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -201,14 +199,12 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("Metadata", pipeline_response) + deserialized = self._deserialize("Metadata", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -253,7 +249,7 @@ async def initiate_device_flow( Initiate the device flow against DIRAC authorization Server. Scope must have exactly up to one ``group`` (otherwise default) and one or more ``property`` scope. - If no property, then get default one + If no property, then get default one. Offers the user to go with the browser to ``auth//device?user_code=XYZ``. @@ -266,12 +262,14 @@ async def initiate_device_flow( :rtype: ~client.models.InitiateDeviceFlowResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -297,15 +295,13 @@ async def initiate_device_flow( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) deserialized = self._deserialize( - "InitiateDeviceFlowResponse", pipeline_response + "InitiateDeviceFlowResponse", pipeline_response.http_response ) if cls: @@ -332,12 +328,14 @@ async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -362,14 +360,12 @@ async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -394,12 +390,14 @@ async def finish_device_flow(self, *, code: str, state: str, **kwargs: Any) -> A :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -425,14 +423,12 @@ async def finish_device_flow(self, *, code: str, state: str, **kwargs: Any) -> A response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -449,12 +445,14 @@ async def finished(self, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -478,14 +476,12 @@ async def finished(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -503,12 +499,14 @@ async def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: :rtype: list[any] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -532,14 +530,12 @@ async def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -559,12 +555,14 @@ async def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -589,14 +587,12 @@ async def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -613,12 +609,14 @@ async def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: :rtype: ~client.models.UserInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -642,14 +640,14 @@ async def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("UserInfoResponse", pipeline_response) + deserialized = self._deserialize( + "UserInfoResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -697,12 +695,14 @@ async def authorization_flow( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -733,14 +733,12 @@ async def authorization_flow( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -769,12 +767,14 @@ async def authorization_flow_complete( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -800,14 +800,12 @@ async def authorization_flow_complete( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -865,12 +863,14 @@ async def serve_config( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError elif match_condition == MatchConditions.IfPresent: @@ -903,14 +903,12 @@ async def serve_config( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1011,12 +1009,14 @@ async def initiate_sandbox_upload( :rtype: ~client.models.SandboxUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1054,14 +1054,14 @@ async def initiate_sandbox_upload( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("SandboxUploadResponse", pipeline_response) + deserialized = self._deserialize( + "SandboxUploadResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1074,7 +1074,7 @@ async def get_sandbox_file( ) -> _models.SandboxDownloadResponse: """Get Sandbox File. - Get a presigned URL to download a sandbox file + Get a presigned URL to download a sandbox file. This route cannot use a redirect response most clients will also send the authorization header when following a redirect. This is not desirable as @@ -1088,12 +1088,14 @@ async def get_sandbox_file( :rtype: ~client.models.SandboxDownloadResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1118,14 +1120,14 @@ async def get_sandbox_file( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("SandboxDownloadResponse", pipeline_response) + deserialized = self._deserialize( + "SandboxDownloadResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1146,12 +1148,14 @@ async def unassign_bulk_jobs_sandboxes( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1176,14 +1180,12 @@ async def unassign_bulk_jobs_sandboxes( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1204,12 +1206,14 @@ async def get_job_sandboxes( :rtype: dict[str, list[any]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1234,14 +1238,12 @@ async def get_job_sandboxes( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{[object]}", pipeline_response) + deserialized = self._deserialize("{[object]}", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1260,12 +1262,14 @@ async def unassign_job_sandboxes(self, job_id: int, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1290,14 +1294,12 @@ async def unassign_job_sandboxes(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1320,12 +1322,14 @@ async def get_job_sandbox( :rtype: list[any] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1351,14 +1355,12 @@ async def get_job_sandbox( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1379,12 +1381,14 @@ async def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1416,14 +1420,73 @@ async def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: + """Remove Bulk Jobs. + + Fully remove a list of jobs from the WMS databases. + + WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS + and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should + be removed, and a status change to Deleted (PATCH /jobs/status) should be used instead for any + other purpose. + + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_remove_bulk_jobs_request( + job_ids=job_ids, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1480,12 +1543,14 @@ async def submit_bulk_jobs( :rtype: list[~client.models.InsertedJob] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1523,103 +1588,131 @@ async def submit_bulk_jobs( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[InsertedJob]", pipeline_response) + deserialized = self._deserialize( + "[InsertedJob]", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Delete Bulk Jobs. + @overload + async def set_single_job_status( + self, + job_id: int, + body: Dict[str, _models.JobStatusUpdate], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - Delete Bulk Jobs. + Set Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: dict[str, ~client.models.JobStatusUpdate] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_delete_bulk_jobs_request( - job_ids=job_ids, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) + @overload + async def set_single_job_status( + self, + job_id: int, + body: IO[bytes], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Set Single Job Status. - return deserialized # type: ignore + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: IO[bytes] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Kill Bulk Jobs. + async def set_single_job_status( + self, + job_id: int, + body: Union[Dict[str, _models.JobStatusUpdate], IO[bytes]], + *, + force: bool = False, + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - Kill Bulk Jobs. + Set Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :param body: Is either a {str: JobStatusUpdate} type or a IO[bytes] type. Required. + :type body: dict[str, ~client.models.JobStatusUpdate] or IO[bytes] + :keyword force: Default value is False. + :paramtype force: bool + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - _request = build_jobs_kill_bulk_jobs_request( - job_ids=job_ids, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "{JobStatusUpdate}") + + _request = build_jobs_set_single_job_status_request( + job_id=job_id, + force=force, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1635,14 +1728,14 @@ async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "{SetJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1650,36 +1743,38 @@ async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace_async - async def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Remove Bulk Jobs. - - Fully remove a list of jobs from the WMS databases. + async def get_single_job_status( + self, job_id: int, **kwargs: Any + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Single Job Status. - WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS - and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should - be removed, and the delete endpoint should be used instead for any other purpose. + Get Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None + ) - _request = build_jobs_remove_bulk_jobs_request( - job_ids=job_ids, + _request = build_jobs_get_single_job_status_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1695,92 +1790,32 @@ async def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "{LimitedJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_job_status_bulk( - self, *, job_ids: List[int], **kwargs: Any - ) -> Dict[str, _models.LimitedJobStatusReturn]: - """Get Job Status Bulk. + @overload + async def set_job_status_bulk( + self, + body: Dict[str, Dict[str, _models.JobStatusUpdate]], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. - Get Job Status Bulk. - - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: dict mapping str to LimitedJobStatusReturn - :rtype: dict[str, ~client.models.LimitedJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( - "cls", None - ) - - _request = build_jobs_get_job_status_bulk_request( - job_ids=job_ids, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def set_job_status_bulk( - self, - body: Dict[str, Dict[str, _models.JobStatusUpdate]], - *, - force: bool = False, - content_type: str = "application/json", - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Job Status Bulk. - - Set Job Status Bulk. + Set Job Status Bulk. :param body: Required. :type body: dict[str, dict[str, ~client.models.JobStatusUpdate]] @@ -1839,12 +1874,14 @@ async def set_job_status_bulk( :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1883,14 +1920,14 @@ async def set_job_status_bulk( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) + deserialized = self._deserialize( + "{SetJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1898,33 +1935,37 @@ async def set_job_status_bulk( return deserialized # type: ignore @distributed_trace_async - async def get_job_status_history_bulk( + async def get_job_status_bulk( self, *, job_ids: List[int], **kwargs: Any - ) -> Dict[str, List[_models.JobStatusReturn]]: - """Get Job Status History Bulk. + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Job Status Bulk. - Get Job Status History Bulk. + Get Job Status Bulk. :keyword job_ids: Required. :paramtype job_ids: list[int] - :return: dict mapping str to list of JobStatusReturn - :rtype: dict[str, list[~client.models.JobStatusReturn]] + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None + ) - _request = build_jobs_get_job_status_history_bulk_request( + _request = build_jobs_get_job_status_bulk_request( job_ids=job_ids, headers=_headers, params=_params, @@ -1941,14 +1982,14 @@ async def get_job_status_history_bulk( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) + deserialized = self._deserialize( + "{LimitedJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1967,12 +2008,14 @@ async def reschedule_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> An :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1997,14 +2040,12 @@ async def reschedule_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> An response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2023,12 +2064,14 @@ async def reschedule_single_job(self, job_id: int, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2053,14 +2096,199 @@ async def reschedule_single_job(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def remove_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Remove Single Job. + + Fully remove a job from the WMS databases. + + WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS + and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should + be removed, and a status change to "Deleted" (PATCH /jobs/{job_id}/status) should be used + instead. + + :param job_id: Required. + :type job_id: int + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_remove_single_job_request( + job_id=job_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def set_single_job_properties( + self, job_id: int, body: JSON, *, update_timestamp: bool = False, **kwargs: Any + ) -> Any: + """Set Single Job Properties. + + Update the given job properties (MinorStatus, ApplicationStatus, etc). + + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: JSON + :keyword update_timestamp: Default value is False. + :paramtype update_timestamp: bool + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop( + "content_type", _headers.pop("Content-Type", "application/json") + ) + cls: ClsType[Any] = kwargs.pop("cls", None) + + _json = self._serialize.body(body, "object") + + _request = build_jobs_set_single_job_properties_request( + job_id=job_id, + update_timestamp=update_timestamp, + content_type=content_type, + json=_json, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Get Single Job. + + Get Single Job. + + :param job_id: Required. + :type job_id: int + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_get_single_job_request( + job_id=job_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2152,12 +2380,14 @@ async def search( :rtype: list[JSON] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2200,23 +2430,18 @@ async def search( response = pipeline_response.http_response if response.status_code not in [200, 206]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("[object]", pipeline_response) - if response.status_code == 206: response_headers["Content-Range"] = self._deserialize( "str", response.headers.get("Content-Range") ) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2277,12 +2502,14 @@ async def summary( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2320,14 +2547,12 @@ async def summary( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2335,334 +2560,36 @@ async def summary( return deserialized # type: ignore @distributed_trace_async - async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Get Single Job. + async def get_job_status_history_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Job Status History Bulk. - Get Single Job. + Get Job Status History Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_get_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Delete Single Job. - - Delete a job by killing and setting the job status to DELETED. - - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_delete_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def set_single_job_properties( - self, job_id: int, body: JSON, *, update_timestamp: bool = False, **kwargs: Any - ) -> Any: - """Set Single Job Properties. - - Update the given job properties (MinorStatus, ApplicationStatus, etc). - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: JSON - :keyword update_timestamp: Default value is False. - :paramtype update_timestamp: bool - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: str = kwargs.pop( - "content_type", _headers.pop("Content-Type", "application/json") - ) - cls: ClsType[Any] = kwargs.pop("cls", None) - - _json = self._serialize.body(body, "object") - - _request = build_jobs_set_single_job_properties_request( - job_id=job_id, - update_timestamp=update_timestamp, - content_type=content_type, - json=_json, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Kill Single Job. - - Kill a job. - - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_kill_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def remove_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Remove Single Job. - - Fully remove a job from the WMS databases. - - WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS - and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should - be removed, and the delete endpoint should be used instead. - - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_remove_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_single_job_status( - self, job_id: int, **kwargs: Any - ) -> Dict[str, _models.LimitedJobStatusReturn]: - """Get Single Job Status. - - Get Single Job Status. - - :param job_id: Required. - :type job_id: int - :return: dict mapping str to LimitedJobStatusReturn - :rtype: dict[str, ~client.models.LimitedJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( - "cls", None - ) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - _request = build_jobs_get_single_job_status_request( - job_id=job_id, + _request = build_jobs_get_job_status_history_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -2678,153 +2605,15 @@ async def get_single_job_status( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def set_single_job_status( - self, - job_id: int, - body: Dict[str, _models.JobStatusUpdate], - *, - force: bool = False, - content_type: str = "application/json", - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: dict[str, ~client.models.JobStatusUpdate] - :keyword force: Default value is False. - :paramtype force: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def set_single_job_status( - self, - job_id: int, - body: IO[bytes], - *, - force: bool = False, - content_type: str = "application/json", - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: IO[bytes] - :keyword force: Default value is False. - :paramtype force: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def set_single_job_status( - self, - job_id: int, - body: Union[Dict[str, _models.JobStatusUpdate], IO[bytes]], - *, - force: bool = False, - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Is either a {str: JobStatusUpdate} type or a IO[bytes] type. Required. - :type body: dict[str, ~client.models.JobStatusUpdate] or IO[bytes] - :keyword force: Default value is False. - :paramtype force: bool - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "{JobStatusUpdate}") - - _request = build_jobs_set_single_job_status_request( - job_id=job_id, - force=force, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + deserialized = self._deserialize( + "{[JobStatusReturn]}", pipeline_response.http_response ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2844,12 +2633,14 @@ async def get_single_job_status_history( :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2874,14 +2665,14 @@ async def get_single_job_status_history( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) + deserialized = self._deserialize( + "{[JobStatusReturn]}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/diracx-client/src/diracx/client/models/__init__.py b/diracx-client/src/diracx/client/models/__init__.py index 7cd1643a..8d063357 100644 --- a/diracx-client/src/diracx/client/models/__init__.py +++ b/diracx-client/src/diracx/client/models/__init__.py @@ -1,11 +1,12 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._models import BodyAuthToken from ._models import BodyAuthTokenGrantType +from ._models import DevelopmentSettings from ._models import GroupInfo from ._models import HTTPValidationError from ._models import InitiateDeviceFlowResponse @@ -53,6 +54,7 @@ __all__ = [ "BodyAuthToken", "BodyAuthTokenGrantType", + "DevelopmentSettings", "GroupInfo", "HTTPValidationError", "InitiateDeviceFlowResponse", diff --git a/diracx-client/src/diracx/client/models/_enums.py b/diracx-client/src/diracx/client/models/_enums.py index 935cbb17..6331a50e 100644 --- a/diracx-client/src/diracx/client/models/_enums.py +++ b/diracx-client/src/diracx/client/models/_enums.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -99,5 +99,5 @@ class SortDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): class VectorSearchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VectorSearchOperator.""" - IN_ENUM = "in" + IN = "in" NOT_IN = "not in" diff --git a/diracx-client/src/diracx/client/models/_models.py b/diracx-client/src/diracx/client/models/_models.py index 23833265..2e78fe46 100644 --- a/diracx-client/src/diracx/client/models/_models.py +++ b/diracx-client/src/diracx/client/models/_models.py @@ -1,7 +1,7 @@ # coding=utf-8 # pylint: disable=too-many-lines # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -102,6 +102,31 @@ class BodyAuthTokenGrantType(_serialization.Model): """OAuth2 Grant type.""" +class DevelopmentSettings(_serialization.Model): + """Settings for the Development Configuration that can influence run time. + + :ivar crash_on_missed_access_policy: Crash On Missed Access Policy. + :vartype crash_on_missed_access_policy: bool + """ + + _attribute_map = { + "crash_on_missed_access_policy": { + "key": "crash_on_missed_access_policy", + "type": "bool", + }, + } + + def __init__( + self, *, crash_on_missed_access_policy: bool = False, **kwargs: Any + ) -> None: + """ + :keyword crash_on_missed_access_policy: Crash On Missed Access Policy. + :paramtype crash_on_missed_access_policy: bool + """ + super().__init__(**kwargs) + self.crash_on_missed_access_policy = crash_on_missed_access_policy + + class GroupInfo(_serialization.Model): """GroupInfo. @@ -538,25 +563,41 @@ class Metadata(_serialization.Model): :ivar virtual_organizations: Virtual Organizations. Required. :vartype virtual_organizations: dict[str, ~client.models.VOInfo] + :ivar development_settings: Settings for the Development Configuration that can influence run + time. Required. + :vartype development_settings: ~client.models.DevelopmentSettings """ _validation = { "virtual_organizations": {"required": True}, + "development_settings": {"required": True}, } _attribute_map = { "virtual_organizations": {"key": "virtual_organizations", "type": "{VOInfo}"}, + "development_settings": { + "key": "development_settings", + "type": "DevelopmentSettings", + }, } def __init__( - self, *, virtual_organizations: Dict[str, "_models.VOInfo"], **kwargs: Any + self, + *, + virtual_organizations: Dict[str, "_models.VOInfo"], + development_settings: "_models.DevelopmentSettings", + **kwargs: Any, ) -> None: """ :keyword virtual_organizations: Virtual Organizations. Required. :paramtype virtual_organizations: dict[str, ~client.models.VOInfo] + :keyword development_settings: Settings for the Development Configuration that can influence + run time. Required. + :paramtype development_settings: ~client.models.DevelopmentSettings """ super().__init__(**kwargs) self.virtual_organizations = virtual_organizations + self.development_settings = development_settings class SandboxDownloadResponse(_serialization.Model): @@ -609,7 +650,7 @@ class SandboxInfo(_serialization.Model): _validation = { "checksum_algorithm": {"required": True}, - "checksum": {"required": True, "pattern": r"^[0-f]{64}$"}, + "checksum": {"required": True, "pattern": r"^[0-9a-fA-F]{64}$"}, "size": {"required": True, "minimum": 1}, "format": {"required": True}, } diff --git a/diracx-client/src/diracx/client/operations/__init__.py b/diracx-client/src/diracx/client/operations/__init__.py index eb877968..62ee157a 100644 --- a/diracx-client/src/diracx/client/operations/__init__.py +++ b/diracx-client/src/diracx/client/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/operations/_operations.py b/diracx-client/src/diracx/client/operations/_operations.py index 800996ab..8b7bf052 100644 --- a/diracx-client/src/diracx/client/operations/_operations.py +++ b/diracx-client/src/diracx/client/operations/_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.22.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -469,28 +469,7 @@ def build_jobs_assign_sandbox_to_job_request( ) -def build_jobs_submit_bulk_jobs_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/api/jobs/" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -def build_jobs_delete_bulk_jobs_request( +def build_jobs_remove_bulk_jobs_request( *, job_ids: List[int], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -512,70 +491,79 @@ def build_jobs_delete_bulk_jobs_request( ) -def build_jobs_kill_bulk_jobs_request( - *, job_ids: List[int], **kwargs: Any -) -> HttpRequest: +def build_jobs_submit_bulk_jobs_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/kill" - - # Construct parameters - _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") + _url = "/api/jobs/" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs - ) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_jobs_remove_bulk_jobs_request( - *, job_ids: List[int], **kwargs: Any +def build_jobs_set_single_job_status_request( + job_id: int, *, force: bool = False, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/remove" + _url = "/api/jobs/{job_id}/status" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs + method="PATCH", url=_url, params=_params, headers=_headers, **kwargs ) -def build_jobs_get_job_status_bulk_request( - *, job_ids: List[int], **kwargs: Any -) -> HttpRequest: +def build_jobs_get_single_job_status_request(job_id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/status" + _url = "/api/jobs/{job_id}/status" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } - # Construct parameters - _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", url=_url, params=_params, headers=_headers, **kwargs - ) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) def build_jobs_set_job_status_bulk_request( @@ -608,7 +596,7 @@ def build_jobs_set_job_status_bulk_request( ) -def build_jobs_get_job_status_history_bulk_request( # pylint: disable=name-too-long +def build_jobs_get_job_status_bulk_request( *, job_ids: List[int], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -617,7 +605,7 @@ def build_jobs_get_job_status_history_bulk_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/status/history" + _url = "/api/jobs/status" # Construct parameters _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") @@ -671,79 +659,7 @@ def build_jobs_reschedule_single_job_request(job_id: int, **kwargs: Any) -> Http return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_jobs_search_request( - *, page: int = 1, per_page: int = 100, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/api/jobs/search" - - # Construct parameters - if page is not None: - _params["page"] = _SERIALIZER.query("page", page, "int") - if per_page is not None: - _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs - ) - - -def build_jobs_summary_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/api/jobs/summary" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -def build_jobs_get_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/api/jobs/{job_id}" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) - - -def build_jobs_delete_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_remove_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") @@ -799,13 +715,13 @@ def build_jobs_set_single_job_properties_request( # pylint: disable=name-too-lo ) -def build_jobs_kill_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_get_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/{job_id}/kill" + _url = "/api/jobs/{job_id}" path_format_arguments = { "job_id": _SERIALIZER.url("job_id", job_id, "int"), } @@ -815,79 +731,81 @@ def build_jobs_kill_single_job_request(job_id: int, **kwargs: Any) -> HttpReques # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_jobs_remove_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_search_request( + *, page: int = 1, per_page: int = 100, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/{job_id}/remove" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } + _url = "/api/jobs/search" - _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest( + method="POST", url=_url, params=_params, headers=_headers, **kwargs + ) -def build_jobs_get_single_job_status_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_summary_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/{job_id}/status" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/api/jobs/summary" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_jobs_set_single_job_status_request( - job_id: int, *, force: bool = False, **kwargs: Any +def build_jobs_get_job_status_history_bulk_request( # pylint: disable=name-too-long + *, job_ids: List[int], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/api/jobs/{job_id}/status" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/api/jobs/status/history" # Construct parameters - if force is not None: - _params["force"] = _SERIALIZER.query("force", force, "bool") + _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( - method="PATCH", url=_url, params=_params, headers=_headers, **kwargs + method="GET", url=_url, params=_params, headers=_headers, **kwargs ) @@ -943,12 +861,14 @@ def openid_configuration(self, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -972,14 +892,12 @@ def openid_configuration(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -996,12 +914,14 @@ def installation_metadata(self, **kwargs: Any) -> _models.Metadata: :rtype: ~client.models.Metadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1025,14 +945,12 @@ def installation_metadata(self, **kwargs: Any) -> _models.Metadata: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("Metadata", pipeline_response) + deserialized = self._deserialize("Metadata", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1077,7 +995,7 @@ def initiate_device_flow( Initiate the device flow against DIRAC authorization Server. Scope must have exactly up to one ``group`` (otherwise default) and one or more ``property`` scope. - If no property, then get default one + If no property, then get default one. Offers the user to go with the browser to ``auth//device?user_code=XYZ``. @@ -1090,12 +1008,14 @@ def initiate_device_flow( :rtype: ~client.models.InitiateDeviceFlowResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1121,15 +1041,13 @@ def initiate_device_flow( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) deserialized = self._deserialize( - "InitiateDeviceFlowResponse", pipeline_response + "InitiateDeviceFlowResponse", pipeline_response.http_response ) if cls: @@ -1156,12 +1074,14 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1186,14 +1106,12 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1218,12 +1136,14 @@ def finish_device_flow(self, *, code: str, state: str, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1249,14 +1169,12 @@ def finish_device_flow(self, *, code: str, state: str, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1273,12 +1191,14 @@ def finished(self, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1302,14 +1222,12 @@ def finished(self, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1327,12 +1245,14 @@ def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: :rtype: list[any] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1356,14 +1276,12 @@ def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1383,12 +1301,14 @@ def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1413,14 +1333,12 @@ def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1437,12 +1355,14 @@ def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: :rtype: ~client.models.UserInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1466,14 +1386,14 @@ def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("UserInfoResponse", pipeline_response) + deserialized = self._deserialize( + "UserInfoResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1521,12 +1441,14 @@ def authorization_flow( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1557,14 +1479,12 @@ def authorization_flow( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1593,12 +1513,14 @@ def authorization_flow_complete( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1624,14 +1546,12 @@ def authorization_flow_complete( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1689,12 +1609,14 @@ def serve_config( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError elif match_condition == MatchConditions.IfPresent: @@ -1727,14 +1649,12 @@ def serve_config( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1835,12 +1755,14 @@ def initiate_sandbox_upload( :rtype: ~client.models.SandboxUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1878,14 +1800,14 @@ def initiate_sandbox_upload( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("SandboxUploadResponse", pipeline_response) + deserialized = self._deserialize( + "SandboxUploadResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1898,7 +1820,7 @@ def get_sandbox_file( ) -> _models.SandboxDownloadResponse: """Get Sandbox File. - Get a presigned URL to download a sandbox file + Get a presigned URL to download a sandbox file. This route cannot use a redirect response most clients will also send the authorization header when following a redirect. This is not desirable as @@ -1912,12 +1834,14 @@ def get_sandbox_file( :rtype: ~client.models.SandboxDownloadResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1942,14 +1866,14 @@ def get_sandbox_file( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("SandboxDownloadResponse", pipeline_response) + deserialized = self._deserialize( + "SandboxDownloadResponse", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1970,12 +1894,14 @@ def unassign_bulk_jobs_sandboxes( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2000,14 +1926,12 @@ def unassign_bulk_jobs_sandboxes( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2026,12 +1950,14 @@ def get_job_sandboxes(self, job_id: int, **kwargs: Any) -> Dict[str, List[Any]]: :rtype: dict[str, list[any]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2056,14 +1982,12 @@ def get_job_sandboxes(self, job_id: int, **kwargs: Any) -> Dict[str, List[Any]]: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{[object]}", pipeline_response) + deserialized = self._deserialize("{[object]}", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2082,12 +2006,14 @@ def unassign_job_sandboxes(self, job_id: int, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2112,14 +2038,12 @@ def unassign_job_sandboxes(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2142,12 +2066,14 @@ def get_job_sandbox( :rtype: list[any] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2173,14 +2099,12 @@ def get_job_sandbox( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2201,12 +2125,14 @@ def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2238,23 +2164,82 @@ def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def submit_bulk_jobs( - self, body: List[str], *, content_type: str = "application/json", **kwargs: Any + @distributed_trace + def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: + """Remove Bulk Jobs. + + Fully remove a list of jobs from the WMS databases. + + WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS + and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should + be removed, and a status change to Deleted (PATCH /jobs/status) should be used instead for any + other purpose. + + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_remove_bulk_jobs_request( + job_ids=job_ids, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def submit_bulk_jobs( + self, body: List[str], *, content_type: str = "application/json", **kwargs: Any ) -> List[_models.InsertedJob]: """Submit Bulk Jobs. @@ -2302,12 +2287,14 @@ def submit_bulk_jobs( :rtype: list[~client.models.InsertedJob] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2345,163 +2332,131 @@ def submit_bulk_jobs( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[InsertedJob]", pipeline_response) + deserialized = self._deserialize( + "[InsertedJob]", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Delete Bulk Jobs. + @overload + def set_single_job_status( + self, + job_id: int, + body: Dict[str, _models.JobStatusUpdate], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - Delete Bulk Jobs. + Set Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: dict[str, ~client.models.JobStatusUpdate] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_delete_bulk_jobs_request( - job_ids=job_ids, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Kill Bulk Jobs. + @overload + def set_single_job_status( + self, + job_id: int, + body: IO[bytes], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - Kill Bulk Jobs. + Set Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: IO[bytes] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_kill_bulk_jobs_request( - job_ids=job_ids, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore @distributed_trace - def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Remove Bulk Jobs. - - Fully remove a list of jobs from the WMS databases. + def set_single_job_status( + self, + job_id: int, + body: Union[Dict[str, _models.JobStatusUpdate], IO[bytes]], + *, + force: bool = False, + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS - and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should - be removed, and the delete endpoint should be used instead for any other purpose. + Set Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :param body: Is either a {str: JobStatusUpdate} type or a IO[bytes] type. Required. + :type body: dict[str, ~client.models.JobStatusUpdate] or IO[bytes] + :keyword force: Default value is False. + :paramtype force: bool + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - _request = build_jobs_remove_bulk_jobs_request( - job_ids=job_ids, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "{JobStatusUpdate}") + + _request = build_jobs_set_single_job_status_request( + job_id=job_id, + force=force, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2517,14 +2472,14 @@ def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "{SetJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2532,25 +2487,27 @@ def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace - def get_job_status_bulk( - self, *, job_ids: List[int], **kwargs: Any + def get_single_job_status( + self, job_id: int, **kwargs: Any ) -> Dict[str, _models.LimitedJobStatusReturn]: - """Get Job Status Bulk. + """Get Single Job Status. - Get Job Status Bulk. + Get Single Job Status. - :keyword job_ids: Required. - :paramtype job_ids: list[int] + :param job_id: Required. + :type job_id: int :return: dict mapping str to LimitedJobStatusReturn :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2560,8 +2517,8 @@ def get_job_status_bulk( "cls", None ) - _request = build_jobs_get_job_status_bulk_request( - job_ids=job_ids, + _request = build_jobs_get_single_job_status_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -2577,14 +2534,14 @@ def get_job_status_bulk( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) + deserialized = self._deserialize( + "{LimitedJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2661,12 +2618,14 @@ def set_job_status_bulk( :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2705,14 +2664,14 @@ def set_job_status_bulk( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) + deserialized = self._deserialize( + "{SetJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2720,33 +2679,37 @@ def set_job_status_bulk( return deserialized # type: ignore @distributed_trace - def get_job_status_history_bulk( + def get_job_status_bulk( self, *, job_ids: List[int], **kwargs: Any - ) -> Dict[str, List[_models.JobStatusReturn]]: - """Get Job Status History Bulk. + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Job Status Bulk. - Get Job Status History Bulk. + Get Job Status Bulk. :keyword job_ids: Required. :paramtype job_ids: list[int] - :return: dict mapping str to list of JobStatusReturn - :rtype: dict[str, list[~client.models.JobStatusReturn]] + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None + ) - _request = build_jobs_get_job_status_history_bulk_request( + _request = build_jobs_get_job_status_bulk_request( job_ids=job_ids, headers=_headers, params=_params, @@ -2763,14 +2726,14 @@ def get_job_status_history_bulk( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) + deserialized = self._deserialize( + "{LimitedJobStatusReturn}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2789,12 +2752,14 @@ def reschedule_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2819,14 +2784,12 @@ def reschedule_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2845,12 +2808,14 @@ def reschedule_single_job(self, job_id: int, **kwargs: Any) -> Any: :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2875,14 +2840,199 @@ def reschedule_single_job(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def remove_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Remove Single Job. + + Fully remove a job from the WMS databases. + + WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS + and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should + be removed, and a status change to "Deleted" (PATCH /jobs/{job_id}/status) should be used + instead. + + :param job_id: Required. + :type job_id: int + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_remove_single_job_request( + job_id=job_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def set_single_job_properties( + self, job_id: int, body: JSON, *, update_timestamp: bool = False, **kwargs: Any + ) -> Any: + """Set Single Job Properties. + + Update the given job properties (MinorStatus, ApplicationStatus, etc). + + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: JSON + :keyword update_timestamp: Default value is False. + :paramtype update_timestamp: bool + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop( + "content_type", _headers.pop("Content-Type", "application/json") + ) + cls: ClsType[Any] = kwargs.pop("cls", None) + + _json = self._serialize.body(body, "object") + + _request = build_jobs_set_single_job_properties_request( + job_id=job_id, + update_timestamp=update_timestamp, + content_type=content_type, + json=_json, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Get Single Job. + + Get Single Job. + + :param job_id: Required. + :type job_id: int + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Any] = kwargs.pop("cls", None) + + _request = build_jobs_get_single_job_request( + job_id=job_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error( + status_code=response.status_code, response=response, error_map=error_map + ) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2974,12 +3124,14 @@ def search( :rtype: list[JSON] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3022,23 +3174,18 @@ def search( response = pipeline_response.http_response if response.status_code not in [200, 206]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("[object]", pipeline_response) - if response.status_code == 206: response_headers["Content-Range"] = self._deserialize( "str", response.headers.get("Content-Range") ) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3099,12 +3246,14 @@ def summary( :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3142,14 +3291,12 @@ def summary( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3157,32 +3304,36 @@ def summary( return deserialized # type: ignore @distributed_trace - def get_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Get Single Job. + def get_job_status_history_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Job Status History Bulk. - Get Single Job. + Get Job Status History Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - _request = build_jobs_get_single_job_request( - job_id=job_id, + _request = build_jobs_get_job_status_history_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -3198,14 +3349,14 @@ def get_single_job(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "{[JobStatusReturn]}", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3213,31 +3364,35 @@ def get_single_job(self, job_id: int, **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace - def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Delete Single Job. + def get_single_job_status_history( + self, job_id: int, **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Single Job Status History. - Delete a job by killing and setting the job status to DELETED. + Get Single Job Status History. :param job_id: Required. :type job_id: int - :return: any - :rtype: any + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } + error_map: MutableMapping[int, Type[HttpResponseError]] = ( + { # pylint: disable=unsubscriptable-object + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + ) error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - _request = build_jobs_delete_single_job_request( + _request = build_jobs_get_single_job_status_history_request( job_id=job_id, headers=_headers, params=_params, @@ -3254,456 +3409,14 @@ def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error( status_code=response.status_code, response=response, error_map=error_map ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def set_single_job_properties( - self, job_id: int, body: JSON, *, update_timestamp: bool = False, **kwargs: Any - ) -> Any: - """Set Single Job Properties. - - Update the given job properties (MinorStatus, ApplicationStatus, etc). - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: JSON - :keyword update_timestamp: Default value is False. - :paramtype update_timestamp: bool - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: str = kwargs.pop( - "content_type", _headers.pop("Content-Type", "application/json") + deserialized = self._deserialize( + "{[JobStatusReturn]}", pipeline_response.http_response ) - cls: ClsType[Any] = kwargs.pop("cls", None) - - _json = self._serialize.body(body, "object") - - _request = build_jobs_set_single_job_properties_request( - job_id=job_id, - update_timestamp=update_timestamp, - content_type=content_type, - json=_json, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Kill Single Job. - - Kill a job. - - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_kill_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def remove_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Remove Single Job. - - Fully remove a job from the WMS databases. - - WARNING: This endpoint has been implemented for the compatibility with the legacy DIRAC WMS - and the JobCleaningAgent. However, once this agent is ported to diracx, this endpoint should - be removed, and the delete endpoint should be used instead. - - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Any] = kwargs.pop("cls", None) - - _request = build_jobs_remove_single_job_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("object", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_single_job_status( - self, job_id: int, **kwargs: Any - ) -> Dict[str, _models.LimitedJobStatusReturn]: - """Get Single Job Status. - - Get Single Job Status. - - :param job_id: Required. - :type job_id: int - :return: dict mapping str to LimitedJobStatusReturn - :rtype: dict[str, ~client.models.LimitedJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( - "cls", None - ) - - _request = build_jobs_get_single_job_status_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def set_single_job_status( - self, - job_id: int, - body: Dict[str, _models.JobStatusUpdate], - *, - force: bool = False, - content_type: str = "application/json", - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: dict[str, ~client.models.JobStatusUpdate] - :keyword force: Default value is False. - :paramtype force: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def set_single_job_status( - self, - job_id: int, - body: IO[bytes], - *, - force: bool = False, - content_type: str = "application/json", - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Required. - :type body: IO[bytes] - :keyword force: Default value is False. - :paramtype force: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def set_single_job_status( - self, - job_id: int, - body: Union[Dict[str, _models.JobStatusUpdate], IO[bytes]], - *, - force: bool = False, - **kwargs: Any, - ) -> Dict[str, _models.SetJobStatusReturn]: - """Set Single Job Status. - - Set Single Job Status. - - :param job_id: Required. - :type job_id: int - :param body: Is either a {str: JobStatusUpdate} type or a IO[bytes] type. Required. - :type body: dict[str, ~client.models.JobStatusUpdate] or IO[bytes] - :keyword force: Default value is False. - :paramtype force: bool - :return: dict mapping str to SetJobStatusReturn - :rtype: dict[str, ~client.models.SetJobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "{JobStatusUpdate}") - - _request = build_jobs_set_single_job_status_request( - job_id=job_id, - force=force, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_single_job_status_history( - self, job_id: int, **kwargs: Any - ) -> Dict[str, List[_models.JobStatusReturn]]: - """Get Single Job Status History. - - Get Single Job Status History. - - :param job_id: Required. - :type job_id: int - :return: dict mapping str to list of JobStatusReturn - :rtype: dict[str, list[~client.models.JobStatusReturn]] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - - _request = build_jobs_get_single_job_status_history_request( - job_id=job_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error( - status_code=response.status_code, response=response, error_map=error_map - ) - raise HttpResponseError(response=response) - - deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore