From d6f81c37523973ff4e2781edce9f59c386dd7013 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Sat, 8 Jun 2024 14:57:15 +0200 Subject: [PATCH] Regenerate client --- diracx-client/src/diracx/client/__init__.py | 2 +- diracx-client/src/diracx/client/_client.py | 2 +- .../src/diracx/client/_configuration.py | 2 +- .../src/diracx/client/_serialization.py | 2 +- diracx-client/src/diracx/client/_vendor.py | 2 +- .../src/diracx/client/aio/__init__.py | 2 +- .../src/diracx/client/aio/_client.py | 2 +- .../src/diracx/client/aio/_configuration.py | 2 +- .../src/diracx/client/aio/_vendor.py | 2 +- .../diracx/client/aio/operations/__init__.py | 2 +- .../client/aio/operations/_operations.py | 212 +++++++------- .../src/diracx/client/models/__init__.py | 2 +- .../src/diracx/client/models/_enums.py | 14 +- .../src/diracx/client/models/_models.py | 83 +++--- .../src/diracx/client/operations/__init__.py | 2 +- .../diracx/client/operations/_operations.py | 276 +++++++++--------- 16 files changed, 312 insertions(+), 297 deletions(-) diff --git a/diracx-client/src/diracx/client/__init__.py b/diracx-client/src/diracx/client/__init__.py index 97d268e5..cc37da18 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 453a48c0..962319fa 100644 --- a/diracx-client/src/diracx/client/_client.py +++ b/diracx-client/src/diracx/client/_client.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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/_configuration.py b/diracx-client/src/diracx/client/_configuration.py index dec717d6..e1883c55 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 9e56bc07..5e7b24dc 100644 --- a/diracx-client/src/diracx/client/_serialization.py +++ b/diracx-client/src/diracx/client/_serialization.py @@ -1525,7 +1525,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/diracx-client/src/diracx/client/_vendor.py b/diracx-client/src/diracx/client/_vendor.py index 3bf48338..2b77be83 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 97d268e5..cc37da18 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 1e55fa14..e0128831 100644 --- a/diracx-client/src/diracx/client/aio/_client.py +++ b/diracx-client/src/diracx/client/aio/_client.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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/aio/_configuration.py b/diracx-client/src/diracx/client/aio/_configuration.py index de9cabe2..3a48c2b6 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 3bf48338..2b77be83 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 f96f665d..eb877968 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 9aea2d00..8a2f0d53 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -245,22 +245,25 @@ def __init__(self, *args, **kwargs) -> None: ) @distributed_trace_async - async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: - """Do Device Flow. + async def initiate_device_flow( + self, *, client_id: str, scope: str, **kwargs: Any + ) -> _models.InitiateDeviceFlowResponse: + """Initiate Device Flow. - This is called as the verification URI for the device flow. - It will redirect to the actual OpenID server (IAM, CheckIn) to - perform a authorization code 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 - We set the user_code obtained from the device flow in a cookie - to be able to map the authorization flow with the corresponding - device flow. - (note: it can't be put as parameter or in the URL). + Offers the user to go with the browser to + ``auth//device?user_code=XYZ``. - :keyword user_code: Required. - :paramtype user_code: str - :return: any - :rtype: any + :keyword client_id: Required. + :paramtype client_id: str + :keyword scope: Required. + :paramtype scope: str + :return: InitiateDeviceFlowResponse + :rtype: ~client.models.InitiateDeviceFlowResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -274,10 +277,11 @@ async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[_models.InitiateDeviceFlowResponse] = kwargs.pop("cls", None) - _request = build_auth_do_device_flow_request( - user_code=user_code, + _request = build_auth_initiate_device_flow_request( + client_id=client_id, + scope=scope, headers=_headers, params=_params, ) @@ -300,7 +304,9 @@ async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "InitiateDeviceFlowResponse", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -308,25 +314,22 @@ async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace_async - async def initiate_device_flow( - self, *, client_id: str, scope: str, **kwargs: Any - ) -> _models.InitiateDeviceFlowResponse: - """Initiate Device Flow. + async def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: + """Do 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 + This is called as the verification URI for the device flow. + It will redirect to the actual OpenID server (IAM, CheckIn) to + perform a authorization code flow. - Offers the user to go with the browser to - ``auth//device?user_code=XYZ``. + We set the user_code obtained from the device flow in a cookie + to be able to map the authorization flow with the corresponding + device flow. + (note: it can't be put as parameter or in the URL). - :keyword client_id: Required. - :paramtype client_id: str - :keyword scope: Required. - :paramtype scope: str - :return: InitiateDeviceFlowResponse - :rtype: ~client.models.InitiateDeviceFlowResponse + :keyword user_code: Required. + :paramtype user_code: str + :return: any + :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -340,11 +343,10 @@ async def initiate_device_flow( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.InitiateDeviceFlowResponse] = kwargs.pop("cls", None) + cls: ClsType[Any] = kwargs.pop("cls", None) - _request = build_auth_initiate_device_flow_request( - client_id=client_id, - scope=scope, + _request = build_auth_do_device_flow_request( + user_code=user_code, headers=_headers, params=_params, ) @@ -367,9 +369,7 @@ async def initiate_device_flow( ) raise HttpResponseError(response=response) - deserialized = self._deserialize( - "InitiateDeviceFlowResponse", pipeline_response - ) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -939,70 +939,6 @@ def __init__(self, *args, **kwargs) -> None: input_args.pop(0) if input_args else kwargs.pop("deserializer") ) - @distributed_trace_async - async def get_sandbox_file( - self, *, pfn: str, **kwargs: Any - ) -> _models.SandboxDownloadResponse: - """Get 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 - it would leak the authorization token to the storage backend. Additionally, - most storage backends return an error when they receive an authorization - header for a presigned URL. - - :keyword pfn: Required. - :paramtype pfn: str - :return: SandboxDownloadResponse - :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.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SandboxDownloadResponse] = kwargs.pop("cls", None) - - _request = build_jobs_get_sandbox_file_request( - pfn=pfn, - 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("SandboxDownloadResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - @overload async def initiate_sandbox_upload( self, @@ -1132,6 +1068,70 @@ async def initiate_sandbox_upload( return deserialized # type: ignore + @distributed_trace_async + async def get_sandbox_file( + self, *, pfn: str, **kwargs: Any + ) -> _models.SandboxDownloadResponse: + """Get 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 + it would leak the authorization token to the storage backend. Additionally, + most storage backends return an error when they receive an authorization + header for a presigned URL. + + :keyword pfn: Required. + :paramtype pfn: str + :return: SandboxDownloadResponse + :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.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SandboxDownloadResponse] = kwargs.pop("cls", None) + + _request = build_jobs_get_sandbox_file_request( + pfn=pfn, + 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("SandboxDownloadResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace_async async def unassign_bulk_jobs_sandboxes( self, *, jobs_ids: List[int], **kwargs: Any @@ -1369,7 +1369,7 @@ async def get_job_sandbox( async def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> Any: """Assign Sandbox To Job. - Mapp the pfn as output sandbox to job. + Map the pfn as output sandbox to job. :param job_id: Required. :type job_id: int diff --git a/diracx-client/src/diracx/client/models/__init__.py b/diracx-client/src/diracx/client/models/__init__.py index f5323580..7cd1643a 100644 --- a/diracx-client/src/diracx/client/models/__init__.py +++ b/diracx-client/src/diracx/client/models/__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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/diracx-client/src/diracx/client/models/_enums.py b/diracx-client/src/diracx/client/models/_enums.py index 63dde62d..935cbb17 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -9,7 +9,7 @@ class ChecksumAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """ChecksumAlgorithm.""" SHA256 = "sha256" @@ -47,7 +47,7 @@ class Enum4(str, Enum, metaclass=CaseInsensitiveEnumMeta): class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """JobStatus.""" SUBMITTING = "Submitting" RECEIVED = "Received" @@ -67,7 +67,7 @@ class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SandboxFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """SandboxFormat.""" TAR_BZ2 = "tar.bz2" @@ -80,7 +80,7 @@ class SandboxType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ScalarSearchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """ScalarSearchOperator.""" EQ = "eq" NEQ = "neq" @@ -90,14 +90,14 @@ class ScalarSearchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SortDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """SortDirection.""" ASC = "asc" DESC = "desc" class VectorSearchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An enumeration.""" + """VectorSearchOperator.""" IN_ENUM = "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 cfc0edb4..23833265 100644 --- a/diracx-client/src/diracx/client/models/_models.py +++ b/diracx-client/src/diracx/client/models/_models.py @@ -1,18 +1,25 @@ # 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class BodyAuthToken(_serialization.Model): @@ -144,7 +151,7 @@ def __init__( class InitiateDeviceFlowResponse(_serialization.Model): - """InitiateDeviceFlowResponse. + """Response for the device flow initiation. All required parameters must be populated in order to send to server. @@ -319,7 +326,7 @@ class JobStatusReturn(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar status: An enumeration. Required. Known values are: "Submitting", "Received", "Checking", + :ivar status: JobStatus. Required. Known values are: "Submitting", "Received", "Checking", "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", "Deleted", "Killed", and "Rescheduled". :vartype status: str or ~client.models.JobStatus @@ -360,9 +367,9 @@ def __init__( **kwargs: Any, ) -> None: """ - :keyword status: An enumeration. Required. Known values are: "Submitting", "Received", - "Checking", "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", - "Completed", "Failed", "Deleted", "Killed", and "Rescheduled". + :keyword status: JobStatus. Required. Known values are: "Submitting", "Received", "Checking", + "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", + "Failed", "Deleted", "Killed", and "Rescheduled". :paramtype status: str or ~client.models.JobStatus :keyword minor_status: Minorstatus. Required. :paramtype minor_status: str @@ -384,9 +391,9 @@ def __init__( class JobStatusUpdate(_serialization.Model): """JobStatusUpdate. - :ivar status: An enumeration. Known values are: "Submitting", "Received", "Checking", - "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", - "Failed", "Deleted", "Killed", and "Rescheduled". + :ivar status: JobStatus. Known values are: "Submitting", "Received", "Checking", "Staging", + "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", + "Deleted", "Killed", and "Rescheduled". :vartype status: str or ~client.models.JobStatus :ivar minor_status: Minorstatus. :vartype minor_status: str @@ -413,9 +420,9 @@ def __init__( **kwargs: Any, ) -> None: """ - :keyword status: An enumeration. Known values are: "Submitting", "Received", "Checking", - "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", - "Failed", "Deleted", "Killed", and "Rescheduled". + :keyword status: JobStatus. Known values are: "Submitting", "Received", "Checking", "Staging", + "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", + "Deleted", "Killed", and "Rescheduled". :paramtype status: str or ~client.models.JobStatus :keyword minor_status: Minorstatus. :paramtype minor_status: str @@ -478,7 +485,7 @@ class LimitedJobStatusReturn(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar status: An enumeration. Required. Known values are: "Submitting", "Received", "Checking", + :ivar status: JobStatus. Required. Known values are: "Submitting", "Received", "Checking", "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", "Deleted", "Killed", and "Rescheduled". :vartype status: str or ~client.models.JobStatus @@ -509,9 +516,9 @@ def __init__( **kwargs: Any, ) -> None: """ - :keyword status: An enumeration. Required. Known values are: "Submitting", "Received", - "Checking", "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", - "Completed", "Failed", "Deleted", "Killed", and "Rescheduled". + :keyword status: JobStatus. Required. Known values are: "Submitting", "Received", "Checking", + "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", + "Failed", "Deleted", "Killed", and "Rescheduled". :paramtype status: str or ~client.models.JobStatus :keyword minor_status: Minorstatus. Required. :paramtype minor_status: str @@ -590,13 +597,13 @@ class SandboxInfo(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar checksum_algorithm: An enumeration. Required. "sha256" + :ivar checksum_algorithm: ChecksumAlgorithm. Required. "sha256" :vartype checksum_algorithm: str or ~client.models.ChecksumAlgorithm :ivar checksum: Checksum. Required. :vartype checksum: str :ivar size: Size. Required. :vartype size: int - :ivar format: An enumeration. Required. "tar.bz2" + :ivar format: SandboxFormat. Required. "tar.bz2" :vartype format: str or ~client.models.SandboxFormat """ @@ -624,13 +631,13 @@ def __init__( **kwargs: Any, ) -> None: """ - :keyword checksum_algorithm: An enumeration. Required. "sha256" + :keyword checksum_algorithm: ChecksumAlgorithm. Required. "sha256" :paramtype checksum_algorithm: str or ~client.models.ChecksumAlgorithm :keyword checksum: Checksum. Required. :paramtype checksum: str :keyword size: Size. Required. :paramtype size: int - :keyword format: An enumeration. Required. "tar.bz2" + :keyword format: SandboxFormat. Required. "tar.bz2" :paramtype format: str or ~client.models.SandboxFormat """ super().__init__(**kwargs) @@ -692,7 +699,7 @@ class ScalarSearchSpec(_serialization.Model): :ivar parameter: Parameter. Required. :vartype parameter: str - :ivar operator: An enumeration. Required. Known values are: "eq", "neq", "gt", "lt", and + :ivar operator: ScalarSearchOperator. Required. Known values are: "eq", "neq", "gt", "lt", and "like". :vartype operator: str or ~client.models.ScalarSearchOperator :ivar value: Value. Required. @@ -722,8 +729,8 @@ def __init__( """ :keyword parameter: Parameter. Required. :paramtype parameter: str - :keyword operator: An enumeration. Required. Known values are: "eq", "neq", "gt", "lt", and - "like". + :keyword operator: ScalarSearchOperator. Required. Known values are: "eq", "neq", "gt", "lt", + and "like". :paramtype operator: str or ~client.models.ScalarSearchOperator :keyword value: Value. Required. :paramtype value: ~client.models.ScalarSearchSpecValue @@ -741,9 +748,9 @@ class ScalarSearchSpecValue(_serialization.Model): class SetJobStatusReturn(_serialization.Model): """SetJobStatusReturn. - :ivar status: An enumeration. Known values are: "Submitting", "Received", "Checking", - "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", - "Failed", "Deleted", "Killed", and "Rescheduled". + :ivar status: JobStatus. Known values are: "Submitting", "Received", "Checking", "Staging", + "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", + "Deleted", "Killed", and "Rescheduled". :vartype status: str or ~client.models.JobStatus :ivar minor_status: Minorstatus. :vartype minor_status: str @@ -782,9 +789,9 @@ def __init__( **kwargs: Any, ) -> None: """ - :keyword status: An enumeration. Known values are: "Submitting", "Received", "Checking", - "Staging", "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", - "Failed", "Deleted", "Killed", and "Rescheduled". + :keyword status: JobStatus. Known values are: "Submitting", "Received", "Checking", "Staging", + "Waiting", "Matched", "Running", "Stalled", "Completing", "Done", "Completed", "Failed", + "Deleted", "Killed", and "Rescheduled". :paramtype status: str or ~client.models.JobStatus :keyword minor_status: Minorstatus. :paramtype minor_status: str @@ -816,7 +823,7 @@ class SortSpec(_serialization.Model): :ivar parameter: Parameter. Required. :vartype parameter: str - :ivar direction: An enumeration. Required. Known values are: "asc" and "desc". + :ivar direction: SortDirection. Required. Known values are: "asc" and "desc". :vartype direction: str or ~client.models.SortDirection """ @@ -840,7 +847,7 @@ def __init__( """ :keyword parameter: Parameter. Required. :paramtype parameter: str - :keyword direction: An enumeration. Required. Known values are: "asc" and "desc". + :keyword direction: SortDirection. Required. Known values are: "asc" and "desc". :paramtype direction: str or ~client.models.SortDirection """ super().__init__(**kwargs) @@ -944,7 +951,7 @@ def __init__( class UserInfoResponse(_serialization.Model): - """UserInfoResponse. + """Response for the userinfo endpoint. All required parameters must be populated in order to send to server. @@ -954,6 +961,8 @@ class UserInfoResponse(_serialization.Model): :vartype vo: str :ivar dirac_group: Dirac Group. Required. :vartype dirac_group: str + :ivar policies: Policies. Required. + :vartype policies: JSON :ivar properties: Properties. Required. :vartype properties: list[str] :ivar preferred_username: Preferred Username. Required. @@ -964,6 +973,7 @@ class UserInfoResponse(_serialization.Model): "sub": {"required": True}, "vo": {"required": True}, "dirac_group": {"required": True}, + "policies": {"required": True}, "properties": {"required": True}, "preferred_username": {"required": True}, } @@ -972,6 +982,7 @@ class UserInfoResponse(_serialization.Model): "sub": {"key": "sub", "type": "str"}, "vo": {"key": "vo", "type": "str"}, "dirac_group": {"key": "dirac_group", "type": "str"}, + "policies": {"key": "policies", "type": "object"}, "properties": {"key": "properties", "type": "[str]"}, "preferred_username": {"key": "preferred_username", "type": "str"}, } @@ -982,6 +993,7 @@ def __init__( sub: str, vo: str, dirac_group: str, + policies: JSON, properties: List[str], preferred_username: str, **kwargs: Any, @@ -993,6 +1005,8 @@ def __init__( :paramtype vo: str :keyword dirac_group: Dirac Group. Required. :paramtype dirac_group: str + :keyword policies: Policies. Required. + :paramtype policies: JSON :keyword properties: Properties. Required. :paramtype properties: list[str] :keyword preferred_username: Preferred Username. Required. @@ -1002,6 +1016,7 @@ def __init__( self.sub = sub self.vo = vo self.dirac_group = dirac_group + self.policies = policies self.properties = properties self.preferred_username = preferred_username @@ -1064,7 +1079,7 @@ class VectorSearchSpec(_serialization.Model): :ivar parameter: Parameter. Required. :vartype parameter: str - :ivar operator: An enumeration. Required. Known values are: "in" and "not in". + :ivar operator: VectorSearchOperator. Required. Known values are: "in" and "not in". :vartype operator: str or ~client.models.VectorSearchOperator :ivar values: Values. Required. :vartype values: ~client.models.VectorSearchSpecValues @@ -1093,7 +1108,7 @@ def __init__( """ :keyword parameter: Parameter. Required. :paramtype parameter: str - :keyword operator: An enumeration. Required. Known values are: "in" and "not in". + :keyword operator: VectorSearchOperator. Required. Known values are: "in" and "not in". :paramtype operator: str or ~client.models.VectorSearchOperator :keyword values: Values. Required. :paramtype values: ~client.models.VectorSearchSpecValues diff --git a/diracx-client/src/diracx/client/operations/__init__.py b/diracx-client/src/diracx/client/operations/__init__.py index f96f665d..eb877968 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # 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 048d85a2..800996ab 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.17) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -84,7 +84,9 @@ def build_well_known_installation_metadata_request( return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_auth_do_device_flow_request(*, user_code: str, **kwargs: Any) -> HttpRequest: +def build_auth_initiate_device_flow_request( + *, client_id: str, scope: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -94,19 +96,18 @@ def build_auth_do_device_flow_request(*, user_code: str, **kwargs: Any) -> HttpR _url = "/api/auth/device" # Construct parameters - _params["user_code"] = _SERIALIZER.query("user_code", user_code, "str") + _params["client_id"] = _SERIALIZER.query("client_id", client_id, "str") + _params["scope"] = _SERIALIZER.query("scope", scope, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( - method="GET", url=_url, params=_params, headers=_headers, **kwargs + method="POST", url=_url, params=_params, headers=_headers, **kwargs ) -def build_auth_initiate_device_flow_request( - *, client_id: str, scope: str, **kwargs: Any -) -> HttpRequest: +def build_auth_do_device_flow_request(*, user_code: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -116,14 +117,13 @@ def build_auth_initiate_device_flow_request( _url = "/api/auth/device" # Construct parameters - _params["client_id"] = _SERIALIZER.query("client_id", client_id, "str") - _params["scope"] = _SERIALIZER.query("scope", scope, "str") + _params["user_code"] = _SERIALIZER.query("user_code", user_code, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs + method="GET", url=_url, params=_params, headers=_headers, **kwargs ) @@ -306,6 +306,29 @@ def build_config_serve_config_request( return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) +def build_jobs_initiate_sandbox_upload_request( + **kwargs: Any, +) -> HttpRequest: # pylint: disable=name-too-long + _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/sandbox" + + # 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_sandbox_file_request(*, pfn: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -332,29 +355,6 @@ def build_jobs_get_sandbox_file_request(*, pfn: str, **kwargs: Any) -> HttpReque ) -def build_jobs_initiate_sandbox_upload_request( - **kwargs: Any, -) -> HttpRequest: # pylint: disable=name-too-long - _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/sandbox" - - # 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_unassign_bulk_jobs_sandboxes_request( # pylint: disable=name-too-long *, jobs_ids: List[int], **kwargs: Any ) -> HttpRequest: @@ -1069,22 +1069,25 @@ def __init__(self, *args, **kwargs): ) @distributed_trace - def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: - """Do Device Flow. + def initiate_device_flow( + self, *, client_id: str, scope: str, **kwargs: Any + ) -> _models.InitiateDeviceFlowResponse: + """Initiate Device Flow. - This is called as the verification URI for the device flow. - It will redirect to the actual OpenID server (IAM, CheckIn) to - perform a authorization code 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 - We set the user_code obtained from the device flow in a cookie - to be able to map the authorization flow with the corresponding - device flow. - (note: it can't be put as parameter or in the URL). + Offers the user to go with the browser to + ``auth//device?user_code=XYZ``. - :keyword user_code: Required. - :paramtype user_code: str - :return: any - :rtype: any + :keyword client_id: Required. + :paramtype client_id: str + :keyword scope: Required. + :paramtype scope: str + :return: InitiateDeviceFlowResponse + :rtype: ~client.models.InitiateDeviceFlowResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -1098,10 +1101,11 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[_models.InitiateDeviceFlowResponse] = kwargs.pop("cls", None) - _request = build_auth_do_device_flow_request( - user_code=user_code, + _request = build_auth_initiate_device_flow_request( + client_id=client_id, + scope=scope, headers=_headers, params=_params, ) @@ -1124,7 +1128,9 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize( + "InitiateDeviceFlowResponse", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1132,25 +1138,22 @@ def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace - def initiate_device_flow( - self, *, client_id: str, scope: str, **kwargs: Any - ) -> _models.InitiateDeviceFlowResponse: - """Initiate Device Flow. + def do_device_flow(self, *, user_code: str, **kwargs: Any) -> Any: + """Do 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 + This is called as the verification URI for the device flow. + It will redirect to the actual OpenID server (IAM, CheckIn) to + perform a authorization code flow. - Offers the user to go with the browser to - ``auth//device?user_code=XYZ``. + We set the user_code obtained from the device flow in a cookie + to be able to map the authorization flow with the corresponding + device flow. + (note: it can't be put as parameter or in the URL). - :keyword client_id: Required. - :paramtype client_id: str - :keyword scope: Required. - :paramtype scope: str - :return: InitiateDeviceFlowResponse - :rtype: ~client.models.InitiateDeviceFlowResponse + :keyword user_code: Required. + :paramtype user_code: str + :return: any + :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -1164,11 +1167,10 @@ def initiate_device_flow( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.InitiateDeviceFlowResponse] = kwargs.pop("cls", None) + cls: ClsType[Any] = kwargs.pop("cls", None) - _request = build_auth_initiate_device_flow_request( - client_id=client_id, - scope=scope, + _request = build_auth_do_device_flow_request( + user_code=user_code, headers=_headers, params=_params, ) @@ -1191,9 +1193,7 @@ def initiate_device_flow( ) raise HttpResponseError(response=response) - deserialized = self._deserialize( - "InitiateDeviceFlowResponse", pipeline_response - ) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1763,70 +1763,6 @@ def __init__(self, *args, **kwargs): input_args.pop(0) if input_args else kwargs.pop("deserializer") ) - @distributed_trace - def get_sandbox_file( - self, *, pfn: str, **kwargs: Any - ) -> _models.SandboxDownloadResponse: - """Get 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 - it would leak the authorization token to the storage backend. Additionally, - most storage backends return an error when they receive an authorization - header for a presigned URL. - - :keyword pfn: Required. - :paramtype pfn: str - :return: SandboxDownloadResponse - :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.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.SandboxDownloadResponse] = kwargs.pop("cls", None) - - _request = build_jobs_get_sandbox_file_request( - pfn=pfn, - 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("SandboxDownloadResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - @overload def initiate_sandbox_upload( self, @@ -1956,6 +1892,70 @@ def initiate_sandbox_upload( return deserialized # type: ignore + @distributed_trace + def get_sandbox_file( + self, *, pfn: str, **kwargs: Any + ) -> _models.SandboxDownloadResponse: + """Get 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 + it would leak the authorization token to the storage backend. Additionally, + most storage backends return an error when they receive an authorization + header for a presigned URL. + + :keyword pfn: Required. + :paramtype pfn: str + :return: SandboxDownloadResponse + :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.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SandboxDownloadResponse] = kwargs.pop("cls", None) + + _request = build_jobs_get_sandbox_file_request( + pfn=pfn, + 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("SandboxDownloadResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace def unassign_bulk_jobs_sandboxes( self, *, jobs_ids: List[int], **kwargs: Any @@ -2191,7 +2191,7 @@ def get_job_sandbox( def assign_sandbox_to_job(self, job_id: int, body: str, **kwargs: Any) -> Any: """Assign Sandbox To Job. - Mapp the pfn as output sandbox to job. + Map the pfn as output sandbox to job. :param job_id: Required. :type job_id: int