From 5b4dbfd6384105b8775bf1080f43a4c98cd8510a Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Fri, 18 Oct 2024 10:59:35 +0200 Subject: [PATCH 1/6] Send client version to server --- .../src/diracx/client/patches/aio/utils.py | 15 +++++ .../src/diracx/client/patches/utils.py | 18 +++++- diracx-routers/pyproject.toml | 3 + diracx-routers/src/diracx/routers/__init__.py | 58 ++++++++++++++++++- diracx-routers/src/diracx/routers/version.py | 1 + diracx-routers/tests/test_generic.py | 25 ++++++++ docs/VERSIONING.md | 3 + 7 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 diracx-routers/src/diracx/routers/version.py diff --git a/diracx-client/src/diracx/client/patches/aio/utils.py b/diracx-client/src/diracx/client/patches/aio/utils.py index b010521f..94ca2065 100644 --- a/diracx-client/src/diracx/client/patches/aio/utils.py +++ b/diracx-client/src/diracx/client/patches/aio/utils.py @@ -10,6 +10,7 @@ import abc import json +from importlib.metadata import PackageNotFoundError, distribution from types import TracebackType from pathlib import Path from typing import Any, List, Optional, Self @@ -156,6 +157,20 @@ def __init__( # Get .well-known configuration openid_configuration = get_openid_configuration(self._endpoint, verify=verify) + try: + self.client_version = distribution("diracx").version + except PackageNotFoundError: + try: + self.client_version = distribution("diracx-client").version + except PackageNotFoundError: + print("Error while getting client version") + self.client_version = "Unknown" + + # Setting default headers + kwargs.setdefault("base_headers", {})[ + "DiracX-Client-Version" + ] = self.client_version + # Initialize Dirac with a Dirac-specific token credential policy # We need to ignore types here because mypy complains that we give # too many arguments to "object" constructor as this is a mixin diff --git a/diracx-client/src/diracx/client/patches/utils.py b/diracx-client/src/diracx/client/patches/utils.py index 834703c9..86c389f4 100644 --- a/diracx-client/src/diracx/client/patches/utils.py +++ b/diracx-client/src/diracx/client/patches/utils.py @@ -1,10 +1,12 @@ from __future__ import annotations -from datetime import datetime, timezone + import json import jwt import requests +from datetime import datetime, timezone +from importlib.metadata import PackageNotFoundError, distribution from pathlib import Path from typing import Any, Dict, List, Optional, cast, Self @@ -221,6 +223,20 @@ def __init__( # Get .well-known configuration openid_configuration = get_openid_configuration(self._endpoint, verify=verify) + try: + self.client_version = distribution("diracx").version + except PackageNotFoundError: + try: + self.client_version = distribution("diracx-client").version + except PackageNotFoundError: + print("Error while getting client version") + self.client_version = "Unknown" + + # Setting default headers + kwargs.setdefault("base_headers", {})[ + "DiracX-Client-Version" + ] = self.client_version + # Initialize Dirac with a Dirac-specific token credential policy # We need to ignore types here because mypy complains that we give # too many arguments to "object" constructor as this is a mixin diff --git a/diracx-routers/pyproject.toml b/diracx-routers/pyproject.toml index a72c1743..6bc025b6 100644 --- a/diracx-routers/pyproject.toml +++ b/diracx-routers/pyproject.toml @@ -57,6 +57,9 @@ auth = "diracx.routers.auth:router" WMSAccessPolicy = "diracx.routers.job_manager.access_policies:WMSAccessPolicy" SandboxAccessPolicy = "diracx.routers.job_manager.access_policies:SandboxAccessPolicy" +# Minimum version of the client supported +[project.entry-points."diracx.min_client_version"] +diracx = "diracx.routers.version:DIRACX_MIN_CLIENT_VERSION" [tool.setuptools.packages.find] where = ["src"] diff --git a/diracx-routers/src/diracx/routers/__init__.py b/diracx-routers/src/diracx/routers/__init__.py index bea18d43..f20a89b0 100644 --- a/diracx-routers/src/diracx/routers/__init__.py +++ b/diracx-routers/src/diracx/routers/__init__.py @@ -12,6 +12,8 @@ import os from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable, Sequence from functools import partial +from http import HTTPStatus +from importlib.metadata import EntryPoint, EntryPoints, entry_points from logging import Formatter, StreamHandler from typing import ( Any, @@ -21,12 +23,14 @@ import dotenv from cachetools import TTLCache -from fastapi import APIRouter, Depends, Request, status +from fastapi import APIRouter, Depends, FastAPI, HTTPException, Request, status from fastapi.dependencies.models import Dependant from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse, Response from fastapi.routing import APIRoute +from packaging.version import InvalidVersion, parse from pydantic import TypeAdapter +from starlette.middleware.base import BaseHTTPMiddleware from uvicorn.logging import AccessFormatter, DefaultFormatter from diracx.core.config import ConfigSource @@ -297,6 +301,8 @@ def create_app_inner( "http://localhost:8000", ] + app.add_middleware(ClientMinVersionCheckMiddleware) + app.add_middleware( CORSMiddleware, allow_origins=origins, @@ -442,3 +448,53 @@ async def db_transaction(db: T2) -> AsyncGenerator[T2]: if reason := await is_db_unavailable(db): raise DBUnavailable(reason) yield db + + +class ClientMinVersionCheckMiddleware(BaseHTTPMiddleware): + """Custom FastAPI middleware to verify that + the client has the required minimum version. + """ + + def __init__(self, app: FastAPI): + super().__init__(app) + self.min_client_version = get_min_client_version() + self.parsed_min_client_version = parse(self.min_client_version) + + async def dispatch(self, request: Request, call_next) -> Response: + client_version = request.headers.get("DiracX-Client-Version") + if client_version and self.is_version_too_old(client_version): + # When comes from Swagger or Web, there is no client version header. + # This is not managed here. + raise HTTPException( + status_code=HTTPStatus.UPGRADE_REQUIRED, + detail=f"Client version ({client_version}) not recent enough (>= {self.min_client_version}). Upgrade.", + ) + + response = await call_next(request) + return response + + def is_version_too_old(self, client_version: str) -> bool | None: + """Verify that client version is ge than min.""" + try: + return parse(client_version) < self.parsed_min_client_version + except InvalidVersion as iv_exc: + raise HTTPException( + status_code=HTTPStatus.BAD_REQUEST, + detail=f"Invalid version string: '{client_version}'", + ) from iv_exc + + +def get_min_client_version(): + """Extracting min client version from entry_points and searching for extension.""" + matched_entry_points: EntryPoints = entry_points(group="diracx.min_client_version") + # Searching for an extension: + entry_points_dict: dict[str, EntryPoint] = { + ep.name: ep for ep in matched_entry_points + } + for ep_name, ep in entry_points_dict.items(): + if ep_name != "diracx": + return ep.load() + + # Taking diracx if no extension: + if "diracx" in entry_points_dict: + return entry_points_dict["diracx"].load() diff --git a/diracx-routers/src/diracx/routers/version.py b/diracx-routers/src/diracx/routers/version.py new file mode 100644 index 00000000..7c57daf0 --- /dev/null +++ b/diracx-routers/src/diracx/routers/version.py @@ -0,0 +1 @@ +DIRACX_MIN_CLIENT_VERSION = "0.0.1" diff --git a/diracx-routers/tests/test_generic.py b/diracx-routers/tests/test_generic.py index 1f09b2a5..30481cad 100644 --- a/diracx-routers/tests/test_generic.py +++ b/diracx-routers/tests/test_generic.py @@ -1,4 +1,10 @@ +from http import HTTPStatus + import pytest +from fastapi import HTTPException +from packaging.version import Version, parse + +from diracx.routers.version import DIRACX_MIN_CLIENT_VERSION pytestmark = pytest.mark.enabled_dependencies( [ @@ -46,3 +52,22 @@ def test_unavailable_db(monkeypatch, test_client): r = test_client.get("/api/job/123") assert r.status_code == 503 assert r.json() + + +def test_min_client_version_lower_than_expected(test_client): + min_client_version: Version = parse(DIRACX_MIN_CLIENT_VERSION) + lower_version_than_min: Version = ( + f"{min_client_version.major}.{min_client_version.minor}.dev123" + ) + with pytest.raises(HTTPException) as response: + test_client.get("/", headers={"DiracX-Client-Version": lower_version_than_min}) + assert response.value.status_code == HTTPStatus.UPGRADE_REQUIRED + assert str(min_client_version) in response.value.detail + + +def test_invalid_client_version(test_client, caplog: pytest.LogCaptureFixture): + invalid_version = "invalid.version" + with pytest.raises(HTTPException) as response: + test_client.get("/", headers={"DiracX-Client-Version": invalid_version}) + assert response.value.status_code == 400 + assert invalid_version in response.value.detail diff --git a/docs/VERSIONING.md b/docs/VERSIONING.md index 8ec60b50..2f890cf4 100644 --- a/docs/VERSIONING.md +++ b/docs/VERSIONING.md @@ -94,6 +94,9 @@ See this diagram for an example of how this looks in practice: TODO: document the entry point +- `diracx-routers`: + - `diracx.diracx_min_client_version` entry-point defines the diracx minimum client version required by the server to prevent issues. This also searches for extension names instead of `diracx`. The minimum version number has to be updated in `diracx-routers/src/diracx/version.py` + ## Extensions - Extensions will extend one or more of `diracx`, `diracx-routers`, `diracx-tasks` images (e.g. `lhcbdiracx`, `lhcbdiracx-routers`, `lhcbdiracx-tasks`). From cbca461c078115478d1e935994e7b13f7077a556 Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Fri, 18 Oct 2024 11:01:42 +0200 Subject: [PATCH 2/6] regenerate client --- .../src/diracx/client/generated/__init__.py | 6 +- .../src/diracx/client/generated/_client.py | 2 +- .../diracx/client/generated/_configuration.py | 2 +- .../diracx/client/generated/_serialization.py | 7 +- .../src/diracx/client/generated/_vendor.py | 2 +- .../diracx/client/generated/aio/__init__.py | 6 +- .../diracx/client/generated/aio/_client.py | 2 +- .../client/generated/aio/_configuration.py | 2 +- .../diracx/client/generated/aio/_vendor.py | 2 +- .../generated/aio/operations/__init__.py | 4 +- .../generated/aio/operations/_operations.py | 551 ++++++++---------- .../client/generated/models/__init__.py | 4 +- .../diracx/client/generated/models/_enums.py | 2 +- .../diracx/client/generated/models/_models.py | 7 +- .../client/generated/operations/__init__.py | 4 +- .../generated/operations/_operations.py | 551 ++++++++---------- 16 files changed, 489 insertions(+), 665 deletions(-) diff --git a/diracx-client/src/diracx/client/generated/__init__.py b/diracx-client/src/diracx/client/generated/__init__.py index fa740e66..b01cfdc2 100644 --- a/diracx-client/src/diracx/client/generated/__init__.py +++ b/diracx-client/src/diracx/client/generated/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -9,13 +9,13 @@ try: from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import -except ValueError: +except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ "Dirac", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/diracx-client/src/diracx/client/generated/_client.py b/diracx-client/src/diracx/client/generated/_client.py index 434a8038..231f5ef4 100644 --- a/diracx-client/src/diracx/client/generated/_client.py +++ b/diracx-client/src/diracx/client/generated/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/_configuration.py b/diracx-client/src/diracx/client/generated/_configuration.py index e79ab80a..53346cd8 100644 --- a/diracx-client/src/diracx/client/generated/_configuration.py +++ b/diracx-client/src/diracx/client/generated/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/_serialization.py b/diracx-client/src/diracx/client/generated/_serialization.py index 0ba76b66..a058c396 100644 --- a/diracx-client/src/diracx/client/generated/_serialization.py +++ b/diracx-client/src/diracx/client/generated/_serialization.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -235,7 +234,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -637,7 +636,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -1550,7 +1549,7 @@ class Deserializer(object): 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): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, diff --git a/diracx-client/src/diracx/client/generated/_vendor.py b/diracx-client/src/diracx/client/generated/_vendor.py index b8f659c3..68bb7b81 100644 --- a/diracx-client/src/diracx/client/generated/_vendor.py +++ b/diracx-client/src/diracx/client/generated/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/aio/__init__.py b/diracx-client/src/diracx/client/generated/aio/__init__.py index fa740e66..b01cfdc2 100644 --- a/diracx-client/src/diracx/client/generated/aio/__init__.py +++ b/diracx-client/src/diracx/client/generated/aio/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -9,13 +9,13 @@ try: from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import -except ValueError: +except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ "Dirac", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/diracx-client/src/diracx/client/generated/aio/_client.py b/diracx-client/src/diracx/client/generated/aio/_client.py index a6259c31..4bdb75f2 100644 --- a/diracx-client/src/diracx/client/generated/aio/_client.py +++ b/diracx-client/src/diracx/client/generated/aio/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/aio/_configuration.py b/diracx-client/src/diracx/client/generated/aio/_configuration.py index 02de397a..086ea1c6 100644 --- a/diracx-client/src/diracx/client/generated/aio/_configuration.py +++ b/diracx-client/src/diracx/client/generated/aio/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/aio/_vendor.py b/diracx-client/src/diracx/client/generated/aio/_vendor.py index b8f659c3..68bb7b81 100644 --- a/diracx-client/src/diracx/client/generated/aio/_vendor.py +++ b/diracx-client/src/diracx/client/generated/aio/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/aio/operations/__init__.py b/diracx-client/src/diracx/client/generated/aio/operations/__init__.py index 66a084b1..96c3a8b8 100644 --- a/diracx-client/src/diracx/client/generated/aio/operations/__init__.py +++ b/diracx-client/src/diracx/client/generated/aio/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -19,5 +19,5 @@ "ConfigOperations", "JobsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/diracx-client/src/diracx/client/generated/aio/operations/_operations.py b/diracx-client/src/diracx/client/generated/aio/operations/_operations.py index 61f44cb9..a7568277 100644 --- a/diracx-client/src/diracx/client/generated/aio/operations/_operations.py +++ b/diracx-client/src/diracx/client/generated/aio/operations/_operations.py @@ -1,23 +1,12 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import ( - Any, - Callable, - Dict, - IO, - List, - Optional, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core import MatchConditions from azure.core.exceptions import ( @@ -80,7 +69,7 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[ Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any] @@ -119,14 +108,12 @@ async def openid_configuration(self, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -172,14 +159,12 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: :rtype: ~generated.models.Metadata :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -266,14 +251,12 @@ async def initiate_device_flow( :rtype: ~generated.models.InitiateDeviceFlowResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -332,14 +315,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -394,14 +375,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -449,14 +428,12 @@ async def finished(self, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -503,14 +480,12 @@ async def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: :rtype: list[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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -559,14 +534,12 @@ async def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: :rtype: str :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -613,14 +586,12 @@ async def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: :rtype: ~generated.models.UserInfoResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -699,14 +670,12 @@ async def authorization_flow( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -771,14 +740,12 @@ async def authorization_flow_complete( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -867,14 +834,12 @@ async def serve_config( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError elif match_condition == MatchConditions.IfPresent: @@ -1013,14 +978,12 @@ async def initiate_sandbox_upload( :rtype: ~generated.models.SandboxUploadResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1092,14 +1055,12 @@ async def get_sandbox_file( :rtype: ~generated.models.SandboxDownloadResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1152,14 +1113,12 @@ async def unassign_bulk_jobs_sandboxes( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1210,14 +1169,12 @@ async def get_job_sandboxes( :rtype: dict[str, list[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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1266,14 +1223,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1326,14 +1281,12 @@ async def get_job_sandbox( :rtype: list[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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1385,14 +1338,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1486,14 +1437,12 @@ async def submit_bulk_jobs( :rtype: list[~generated.models.InsertedJob] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1557,14 +1506,12 @@ async def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1613,14 +1560,12 @@ async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1673,14 +1618,12 @@ async def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1731,14 +1674,12 @@ async def get_job_status_bulk( :rtype: dict[str, ~generated.models.LimitedJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1849,14 +1790,12 @@ async def set_job_status_bulk( :rtype: dict[str, ~generated.models.SetJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1923,14 +1862,12 @@ async def get_job_status_history_bulk( :rtype: dict[str, list[~generated.models.JobStatusReturn]] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1981,14 +1918,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2037,14 +1972,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2166,14 +2099,12 @@ async def search( :rtype: list[JSON] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2288,14 +2219,12 @@ async def summary( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2357,14 +2286,12 @@ async def get_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2413,14 +2340,12 @@ async def delete_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2475,14 +2400,12 @@ async def set_single_job_properties( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2539,14 +2462,12 @@ async def kill_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2599,14 +2520,12 @@ async def remove_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2657,14 +2576,12 @@ async def get_single_job_status( :rtype: dict[str, ~generated.models.LimitedJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2784,14 +2701,12 @@ async def set_single_job_status( :rtype: dict[str, ~generated.models.SetJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2859,14 +2774,12 @@ async def get_single_job_status_history( :rtype: dict[str, list[~generated.models.JobStatusReturn]] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} diff --git a/diracx-client/src/diracx/client/generated/models/__init__.py b/diracx-client/src/diracx/client/generated/models/__init__.py index ab8c7e13..42b444c1 100644 --- a/diracx-client/src/diracx/client/generated/models/__init__.py +++ b/diracx-client/src/diracx/client/generated/models/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -95,5 +95,5 @@ "SortDirection", "VectorSearchOperator", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/diracx-client/src/diracx/client/generated/models/_enums.py b/diracx-client/src/diracx/client/generated/models/_enums.py index 32076969..d74055c9 100644 --- a/diracx-client/src/diracx/client/generated/models/_enums.py +++ b/diracx-client/src/diracx/client/generated/models/_enums.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/generated/models/_models.py b/diracx-client/src/diracx/client/generated/models/_models.py index e19faec2..47b82e84 100644 --- a/diracx-client/src/diracx/client/generated/models/_models.py +++ b/diracx-client/src/diracx/client/generated/models/_models.py @@ -1,7 +1,7 @@ -# coding=utf-8 # pylint: disable=too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -14,10 +14,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/diracx-client/src/diracx/client/generated/operations/__init__.py b/diracx-client/src/diracx/client/generated/operations/__init__.py index 66a084b1..96c3a8b8 100644 --- a/diracx-client/src/diracx/client/generated/operations/__init__.py +++ b/diracx-client/src/diracx/client/generated/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -19,5 +19,5 @@ "ConfigOperations", "JobsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/diracx-client/src/diracx/client/generated/operations/_operations.py b/diracx-client/src/diracx/client/generated/operations/_operations.py index 61747f2a..ca441334 100644 --- a/diracx-client/src/diracx/client/generated/operations/_operations.py +++ b/diracx-client/src/diracx/client/generated/operations/_operations.py @@ -1,23 +1,12 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.23.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.26.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import ( - Any, - Callable, - Dict, - IO, - List, - Optional, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core import MatchConditions from azure.core.exceptions import ( @@ -41,7 +30,7 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[ Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any] @@ -943,14 +932,12 @@ def openid_configuration(self, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -996,14 +983,12 @@ def installation_metadata(self, **kwargs: Any) -> _models.Metadata: :rtype: ~generated.models.Metadata :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1090,14 +1075,12 @@ def initiate_device_flow( :rtype: ~generated.models.InitiateDeviceFlowResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1156,14 +1139,12 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1218,14 +1199,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1273,14 +1252,12 @@ def finished(self, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1327,14 +1304,12 @@ def get_refresh_tokens(self, **kwargs: Any) -> List[Any]: :rtype: list[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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1383,14 +1358,12 @@ def revoke_refresh_token(self, jti: str, **kwargs: Any) -> str: :rtype: str :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1437,14 +1410,12 @@ def userinfo(self, **kwargs: Any) -> _models.UserInfoResponse: :rtype: ~generated.models.UserInfoResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1523,14 +1494,12 @@ def authorization_flow( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1595,14 +1564,12 @@ def authorization_flow_complete( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1691,14 +1658,12 @@ def serve_config( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError elif match_condition == MatchConditions.IfPresent: @@ -1837,14 +1802,12 @@ def initiate_sandbox_upload( :rtype: ~generated.models.SandboxUploadResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1916,14 +1879,12 @@ def get_sandbox_file( :rtype: ~generated.models.SandboxDownloadResponse :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -1976,14 +1937,12 @@ def unassign_bulk_jobs_sandboxes( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2032,14 +1991,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2088,14 +2045,12 @@ def unassign_job_sandboxes(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2148,14 +2103,12 @@ def get_job_sandbox( :rtype: list[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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2207,14 +2160,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2308,14 +2259,12 @@ def submit_bulk_jobs( :rtype: list[~generated.models.InsertedJob] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2379,14 +2328,12 @@ def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2435,14 +2382,12 @@ def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2495,14 +2440,12 @@ def remove_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2553,14 +2496,12 @@ def get_job_status_bulk( :rtype: dict[str, ~generated.models.LimitedJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2671,14 +2612,12 @@ def set_job_status_bulk( :rtype: dict[str, ~generated.models.SetJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2745,14 +2684,12 @@ def get_job_status_history_bulk( :rtype: dict[str, list[~generated.models.JobStatusReturn]] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2803,14 +2740,12 @@ 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]] = ( - { # pylint: disable=unsubscriptable-object - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - ) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2859,14 +2794,12 @@ def reschedule_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -2988,14 +2921,12 @@ def search( :rtype: list[JSON] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3110,14 +3041,12 @@ def summary( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3179,14 +3108,12 @@ def get_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -3235,14 +3162,12 @@ def delete_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -3297,14 +3222,12 @@ def set_single_job_properties( :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3361,14 +3284,12 @@ def kill_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -3421,14 +3342,12 @@ def remove_single_job(self, job_id: int, **kwargs: Any) -> 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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -3479,14 +3398,12 @@ def get_single_job_status( :rtype: dict[str, ~generated.models.LimitedJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} @@ -3606,14 +3523,12 @@ def set_single_job_status( :rtype: dict[str, ~generated.models.SetJobStatusReturn] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3681,14 +3596,12 @@ def get_single_job_status_history( :rtype: dict[str, list[~generated.models.JobStatusReturn]] :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: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} From 1673f76dadbc2465d549c47bd110335b88ba1062 Mon Sep 17 00:00:00 2001 From: natthan-pigoux Date: Fri, 18 Oct 2024 16:27:33 +0200 Subject: [PATCH 3/6] move min_diracx_version constant in routers init --- diracx-routers/pyproject.toml | 2 +- diracx-routers/src/diracx/routers/__init__.py | 2 ++ diracx-routers/src/diracx/routers/version.py | 1 - diracx-routers/tests/test_generic.py | 2 +- docs/VERSIONING.md | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 diracx-routers/src/diracx/routers/version.py diff --git a/diracx-routers/pyproject.toml b/diracx-routers/pyproject.toml index 6bc025b6..91d99023 100644 --- a/diracx-routers/pyproject.toml +++ b/diracx-routers/pyproject.toml @@ -59,7 +59,7 @@ SandboxAccessPolicy = "diracx.routers.job_manager.access_policies:SandboxAccessP # Minimum version of the client supported [project.entry-points."diracx.min_client_version"] -diracx = "diracx.routers.version:DIRACX_MIN_CLIENT_VERSION" +diracx = "diracx.routers:DIRACX_MIN_CLIENT_VERSION" [tool.setuptools.packages.find] where = ["src"] diff --git a/diracx-routers/src/diracx/routers/__init__.py b/diracx-routers/src/diracx/routers/__init__.py index f20a89b0..baa99784 100644 --- a/diracx-routers/src/diracx/routers/__init__.py +++ b/diracx-routers/src/diracx/routers/__init__.py @@ -54,6 +54,8 @@ logger = logging.getLogger(__name__) +DIRACX_MIN_CLIENT_VERSION = "0.0.1" + ###########################################3 diff --git a/diracx-routers/src/diracx/routers/version.py b/diracx-routers/src/diracx/routers/version.py deleted file mode 100644 index 7c57daf0..00000000 --- a/diracx-routers/src/diracx/routers/version.py +++ /dev/null @@ -1 +0,0 @@ -DIRACX_MIN_CLIENT_VERSION = "0.0.1" diff --git a/diracx-routers/tests/test_generic.py b/diracx-routers/tests/test_generic.py index 30481cad..87b2c3bb 100644 --- a/diracx-routers/tests/test_generic.py +++ b/diracx-routers/tests/test_generic.py @@ -4,7 +4,7 @@ from fastapi import HTTPException from packaging.version import Version, parse -from diracx.routers.version import DIRACX_MIN_CLIENT_VERSION +from diracx.routers import DIRACX_MIN_CLIENT_VERSION pytestmark = pytest.mark.enabled_dependencies( [ diff --git a/docs/VERSIONING.md b/docs/VERSIONING.md index 2f890cf4..3dd0a262 100644 --- a/docs/VERSIONING.md +++ b/docs/VERSIONING.md @@ -95,7 +95,7 @@ See this diagram for an example of how this looks in practice: TODO: document the entry point - `diracx-routers`: - - `diracx.diracx_min_client_version` entry-point defines the diracx minimum client version required by the server to prevent issues. This also searches for extension names instead of `diracx`. The minimum version number has to be updated in `diracx-routers/src/diracx/version.py` + - `diracx.diracx_min_client_version` entry-point defines the diracx minimum client version required by the server to prevent issues. This also searches for extension names instead of `diracx`. The minimum version number has to be updated in `diracx-routers/src/__init.py__` ## Extensions From 55bf0cddf063db6c5ef1019943411db2f234bf38 Mon Sep 17 00:00:00 2001 From: aldbr Date: Thu, 17 Oct 2024 10:56:03 +0200 Subject: [PATCH 4/6] feat(auth): add scope documentation --- diracx-cli/src/diracx/cli/__init__.py | 28 +++++++++++++++++-- .../routers/auth/authorize_code_flow.py | 11 ++++++++ .../src/diracx/routers/auth/device_flow.py | 14 ++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/diracx-cli/src/diracx/cli/__init__.py b/diracx-cli/src/diracx/cli/__init__.py index 9f2a04f9..edf36abe 100644 --- a/diracx-cli/src/diracx/cli/__init__.py +++ b/diracx-cli/src/diracx/cli/__init__.py @@ -38,12 +38,34 @@ def vo_callback(vo: str | None) -> str: @app.async_command() async def login( - vo: Annotated[Optional[str], typer.Argument(callback=vo_callback)] = None, - group: Optional[str] = None, + vo: Annotated[ + Optional[str], + typer.Argument(callback=vo_callback, help="Virtual Organization name"), + ] = None, + group: Optional[str] = typer.Option( + None, + help="Group name within the VO. If not provided, the default group for the VO will be used.", + ), property: Optional[list[str]] = typer.Option( - None, help="Override the default(s) with one or more properties" + None, + help=( + "List of properties to add to the default properties of the group. " + "If not provided, default properties of the group will be used." + ), ), ): + """Login to the DIRAC system using the device flow. + + - If only VO is provided: Uses the default group and its properties for the VO. + + - If VO and group are provided: Uses the specified group and its properties for the VO. + + - If VO and properties are provided: Uses the default group and combines its properties with the + provided properties. + + - If VO, group, and properties are provided: Uses the specified group and combines its properties with the + provided properties. + """ scopes = [f"vo:{vo}"] if group: scopes.append(f"group:{group}") diff --git a/diracx-routers/src/diracx/routers/auth/authorize_code_flow.py b/diracx-routers/src/diracx/routers/auth/authorize_code_flow.py index 7ee4e602..f57aaa43 100644 --- a/diracx-routers/src/diracx/routers/auth/authorize_code_flow.py +++ b/diracx-routers/src/diracx/routers/auth/authorize_code_flow.py @@ -78,6 +78,17 @@ async def authorization_flow( It will redirect to the actual OpenID server (IAM, CheckIn) to perform a authorization code flow. + Scope details: + - If only VO is provided: Uses the default group and its properties for the VO. + + - If VO and group are provided: Uses the specified group and its properties for the VO. + + - If VO and properties are provided: Uses the default group and combines its properties with the + provided properties. + + - If VO, group, and properties are provided: Uses the specified group and combines its properties with the + provided properties. + We set the user details obtained from the user authorize flow in a cookie to be able to map the authorization flow with the corresponding user authorize flow. diff --git a/diracx-routers/src/diracx/routers/auth/device_flow.py b/diracx-routers/src/diracx/routers/auth/device_flow.py index 799a5e3a..3fa47bf6 100644 --- a/diracx-routers/src/diracx/routers/auth/device_flow.py +++ b/diracx-routers/src/diracx/routers/auth/device_flow.py @@ -101,9 +101,17 @@ async def initiate_device_flow( settings: AuthSettings, ) -> InitiateDeviceFlowResponse: """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. + + Scope details: + - If only VO is provided: Uses the default group and its properties for the VO. + + - If VO and group are provided: Uses the specified group and its properties for the VO. + + - If VO and properties are provided: Uses the default group and combines its properties with the + provided properties. + + - If VO, group, and properties are provided: Uses the specified group and combines its properties with the + provided properties. Offers the user to go with the browser to `auth//device?user_code=XYZ` From 6ec7c7441a0c555b3b7777897ea97649990a302c Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Thu, 17 Oct 2024 16:51:31 +0200 Subject: [PATCH 5/6] feat(readme): quick reshuffle of the description --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 058450cf..24431f07 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,24 @@ ![Legacy tests](https://github.com/DIRACGrid/diracx/actions/workflows/integration.yml/badge.svg?branch=main) ![security: bandit](https://github.com/DIRACGrid/diracx/actions/workflows/main.yml/badge.svg?branch=main) -# DiracX Prototype +# DiracX + +This repository contains the code for DiracX. +It is still incomplete. Check the current progress on our [status board](https://github.com/orgs/DIRACGrid/projects/2/views/2). -This repository contains the proof-of-concept code for DiracX. -It is still extremely incomplete and lacking in documentation. Feel free to look around however try not to draw any conclusions as the code is still rapidly evolving. + +## Getting started + +Follow the instructions in the [diracx-charts README](https://github.com/DIRACGrid/diracx-charts?tab=readme-ov-file#running-the-demo-locally) to try it out. + +## Documentation + +The documentation is scattered around [various files](./docs/). + +## Publications and presentations + +- [The NeXt Dirac Incarnation - CHEP 24](https://indico.cern.ch/event/1338689/contributions/6010971/) +- [Eventually coming with some Documentation - Dirac User Workshop 24](https://indico.cern.ch/event/1341205/contributions/5972930/) +- [Demo and Technical details - Dirac & Rucio Workshop 23](https://indico.cern.ch/event/1252369/contributions/5515392/) +- [Dirac: future Part1](https://indico.cern.ch/event/1292287/) and [Part2 - Bild-Dev meeting June 23](https://indico.cern.ch/event/1297397/) From da251208f45596eddd0cabab5cc3570aedc347f0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:55:49 +0000 Subject: [PATCH 6/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.7.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.7.1) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.13.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4abfcfc8..8c39ade6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.6.9' + rev: 'v0.7.1' hooks: - id: ruff args: ["--fix"] @@ -24,7 +24,7 @@ repos: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy additional_dependencies: