From f731204c15af4152e7e12443de4273e5b4bfd1ac Mon Sep 17 00:00:00 2001 From: aldbr Date: Mon, 18 Sep 2023 11:07:55 +0200 Subject: [PATCH] feat: remove TokenResponse.state --- src/diracx/cli/__init__.py | 3 +- src/diracx/client/_patch.py | 3 +- src/diracx/client/aio/_patch.py | 2 +- .../client/aio/operations/_operations.py | 662 ++++++++------ src/diracx/client/models/__init__.py | 4 + src/diracx/client/models/_enums.py | 15 +- src/diracx/client/models/_models.py | 251 +++++- src/diracx/client/operations/_operations.py | 844 ++++++++++-------- src/diracx/core/models.py | 5 +- src/diracx/core/utils.py | 4 +- src/diracx/routers/auth.py | 3 +- tests/db/jobs/test_jobLoggingDB.py | 2 +- 12 files changed, 1099 insertions(+), 699 deletions(-) diff --git a/src/diracx/cli/__init__.py b/src/diracx/cli/__init__.py index 70b13d18c..09343de7d 100644 --- a/src/diracx/cli/__init__.py +++ b/src/diracx/cli/__init__.py @@ -57,9 +57,8 @@ async def login( raise RuntimeError("Device authorization flow expired") # Save credentials - credentials_path = get_diracx_preferences().credentials_path - credentials_path.parent.mkdir(parents=True, exist_ok=True) write_credentials(response) + credentials_path = get_diracx_preferences().credentials_path print(f"Saved credentials to {credentials_path}") print("\nLogin successful!") diff --git a/src/diracx/client/_patch.py b/src/diracx/client/_patch.py index ab60d7e82..c31f738b6 100644 --- a/src/diracx/client/_patch.py +++ b/src/diracx/client/_patch.py @@ -168,9 +168,8 @@ def refresh_token( token_response = TokenResponse( access_token=res["access_token"], expires_in=res["expires_in"], - state=res["state"], - refresh_token=res.get("refresh_token"), token_type=res.get("token_type"), + refresh_token=res.get("refresh_token"), ) write_credentials(cast(CoreTokenResponse, token_response)) diff --git a/src/diracx/client/aio/_patch.py b/src/diracx/client/aio/_patch.py index 2be6688a0..f20c3b5c6 100644 --- a/src/diracx/client/aio/_patch.py +++ b/src/diracx/client/aio/_patch.py @@ -9,7 +9,7 @@ import json from types import TracebackType from pathlib import Path -from typing import Any, List, Optional, cast +from typing import Any, List, Optional from azure.core.credentials import AccessToken from azure.core.credentials_async import AsyncTokenCredential from azure.core.pipeline import PipelineRequest diff --git a/src/diracx/client/aio/operations/_operations.py b/src/diracx/client/aio/operations/_operations.py index a52b1b4c8..28ed56605 100644 --- a/src/diracx/client/aio/operations/_operations.py +++ b/src/diracx/client/aio/operations/_operations.py @@ -34,15 +34,15 @@ build_auth_revoke_refresh_token_request, build_config_serve_config_request, build_jobs_delete_bulk_jobs_request, - build_jobs_delete_single_job_request, - build_jobs_get_bulk_job_status_request, + build_jobs_get_job_status_bulk_request, + build_jobs_get_job_status_history_bulk_request, build_jobs_get_single_job_request, + build_jobs_get_single_job_status_history_request, build_jobs_get_single_job_status_request, build_jobs_kill_bulk_jobs_request, - build_jobs_kill_single_job_request, build_jobs_search_request, + build_jobs_set_job_status_bulk_request, build_jobs_set_single_job_status_request, - build_jobs_set_status_bulk_request, build_jobs_submit_bulk_jobs_request, build_jobs_summary_request, build_well_known_openid_configuration_request, @@ -930,13 +930,13 @@ async def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized @distributed_trace_async - async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Get Single Job. + async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: + """Kill Bulk Jobs. - Get Single Job. + Kill Bulk Jobs. - :param job_id: Required. - :type job_id: int + :keyword job_ids: Required. + :paramtype job_ids: list[int] :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -954,8 +954,8 @@ async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_get_single_job_request( - job_id=job_id, + request = build_jobs_kill_bulk_jobs_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -984,15 +984,17 @@ async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: return deserialized @distributed_trace_async - async def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Delete Single Job. + async def get_job_status_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Job Status Bulk. - Delete Single Job. + Get Job Status Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1006,10 +1008,12 @@ async def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None + ) - request = build_jobs_delete_single_job_request( - job_id=job_id, + request = build_jobs_get_job_status_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -1030,23 +1034,84 @@ async def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + async def set_job_status_bulk( + self, + body: Dict[str, Dict[str, _models.JobStatusUpdate]], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. + + Set Job Status Bulk. + + :param body: Required. + :type body: dict[str, dict[str, ~client.models.JobStatusUpdate]] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_job_status_bulk( + self, + body: IO, + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. + + Set Job Status Bulk. + + :param body: Required. + :type body: IO + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Kill Single Job. + async def set_job_status_bulk( + self, + body: Union[Dict[str, Dict[str, _models.JobStatusUpdate]], IO], + *, + force: bool = False, + **kwargs: Any + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. - Kill Single Job. + Set Job Status Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :param body: Is either a {str: {str: JobStatusUpdate}} type or a IO type. Required. + :type body: dict[str, dict[str, ~client.models.JobStatusUpdate]] or IO + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1057,13 +1122,27 @@ async def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - request = build_jobs_kill_single_job_request( - job_id=job_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "{{JobStatusUpdate}}") + + request = build_jobs_set_job_status_bulk_request( + force=force, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1084,7 +1163,7 @@ async def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1092,17 +1171,17 @@ async def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: return deserialized @distributed_trace_async - async def get_single_job_status( - self, job_id: int, **kwargs: Any - ) -> Union[str, _models.JobStatus]: - """Get Single Job Status. + async def get_job_status_history_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Job Status History Bulk. - Get Single Job Status. + Get Job Status History Bulk. - :param job_id: Required. - :type job_id: int - :return: JobStatus - :rtype: str or ~client.models.JobStatus + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1116,10 +1195,10 @@ async def get_single_job_status( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Union[str, _models.JobStatus]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - request = build_jobs_get_single_job_status_request( - job_id=job_id, + request = build_jobs_get_job_status_history_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -1140,28 +1219,99 @@ async def get_single_job_status( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + async def search( + self, + body: Optional[_models.JobSearchParams] = None, + *, + page: int = 0, + per_page: int = 100, + content_type: str = "application/json", + **kwargs: Any + ) -> List[JSON]: + """Search. + + Retrieve information about jobs. + + **TODO: Add more docs**. + + :param body: Default value is None. + :type body: ~client.models.JobSearchParams + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def search( + self, + body: Optional[IO] = None, + *, + page: int = 0, + per_page: int = 100, + content_type: str = "application/json", + **kwargs: Any + ) -> List[JSON]: + """Search. + + Retrieve information about jobs. + + **TODO: Add more docs**. + + :param body: Default value is None. + :type body: IO + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def set_single_job_status( - self, job_id: int, *, status: Union[str, _models.JobStatus], **kwargs: Any - ) -> Any: - """Set Single Job Status. + async def search( + self, + body: Optional[Union[_models.JobSearchParams, IO]] = None, + *, + page: int = 0, + per_page: int = 100, + **kwargs: Any + ) -> List[JSON]: + """Search. - Set Single Job Status. + Retrieve information about jobs. - :param job_id: Required. - :type job_id: int - :keyword status: Known values are: "Running", "Stalled", "Killed", "Failed", "RECEIVED", and - "Submitting". Required. - :paramtype status: str or ~client.models.JobStatus - :return: any - :rtype: any + **TODO: Add more docs**. + + :param body: Is either a JobSearchParams type or a IO type. Default value is None. + :type body: ~client.models.JobSearchParams or IO + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1172,14 +1322,31 @@ async def set_single_job_status( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[List[JSON]] = kwargs.pop("cls", None) - request = build_jobs_set_single_job_status_request( - job_id=job_id, - status=status, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "JobSearchParams") + else: + _json = None + + request = build_jobs_search_request( + page=page, + per_page=per_page, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1200,21 +1367,66 @@ async def set_single_job_status( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + async def summary( + self, + body: _models.JobSummaryParams, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Any: + """Summary. + + Show information suitable for plotting. + + :param body: Required. + :type body: ~client.models.JobSummaryParams + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def summary( + self, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> Any: + """Summary. + + Show information suitable for plotting. + + :param body: Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Kill Bulk Jobs. + async def summary( + self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any + ) -> Any: + """Summary. - Kill Bulk Jobs. + Show information suitable for plotting. - :keyword job_ids: Required. - :paramtype job_ids: list[int] + :param body: Is either a JobSummaryParams type or a IO type. Required. + :type body: ~client.models.JobSummaryParams or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -1227,13 +1439,26 @@ async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_kill_bulk_jobs_request( - job_ids=job_ids, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JobSummaryParams") + + request = build_jobs_summary_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1262,13 +1487,13 @@ async def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized @distributed_trace_async - async def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Get Bulk Job Status. + async def get_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Get Single Job. - Get Bulk Job Status. + Get Single Job. - :keyword job_ids: Required. - :paramtype job_ids: list[int] + :param job_id: Required. + :type job_id: int :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -1286,8 +1511,8 @@ async def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_get_bulk_job_status_request( - job_ids=job_ids, + request = build_jobs_get_single_job_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1315,61 +1540,18 @@ async def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any return deserialized - @overload - async def set_status_bulk( - self, - body: List[_models.JobStatusUpdate], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. - - Set Status Bulk. - - :param body: Required. - :type body: list[~client.models.JobStatusUpdate] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def set_status_bulk( - self, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. - - Set Status Bulk. - - :param body: Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def set_status_bulk( - self, body: Union[List[_models.JobStatusUpdate], IO], **kwargs: Any - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. + async def get_single_job_status( + self, job_id: int, **kwargs: Any + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Single Job Status. - Set Status Bulk. + Get Single Job Status. - :param body: Is either a [JobStatusUpdate] type or a IO type. Required. - :type body: list[~client.models.JobStatusUpdate] or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] + :param job_id: Required. + :type job_id: int + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1380,26 +1562,15 @@ async def set_status_bulk( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None ) - cls: ClsType[List[_models.JobStatusReturn]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "[JobStatusUpdate]") - - request = build_jobs_set_status_bulk_request( - content_type=content_type, - json=_json, - content=_content, + request = build_jobs_get_single_job_status_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1420,7 +1591,7 @@ async def set_status_bulk( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[JobStatusReturn]", pipeline_response) + deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1428,91 +1599,85 @@ async def set_status_bulk( return deserialized @overload - async def search( + async def set_single_job_status( self, - body: Optional[_models.JobSearchParams] = None, + job_id: int, + body: Dict[str, _models.JobStatusUpdate], *, - page: int = 0, - per_page: int = 100, + force: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Default value is None. - :type body: ~client.models.JobSearchParams - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: dict[str, ~client.models.JobStatusUpdate] + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def search( + async def set_single_job_status( self, - body: Optional[IO] = None, + job_id: int, + body: IO, *, - page: int = 0, - per_page: int = 100, + force: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Default value is None. + :param job_id: Required. + :type job_id: int + :param body: Required. :type body: IO - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def search( + async def set_single_job_status( self, - body: Optional[Union[_models.JobSearchParams, IO]] = None, + job_id: int, + body: Union[Dict[str, _models.JobStatusUpdate], IO], *, - page: int = 0, - per_page: int = 100, + force: bool = False, **kwargs: Any - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Is either a JobSearchParams type or a IO type. Default value is None. - :type body: ~client.models.JobSearchParams or IO - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :param job_id: Required. + :type job_id: int + :param body: Is either a {str: JobStatusUpdate} type or a IO type. Required. + :type body: dict[str, ~client.models.JobStatusUpdate] or IO + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1529,7 +1694,7 @@ async def search( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[List[JSON]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1537,14 +1702,11 @@ async def search( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "JobSearchParams") - else: - _json = None + _json = self._serialize.body(body, "{JobStatusUpdate}") - request = build_jobs_search_request( - page=page, - per_page=per_page, + request = build_jobs_set_single_job_status_request( + job_id=job_id, + force=force, content_type=content_type, json=_json, content=_content, @@ -1568,68 +1730,25 @@ async def search( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - @overload - async def summary( - self, - body: _models.JobSummaryParams, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Any: - """Summary. - - Show information suitable for plotting. - - :param body: Required. - :type body: ~client.models.JobSummaryParams - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def summary( - self, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> Any: - """Summary. - - Show information suitable for plotting. - - :param body: Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def summary( - self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any - ) -> Any: - """Summary. + async def get_single_job_status_history( + self, job_id: int, **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Single Job Status History. - Show information suitable for plotting. + Get Single Job Status History. - :param body: Is either a JobSummaryParams type or a IO type. Required. - :type body: ~client.models.JobSummaryParams or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1640,26 +1759,13 @@ async def summary( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JobSummaryParams") - - request = build_jobs_summary_request( - content_type=content_type, - json=_json, - content=_content, + request = build_jobs_get_single_job_status_history_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1680,7 +1786,7 @@ async def summary( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) diff --git a/src/diracx/client/models/__init__.py b/src/diracx/client/models/__init__.py index 03647fd5d..9d5c963ea 100644 --- a/src/diracx/client/models/__init__.py +++ b/src/diracx/client/models/__init__.py @@ -15,7 +15,9 @@ from ._models import JobStatusUpdate from ._models import JobSummaryParams from ._models import JobSummaryParamsSearchItem +from ._models import LimitedJobStatusReturn from ._models import ScalarSearchSpec +from ._models import SetJobStatusReturn from ._models import SortSpec from ._models import SortSpecDirection from ._models import TokenResponse @@ -49,7 +51,9 @@ "JobStatusUpdate", "JobSummaryParams", "JobSummaryParamsSearchItem", + "LimitedJobStatusReturn", "ScalarSearchSpec", + "SetJobStatusReturn", "SortSpec", "SortSpecDirection", "TokenResponse", diff --git a/src/diracx/client/models/_enums.py b/src/diracx/client/models/_enums.py index b792f4785..ccabc77c7 100644 --- a/src/diracx/client/models/_enums.py +++ b/src/diracx/client/models/_enums.py @@ -55,12 +55,21 @@ class Enum9(str, Enum, metaclass=CaseInsensitiveEnumMeta): class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An enumeration.""" + SUBMITTING = "Submitting" + RECEIVED = "Received" + CHECKING = "Checking" + STAGING = "Staging" + WAITING = "Waiting" + MATCHED = "Matched" RUNNING = "Running" STALLED = "Stalled" - KILLED = "Killed" + COMPLETING = "Completing" + DONE = "Done" + COMPLETED = "Completed" FAILED = "Failed" - RECEIVED = "RECEIVED" - SUBMITTING = "Submitting" + DELETED = "Deleted" + KILLED = "Killed" + RESCHEDULED = "Rescheduled" class ScalarSearchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/src/diracx/client/models/_models.py b/src/diracx/client/models/_models.py index e258ef566..807777507 100644 --- a/src/diracx/client/models/_models.py +++ b/src/diracx/client/models/_models.py @@ -298,73 +298,116 @@ class JobStatusReturn(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar job_id: Job Id. Required. - :vartype job_id: int - :ivar status: An enumeration. Required. Known values are: "Running", "Stalled", "Killed", - "Failed", "RECEIVED", and "Submitting". + :ivar status: An enumeration. 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 + :ivar minor_status: Minorstatus. Required. + :vartype minor_status: str + :ivar application_status: Applicationstatus. Required. + :vartype application_status: str + :ivar status_time: Statustime. Required. + :vartype status_time: ~datetime.datetime + :ivar status_source: Statussource. Required. + :vartype status_source: str """ _validation = { - "job_id": {"required": True}, "status": {"required": True}, + "minor_status": {"required": True}, + "application_status": {"required": True}, + "status_time": {"required": True}, + "status_source": {"required": True}, } _attribute_map = { - "job_id": {"key": "job_id", "type": "int"}, - "status": {"key": "status", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "minor_status": {"key": "MinorStatus", "type": "str"}, + "application_status": {"key": "ApplicationStatus", "type": "str"}, + "status_time": {"key": "StatusTime", "type": "iso-8601"}, + "status_source": {"key": "StatusSource", "type": "str"}, } def __init__( - self, *, job_id: int, status: Union[str, "_models.JobStatus"], **kwargs: Any + self, + *, + status: Union[str, "_models.JobStatus"], + minor_status: str, + application_status: str, + status_time: datetime.datetime, + status_source: str, + **kwargs: Any ) -> None: """ - :keyword job_id: Job Id. Required. - :paramtype job_id: int - :keyword status: An enumeration. Required. Known values are: "Running", "Stalled", "Killed", - "Failed", "RECEIVED", and "Submitting". + :keyword status: An enumeration. 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 + :keyword application_status: Applicationstatus. Required. + :paramtype application_status: str + :keyword status_time: Statustime. Required. + :paramtype status_time: ~datetime.datetime + :keyword status_source: Statussource. Required. + :paramtype status_source: str """ super().__init__(**kwargs) - self.job_id = job_id self.status = status + self.minor_status = minor_status + self.application_status = application_status + self.status_time = status_time + self.status_source = status_source class JobStatusUpdate(_serialization.Model): """JobStatusUpdate. - All required parameters must be populated in order to send to Azure. - - :ivar job_id: Job Id. Required. - :vartype job_id: int - :ivar status: An enumeration. Required. Known values are: "Running", "Stalled", "Killed", - "Failed", "RECEIVED", and "Submitting". + :ivar status: An enumeration. 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 + :ivar application_status: Applicationstatus. + :vartype application_status: str + :ivar status_source: Statussource. + :vartype status_source: str """ - _validation = { - "job_id": {"required": True}, - "status": {"required": True}, - } - _attribute_map = { - "job_id": {"key": "job_id", "type": "int"}, - "status": {"key": "status", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "minor_status": {"key": "MinorStatus", "type": "str"}, + "application_status": {"key": "ApplicationStatus", "type": "str"}, + "status_source": {"key": "StatusSource", "type": "str"}, } def __init__( - self, *, job_id: int, status: Union[str, "_models.JobStatus"], **kwargs: Any + self, + *, + status: Optional[Union[str, "_models.JobStatus"]] = None, + minor_status: Optional[str] = None, + application_status: Optional[str] = None, + status_source: str = "Unknown", + **kwargs: Any ) -> None: """ - :keyword job_id: Job Id. Required. - :paramtype job_id: int - :keyword status: An enumeration. Required. Known values are: "Running", "Stalled", "Killed", - "Failed", "RECEIVED", and "Submitting". + :keyword status: An enumeration. 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 + :keyword application_status: Applicationstatus. + :paramtype application_status: str + :keyword status_source: Statussource. + :paramtype status_source: str """ super().__init__(**kwargs) - self.job_id = job_id self.status = status + self.minor_status = minor_status + self.application_status = application_status + self.status_source = status_source class JobSummaryParams(_serialization.Model): @@ -415,6 +458,57 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) +class LimitedJobStatusReturn(_serialization.Model): + """LimitedJobStatusReturn. + + All required parameters must be populated in order to send to Azure. + + :ivar status: An enumeration. 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 + :ivar minor_status: Minorstatus. Required. + :vartype minor_status: str + :ivar application_status: Applicationstatus. Required. + :vartype application_status: str + """ + + _validation = { + "status": {"required": True}, + "minor_status": {"required": True}, + "application_status": {"required": True}, + } + + _attribute_map = { + "status": {"key": "Status", "type": "str"}, + "minor_status": {"key": "MinorStatus", "type": "str"}, + "application_status": {"key": "ApplicationStatus", "type": "str"}, + } + + def __init__( + self, + *, + status: Union[str, "_models.JobStatus"], + minor_status: str, + application_status: str, + **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". + :paramtype status: str or ~client.models.JobStatus + :keyword minor_status: Minorstatus. Required. + :paramtype minor_status: str + :keyword application_status: Applicationstatus. Required. + :paramtype application_status: str + """ + super().__init__(**kwargs) + self.status = status + self.minor_status = minor_status + self.application_status = application_status + + class ScalarSearchSpec(_serialization.Model): """ScalarSearchSpec. @@ -464,6 +558,77 @@ def __init__( self.value = value +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". + :vartype status: str or ~client.models.JobStatus + :ivar minor_status: Minorstatus. + :vartype minor_status: str + :ivar application_status: Applicationstatus. + :vartype application_status: str + :ivar heart_beat_time: Heartbeattime. + :vartype heart_beat_time: ~datetime.datetime + :ivar start_exec_time: Startexectime. + :vartype start_exec_time: ~datetime.datetime + :ivar end_exec_time: Endexectime. + :vartype end_exec_time: ~datetime.datetime + :ivar last_update_time: Lastupdatetime. + :vartype last_update_time: ~datetime.datetime + """ + + _attribute_map = { + "status": {"key": "Status", "type": "str"}, + "minor_status": {"key": "MinorStatus", "type": "str"}, + "application_status": {"key": "ApplicationStatus", "type": "str"}, + "heart_beat_time": {"key": "HeartBeatTime", "type": "iso-8601"}, + "start_exec_time": {"key": "StartExecTime", "type": "iso-8601"}, + "end_exec_time": {"key": "EndExecTime", "type": "iso-8601"}, + "last_update_time": {"key": "LastUpdateTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.JobStatus"]] = None, + minor_status: Optional[str] = None, + application_status: Optional[str] = None, + heart_beat_time: Optional[datetime.datetime] = None, + start_exec_time: Optional[datetime.datetime] = None, + end_exec_time: Optional[datetime.datetime] = None, + last_update_time: Optional[datetime.datetime] = None, + **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". + :paramtype status: str or ~client.models.JobStatus + :keyword minor_status: Minorstatus. + :paramtype minor_status: str + :keyword application_status: Applicationstatus. + :paramtype application_status: str + :keyword heart_beat_time: Heartbeattime. + :paramtype heart_beat_time: ~datetime.datetime + :keyword start_exec_time: Startexectime. + :paramtype start_exec_time: ~datetime.datetime + :keyword end_exec_time: Endexectime. + :paramtype end_exec_time: ~datetime.datetime + :keyword last_update_time: Lastupdatetime. + :paramtype last_update_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.status = status + self.minor_status = minor_status + self.application_status = application_status + self.heart_beat_time = heart_beat_time + self.start_exec_time = start_exec_time + self.end_exec_time = end_exec_time + self.last_update_time = last_update_time + + class SortSpec(_serialization.Model): """SortSpec. @@ -516,28 +681,24 @@ class TokenResponse(_serialization.Model): :ivar access_token: Access Token. Required. :vartype access_token: str - :ivar refresh_token: Refresh Token. - :vartype refresh_token: str :ivar expires_in: Expires In. Required. :vartype expires_in: int :ivar token_type: Token Type. :vartype token_type: str - :ivar state: State. Required. - :vartype state: str + :ivar refresh_token: Refresh Token. + :vartype refresh_token: str """ _validation = { "access_token": {"required": True}, "expires_in": {"required": True}, - "state": {"required": True}, } _attribute_map = { "access_token": {"key": "access_token", "type": "str"}, - "refresh_token": {"key": "refresh_token", "type": "str"}, "expires_in": {"key": "expires_in", "type": "int"}, "token_type": {"key": "token_type", "type": "str"}, - "state": {"key": "state", "type": "str"}, + "refresh_token": {"key": "refresh_token", "type": "str"}, } def __init__( @@ -545,29 +706,25 @@ def __init__( *, access_token: str, expires_in: int, - state: str, - refresh_token: Optional[str] = None, token_type: str = "Bearer", + refresh_token: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword access_token: Access Token. Required. :paramtype access_token: str - :keyword refresh_token: Refresh Token. - :paramtype refresh_token: str :keyword expires_in: Expires In. Required. :paramtype expires_in: int :keyword token_type: Token Type. :paramtype token_type: str - :keyword state: State. Required. - :paramtype state: str + :keyword refresh_token: Refresh Token. + :paramtype refresh_token: str """ super().__init__(**kwargs) self.access_token = access_token - self.refresh_token = refresh_token self.expires_in = expires_in self.token_type = token_type - self.state = state + self.refresh_token = refresh_token class ValidationError(_serialization.Model): diff --git a/src/diracx/client/operations/_operations.py b/src/diracx/client/operations/_operations.py index df90e397e..522482500 100644 --- a/src/diracx/client/operations/_operations.py +++ b/src/diracx/client/operations/_operations.py @@ -309,102 +309,127 @@ def build_jobs_delete_bulk_jobs_request( ) -def build_jobs_get_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_kill_bulk_jobs_request( + *, job_ids: List[int], **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/{job_id}" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } + _url = "/jobs/kill" - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + # Construct parameters + _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest( + method="POST", url=_url, params=_params, headers=_headers, **kwargs + ) -def build_jobs_delete_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_get_job_status_bulk_request( + *, job_ids: List[int], **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/{job_id}" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } + _url = "/jobs/status" - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + # Construct parameters + _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) -def build_jobs_kill_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_set_job_status_bulk_request( + *, force: bool = False, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/{job_id}/kill" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } + _url = "/jobs/status" - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + # Construct parameters + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest( + method="PUT", url=_url, params=_params, headers=_headers, **kwargs + ) -def build_jobs_get_single_job_status_request(job_id: int, **kwargs: Any) -> HttpRequest: +def build_jobs_get_job_status_history_bulk_request( # pylint: disable=name-too-long + *, job_ids: List[int], **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/{job_id}/status" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } + _url = "/jobs/status/history" - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + # Construct parameters + _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) -def build_jobs_set_single_job_status_request( - job_id: int, *, status: Union[str, _models.JobStatus], **kwargs: Any +def build_jobs_search_request( + *, page: int = 0, per_page: int = 100, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/{job_id}/status" - path_format_arguments = { - "job_id": _SERIALIZER.url("job_id", job_id, "int"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url = "/jobs/search" # Construct parameters - _params["status"] = _SERIALIZER.query("status", status, "str") + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( @@ -412,73 +437,67 @@ def build_jobs_set_single_job_status_request( ) -def build_jobs_kill_bulk_jobs_request( - *, job_ids: List[int], **kwargs: Any -) -> HttpRequest: +def build_jobs_summary_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/kill" - - # Construct parameters - _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") + _url = "/jobs/summary" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs - ) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_jobs_get_bulk_job_status_request( - *, job_ids: List[int], **kwargs: Any -) -> HttpRequest: +def build_jobs_get_single_job_request(job_id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/status" + _url = "/jobs/{job_id}" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } - # Construct parameters - _params["job_ids"] = _SERIALIZER.query("job_ids", job_ids, "[int]") + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", url=_url, params=_params, headers=_headers, **kwargs - ) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_jobs_set_status_bulk_request(**kwargs: Any) -> HttpRequest: +def build_jobs_get_single_job_status_request(job_id: int, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/status" + _url = "/jobs/{job_id}/status" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_jobs_search_request( - *, page: int = 0, per_page: int = 100, **kwargs: Any +def build_jobs_set_single_job_status_request( + job_id: int, *, force: bool = False, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -489,13 +508,16 @@ def build_jobs_search_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/search" + _url = "/jobs/{job_id}/status" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - if page is not None: - _params["page"] = _SERIALIZER.query("page", page, "int") - if per_page is not None: - _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") # Construct headers if content_type is not None: @@ -505,29 +527,29 @@ def build_jobs_search_request( _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest( - method="POST", url=_url, params=_params, headers=_headers, **kwargs + method="PUT", url=_url, params=_params, headers=_headers, **kwargs ) -def build_jobs_summary_request(**kwargs: Any) -> HttpRequest: +def build_jobs_get_single_job_status_history_request( # pylint: disable=name-too-long + job_id: int, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/jobs/summary" + _url = "/jobs/{job_id}/status/history" + path_format_arguments = { + "job_id": _SERIALIZER.url("job_id", job_id, "int"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header( - "content_type", content_type, "str" - ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) class WellKnownOperations: @@ -1400,13 +1422,13 @@ def delete_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized @distributed_trace - def get_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Get Single Job. + def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: + """Kill Bulk Jobs. - Get Single Job. + Kill Bulk Jobs. - :param job_id: Required. - :type job_id: int + :keyword job_ids: Required. + :paramtype job_ids: list[int] :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -1424,8 +1446,8 @@ def get_single_job(self, job_id: int, **kwargs: Any) -> Any: cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_get_single_job_request( - job_id=job_id, + request = build_jobs_kill_bulk_jobs_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -1454,15 +1476,17 @@ def get_single_job(self, job_id: int, **kwargs: Any) -> Any: return deserialized @distributed_trace - def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Delete Single Job. + def get_job_status_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Job Status Bulk. - Delete Single Job. + Get Job Status Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1476,10 +1500,12 @@ def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None + ) - request = build_jobs_delete_single_job_request( - job_id=job_id, + request = build_jobs_get_job_status_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -1500,23 +1526,84 @@ def delete_single_job(self, job_id: int, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + def set_job_status_bulk( + self, + body: Dict[str, Dict[str, _models.JobStatusUpdate]], + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. + + Set Job Status Bulk. + + :param body: Required. + :type body: dict[str, dict[str, ~client.models.JobStatusUpdate]] + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_job_status_bulk( + self, + body: IO, + *, + force: bool = False, + content_type: str = "application/json", + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. + + Set Job Status Bulk. + + :param body: Required. + :type body: IO + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: - """Kill Single Job. + def set_job_status_bulk( + self, + body: Union[Dict[str, Dict[str, _models.JobStatusUpdate]], IO], + *, + force: bool = False, + **kwargs: Any, + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Job Status Bulk. - Kill Single Job. + Set Job Status Bulk. - :param job_id: Required. - :type job_id: int - :return: any - :rtype: any + :param body: Is either a {str: {str: JobStatusUpdate}} type or a IO type. Required. + :type body: dict[str, dict[str, ~client.models.JobStatusUpdate]] or IO + :keyword force: Default value is False. + :paramtype force: bool + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1527,13 +1614,27 @@ def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) - request = build_jobs_kill_single_job_request( - job_id=job_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "{{JobStatusUpdate}}") + + request = build_jobs_set_job_status_bulk_request( + force=force, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1554,7 +1655,7 @@ def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1562,17 +1663,17 @@ def kill_single_job(self, job_id: int, **kwargs: Any) -> Any: return deserialized @distributed_trace - def get_single_job_status( - self, job_id: int, **kwargs: Any - ) -> Union[str, _models.JobStatus]: - """Get Single Job Status. + def get_job_status_history_bulk( + self, *, job_ids: List[int], **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Job Status History Bulk. - Get Single Job Status. + Get Job Status History Bulk. - :param job_id: Required. - :type job_id: int - :return: JobStatus - :rtype: str or ~client.models.JobStatus + :keyword job_ids: Required. + :paramtype job_ids: list[int] + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1586,10 +1687,10 @@ def get_single_job_status( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Union[str, _models.JobStatus]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - request = build_jobs_get_single_job_status_request( - job_id=job_id, + request = build_jobs_get_job_status_history_bulk_request( + job_ids=job_ids, headers=_headers, params=_params, ) @@ -1610,28 +1711,99 @@ def get_single_job_status( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + def search( + self, + body: Optional[_models.JobSearchParams] = None, + *, + page: int = 0, + per_page: int = 100, + content_type: str = "application/json", + **kwargs: Any, + ) -> List[JSON]: + """Search. + + Retrieve information about jobs. + + **TODO: Add more docs**. + + :param body: Default value is None. + :type body: ~client.models.JobSearchParams + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def search( + self, + body: Optional[IO] = None, + *, + page: int = 0, + per_page: int = 100, + content_type: str = "application/json", + **kwargs: Any, + ) -> List[JSON]: + """Search. + + Retrieve information about jobs. + + **TODO: Add more docs**. + + :param body: Default value is None. + :type body: IO + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def set_single_job_status( - self, job_id: int, *, status: Union[str, _models.JobStatus], **kwargs: Any - ) -> Any: - """Set Single Job Status. + def search( + self, + body: Optional[Union[_models.JobSearchParams, IO]] = None, + *, + page: int = 0, + per_page: int = 100, + **kwargs: Any, + ) -> List[JSON]: + """Search. - Set Single Job Status. + Retrieve information about jobs. - :param job_id: Required. - :type job_id: int - :keyword status: Known values are: "Running", "Stalled", "Killed", "Failed", "RECEIVED", and - "Submitting". Required. - :paramtype status: str or ~client.models.JobStatus - :return: any - :rtype: any + **TODO: Add more docs**. + + :param body: Is either a JobSearchParams type or a IO type. Default value is None. + :type body: ~client.models.JobSearchParams or IO + :keyword page: Default value is 0. + :paramtype page: int + :keyword per_page: Default value is 100. + :paramtype per_page: int + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: list of JSON + :rtype: list[JSON] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1642,14 +1814,31 @@ def set_single_job_status( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[List[JSON]] = kwargs.pop("cls", None) - request = build_jobs_set_single_job_status_request( - job_id=job_id, - status=status, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "JobSearchParams") + else: + _json = None + + request = build_jobs_search_request( + page=page, + per_page=per_page, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1670,21 +1859,64 @@ def set_single_job_status( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("[object]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + @overload + def summary( + self, + body: _models.JobSummaryParams, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Any: + """Summary. + + Show information suitable for plotting. + + :param body: Required. + :type body: ~client.models.JobSummaryParams + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def summary( + self, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> Any: + """Summary. + + Show information suitable for plotting. + + :param body: Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: any + :rtype: any + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Kill Bulk Jobs. + def summary(self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any) -> Any: + """Summary. - Kill Bulk Jobs. + Show information suitable for plotting. - :keyword job_ids: Required. - :paramtype job_ids: list[int] + :param body: Is either a JobSummaryParams type or a IO type. Required. + :type body: ~client.models.JobSummaryParams or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -1697,13 +1929,26 @@ def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_kill_bulk_jobs_request( - job_ids=job_ids, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "JobSummaryParams") + + request = build_jobs_summary_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1732,13 +1977,13 @@ def kill_bulk_jobs(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized @distributed_trace - def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any: - """Get Bulk Job Status. + def get_single_job(self, job_id: int, **kwargs: Any) -> Any: + """Get Single Job. - Get Bulk Job Status. + Get Single Job. - :keyword job_ids: Required. - :paramtype job_ids: list[int] + :param job_id: Required. + :type job_id: int :return: any :rtype: any :raises ~azure.core.exceptions.HttpResponseError: @@ -1756,8 +2001,8 @@ def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any: cls: ClsType[Any] = kwargs.pop("cls", None) - request = build_jobs_get_bulk_job_status_request( - job_ids=job_ids, + request = build_jobs_get_single_job_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1785,61 +2030,18 @@ def get_bulk_job_status(self, *, job_ids: List[int], **kwargs: Any) -> Any: return deserialized - @overload - def set_status_bulk( - self, - body: List[_models.JobStatusUpdate], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. - - Set Status Bulk. - - :param body: Required. - :type body: list[~client.models.JobStatusUpdate] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def set_status_bulk( - self, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. - - Set Status Bulk. - - :param body: Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def set_status_bulk( - self, body: Union[List[_models.JobStatusUpdate], IO], **kwargs: Any - ) -> List[_models.JobStatusReturn]: - """Set Status Bulk. + def get_single_job_status( + self, job_id: int, **kwargs: Any + ) -> Dict[str, _models.LimitedJobStatusReturn]: + """Get Single Job Status. - Set Status Bulk. + Get Single Job Status. - :param body: Is either a [JobStatusUpdate] type or a IO type. Required. - :type body: list[~client.models.JobStatusUpdate] or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :return: list of JobStatusReturn - :rtype: list[~client.models.JobStatusReturn] + :param job_id: Required. + :type job_id: int + :return: dict mapping str to LimitedJobStatusReturn + :rtype: dict[str, ~client.models.LimitedJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1850,26 +2052,15 @@ def set_status_bulk( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) + cls: ClsType[Dict[str, _models.LimitedJobStatusReturn]] = kwargs.pop( + "cls", None ) - cls: ClsType[List[_models.JobStatusReturn]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "[JobStatusUpdate]") - - request = build_jobs_set_status_bulk_request( - content_type=content_type, - json=_json, - content=_content, + request = build_jobs_get_single_job_status_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -1890,7 +2081,7 @@ def set_status_bulk( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[JobStatusReturn]", pipeline_response) + deserialized = self._deserialize("{LimitedJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1898,91 +2089,85 @@ def set_status_bulk( return deserialized @overload - def search( + def set_single_job_status( self, - body: Optional[_models.JobSearchParams] = None, + job_id: int, + body: Dict[str, _models.JobStatusUpdate], *, - page: int = 0, - per_page: int = 100, + force: bool = False, content_type: str = "application/json", **kwargs: Any, - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Default value is None. - :type body: ~client.models.JobSearchParams - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :param job_id: Required. + :type job_id: int + :param body: Required. + :type body: dict[str, ~client.models.JobStatusUpdate] + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def search( + def set_single_job_status( self, - body: Optional[IO] = None, + job_id: int, + body: IO, *, - page: int = 0, - per_page: int = 100, + force: bool = False, content_type: str = "application/json", **kwargs: Any, - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Default value is None. + :param job_id: Required. + :type job_id: int + :param body: Required. :type body: IO - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def search( + def set_single_job_status( self, - body: Optional[Union[_models.JobSearchParams, IO]] = None, + job_id: int, + body: Union[Dict[str, _models.JobStatusUpdate], IO], *, - page: int = 0, - per_page: int = 100, + force: bool = False, **kwargs: Any, - ) -> List[JSON]: - """Search. - - Retrieve information about jobs. + ) -> Dict[str, _models.SetJobStatusReturn]: + """Set Single Job Status. - **TODO: Add more docs**. + Set Single Job Status. - :param body: Is either a JobSearchParams type or a IO type. Default value is None. - :type body: ~client.models.JobSearchParams or IO - :keyword page: Default value is 0. - :paramtype page: int - :keyword per_page: Default value is 100. - :paramtype per_page: int + :param job_id: Required. + :type job_id: int + :param body: Is either a {str: JobStatusUpdate} type or a IO type. Required. + :type body: dict[str, ~client.models.JobStatusUpdate] or IO + :keyword force: Default value is False. + :paramtype force: bool :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str - :return: list of JSON - :rtype: list[JSON] + :return: dict mapping str to SetJobStatusReturn + :rtype: dict[str, ~client.models.SetJobStatusReturn] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1999,7 +2184,7 @@ def search( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[List[JSON]] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, _models.SetJobStatusReturn]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2007,14 +2192,11 @@ def search( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "JobSearchParams") - else: - _json = None + _json = self._serialize.body(body, "{JobStatusUpdate}") - request = build_jobs_search_request( - page=page, - per_page=per_page, + request = build_jobs_set_single_job_status_request( + job_id=job_id, + force=force, content_type=content_type, json=_json, content=_content, @@ -2038,66 +2220,25 @@ def search( ) raise HttpResponseError(response=response) - deserialized = self._deserialize("[object]", pipeline_response) + deserialized = self._deserialize("{SetJobStatusReturn}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - @overload - def summary( - self, - body: _models.JobSummaryParams, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> Any: - """Summary. - - Show information suitable for plotting. - - :param body: Required. - :type body: ~client.models.JobSummaryParams - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def summary( - self, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> Any: - """Summary. - - Show information suitable for plotting. - - :param body: Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: any - :rtype: any - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def summary(self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any) -> Any: - """Summary. + def get_single_job_status_history( + self, job_id: int, **kwargs: Any + ) -> Dict[str, List[_models.JobStatusReturn]]: + """Get Single Job Status History. - Show information suitable for plotting. + Get Single Job Status History. - :param body: Is either a JobSummaryParams type or a IO type. Required. - :type body: ~client.models.JobSummaryParams or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :return: any - :rtype: any + :param job_id: Required. + :type job_id: int + :return: dict mapping str to list of JobStatusReturn + :rtype: dict[str, list[~client.models.JobStatusReturn]] :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -2108,26 +2249,13 @@ def summary(self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any) -> A } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[Any] = kwargs.pop("cls", None) + cls: ClsType[Dict[str, List[_models.JobStatusReturn]]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = self._serialize.body(body, "JobSummaryParams") - - request = build_jobs_summary_request( - content_type=content_type, - json=_json, - content=_content, + request = build_jobs_get_single_job_status_history_request( + job_id=job_id, headers=_headers, params=_params, ) @@ -2148,7 +2276,7 @@ def summary(self, body: Union[_models.JobSummaryParams, IO], **kwargs: Any) -> A ) raise HttpResponseError(response=response) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("{[JobStatusReturn]}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) diff --git a/src/diracx/core/models.py b/src/diracx/core/models.py index 9808f320a..9171dc4f2 100644 --- a/src/diracx/core/models.py +++ b/src/diracx/core/models.py @@ -44,10 +44,9 @@ class VectorSearchSpec(TypedDict): class TokenResponse(BaseModel): # Based on RFC 6749 access_token: str - refresh_token: str | None expires_in: int token_type: str = "Bearer" - state: str + refresh_token: str | None class JobStatus(str, Enum): @@ -76,12 +75,10 @@ class JobStatusUpdate(BaseModel): minor_status: str | None = Field( default=None, alias="MinorStatus", - serialization_alias="minorStatus", ) application_status: str | None = Field( default=None, alias="ApplicationStatus", - serialization_alias="applicationStatus", ) status_source: str = Field( alias="StatusSource", diff --git a/src/diracx/core/utils.py b/src/diracx/core/utils.py index 69ccca6a7..cbb291343 100644 --- a/src/diracx/core/utils.py +++ b/src/diracx/core/utils.py @@ -31,4 +31,6 @@ def write_credentials(token_response: TokenResponse): "refresh_token": token_response.refresh_token, "expires_on": int(datetime.timestamp(expires)), } - get_diracx_preferences().credentials_path.write_text(json.dumps(credential_data)) + credentials_path = get_diracx_preferences().credentials_path + credentials_path.parent.mkdir(parents=True, exist_ok=True) + credentials_path.write_text(json.dumps(credential_data)) diff --git a/src/diracx/routers/auth.py b/src/diracx/routers/auth.py index 06ca6d774..2ae549795 100644 --- a/src/diracx/routers/auth.py +++ b/src/diracx/routers/auth.py @@ -313,9 +313,8 @@ async def exchange_token( return TokenResponse( access_token=access_token, - refresh_token=refresh_token, expires_in=settings.access_token_expire_minutes * 60, - state="None", + refresh_token=refresh_token, ) diff --git a/tests/db/jobs/test_jobLoggingDB.py b/tests/db/jobs/test_jobLoggingDB.py index 482babd1a..1949cde15 100644 --- a/tests/db/jobs/test_jobLoggingDB.py +++ b/tests/db/jobs/test_jobLoggingDB.py @@ -2,8 +2,8 @@ import pytest -from diracx.db.sql import JobLoggingDB from diracx.core.models import JobStatus +from diracx.db.sql import JobLoggingDB @pytest.fixture