Skip to content

Commit 5f84fd9

Browse files
feat: Authorized pilots to access jobs endpoints (+7 squashed commits)
Squashed commits: [da5eb05] fix: Fixed client and configuration [0256c34] refactor: Splitting the job section to have only pilots or only users [d00e224] fix: Fixed client (+2 squashed commits) Squashed commits: [855dd32] fix: Fixed client [7701995] fix: Fixed tests: had list instead of set + optimize [93be233] feat: Returning the forbidden jobs in the error [d15825e] test: Adding tests to the WMS access policy, and some fixes [f8bc670] feat: Checking if a pilot has the rights to access a list of jobs [c79aeee] feat: Improving wmsjobpolicy to contain pilots
1 parent 8fd7d1c commit 5f84fd9

22 files changed

Lines changed: 1574 additions & 11 deletions

File tree

diracx-client/src/diracx/client/_generated/_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
AuthOperations,
2020
ConfigOperations,
2121
JobsOperations,
22+
PilotOperations,
2223
WellKnownOperations,
2324
)
2425

@@ -34,6 +35,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3435
:vartype config: _generated.operations.ConfigOperations
3536
:ivar jobs: JobsOperations operations
3637
:vartype jobs: _generated.operations.JobsOperations
38+
:ivar pilot: PilotOperations operations
39+
:vartype pilot: _generated.operations.PilotOperations
3740
:keyword endpoint: Service URL. Required. Default value is "".
3841
:paramtype endpoint: str
3942
"""
@@ -86,6 +89,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
8689
self.jobs = JobsOperations(
8790
self._client, self._config, self._serialize, self._deserialize
8891
)
92+
self.pilot = PilotOperations(
93+
self._client, self._config, self._serialize, self._deserialize
94+
)
8995

9096
def send_request(
9197
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

diracx-client/src/diracx/client/_generated/aio/_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
AuthOperations,
2020
ConfigOperations,
2121
JobsOperations,
22+
PilotOperations,
2223
WellKnownOperations,
2324
)
2425

@@ -34,6 +35,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3435
:vartype config: _generated.aio.operations.ConfigOperations
3536
:ivar jobs: JobsOperations operations
3637
:vartype jobs: _generated.aio.operations.JobsOperations
38+
:ivar pilot: PilotOperations operations
39+
:vartype pilot: _generated.aio.operations.PilotOperations
3740
:keyword endpoint: Service URL. Required. Default value is "".
3841
:paramtype endpoint: str
3942
"""
@@ -86,6 +89,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
8689
self.jobs = JobsOperations(
8790
self._client, self._config, self._serialize, self._deserialize
8891
)
92+
self.pilot = PilotOperations(
93+
self._client, self._config, self._serialize, self._deserialize
94+
)
8995

9096
def send_request(
9197
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

diracx-client/src/diracx/client/_generated/aio/operations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ._operations import AuthOperations # type: ignore
1515
from ._operations import ConfigOperations # type: ignore
1616
from ._operations import JobsOperations # type: ignore
17+
from ._operations import PilotOperations # type: ignore
1718

1819
from ._patch import __all__ as _patch_all
1920
from ._patch import *
@@ -24,6 +25,7 @@
2425
"AuthOperations",
2526
"ConfigOperations",
2627
"JobsOperations",
28+
"PilotOperations",
2729
]
2830
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2931
_patch_sdk()

diracx-client/src/diracx/client/_generated/aio/operations/_operations.py

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
build_jobs_summary_request,
5454
build_jobs_unassign_bulk_jobs_sandboxes_request,
5555
build_jobs_unassign_job_sandboxes_request,
56+
build_pilot_patch_metadata_request,
57+
build_pilot_set_job_statuses_request,
5658
build_well_known_get_installation_metadata_request,
5759
build_well_known_get_jwks_request,
5860
build_well_known_get_openid_configuration_request,
@@ -2394,3 +2396,264 @@ async def submit_jdl_jobs(
23942396
return cls(pipeline_response, deserialized, {}) # type: ignore
23952397

23962398
return deserialized # type: ignore
2399+
2400+
2401+
class PilotOperations:
2402+
"""
2403+
.. warning::
2404+
**DO NOT** instantiate this class directly.
2405+
2406+
Instead, you should access the following operations through
2407+
:class:`~_generated.aio.Dirac`'s
2408+
:attr:`pilot` attribute.
2409+
"""
2410+
2411+
models = _models
2412+
2413+
def __init__(self, *args, **kwargs) -> None:
2414+
input_args = list(args)
2415+
self._client: AsyncPipelineClient = (
2416+
input_args.pop(0) if input_args else kwargs.pop("client")
2417+
)
2418+
self._config: DiracConfiguration = (
2419+
input_args.pop(0) if input_args else kwargs.pop("config")
2420+
)
2421+
self._serialize: Serializer = (
2422+
input_args.pop(0) if input_args else kwargs.pop("serializer")
2423+
)
2424+
self._deserialize: Deserializer = (
2425+
input_args.pop(0) if input_args else kwargs.pop("deserializer")
2426+
)
2427+
2428+
@overload
2429+
async def set_job_statuses(
2430+
self,
2431+
body: Dict[str, Dict[str, _models.JobStatusUpdate]],
2432+
*,
2433+
force: bool = False,
2434+
content_type: str = "application/json",
2435+
**kwargs: Any,
2436+
) -> _models.SetJobStatusReturn:
2437+
"""Set Job Statuses.
2438+
2439+
Set Job Statuses.
2440+
2441+
:param body: Required.
2442+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]]
2443+
:keyword force: Default value is False.
2444+
:paramtype force: bool
2445+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2446+
Default value is "application/json".
2447+
:paramtype content_type: str
2448+
:return: SetJobStatusReturn
2449+
:rtype: ~_generated.models.SetJobStatusReturn
2450+
:raises ~azure.core.exceptions.HttpResponseError:
2451+
"""
2452+
2453+
@overload
2454+
async def set_job_statuses(
2455+
self,
2456+
body: IO[bytes],
2457+
*,
2458+
force: bool = False,
2459+
content_type: str = "application/json",
2460+
**kwargs: Any,
2461+
) -> _models.SetJobStatusReturn:
2462+
"""Set Job Statuses.
2463+
2464+
Set Job Statuses.
2465+
2466+
:param body: Required.
2467+
:type body: IO[bytes]
2468+
:keyword force: Default value is False.
2469+
:paramtype force: bool
2470+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2471+
Default value is "application/json".
2472+
:paramtype content_type: str
2473+
:return: SetJobStatusReturn
2474+
:rtype: ~_generated.models.SetJobStatusReturn
2475+
:raises ~azure.core.exceptions.HttpResponseError:
2476+
"""
2477+
2478+
@distributed_trace_async
2479+
async def set_job_statuses(
2480+
self,
2481+
body: Union[Dict[str, Dict[str, _models.JobStatusUpdate]], IO[bytes]],
2482+
*,
2483+
force: bool = False,
2484+
**kwargs: Any,
2485+
) -> _models.SetJobStatusReturn:
2486+
"""Set Job Statuses.
2487+
2488+
Set Job Statuses.
2489+
2490+
:param body: Is either a {str: {str: JobStatusUpdate}} type or a IO[bytes] type. Required.
2491+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]] or IO[bytes]
2492+
:keyword force: Default value is False.
2493+
:paramtype force: bool
2494+
:return: SetJobStatusReturn
2495+
:rtype: ~_generated.models.SetJobStatusReturn
2496+
:raises ~azure.core.exceptions.HttpResponseError:
2497+
"""
2498+
error_map: MutableMapping = {
2499+
401: ClientAuthenticationError,
2500+
404: ResourceNotFoundError,
2501+
409: ResourceExistsError,
2502+
304: ResourceNotModifiedError,
2503+
}
2504+
error_map.update(kwargs.pop("error_map", {}) or {})
2505+
2506+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2507+
_params = kwargs.pop("params", {}) or {}
2508+
2509+
content_type: Optional[str] = kwargs.pop(
2510+
"content_type", _headers.pop("Content-Type", None)
2511+
)
2512+
cls: ClsType[_models.SetJobStatusReturn] = kwargs.pop("cls", None)
2513+
2514+
content_type = content_type or "application/json"
2515+
_json = None
2516+
_content = None
2517+
if isinstance(body, (IOBase, bytes)):
2518+
_content = body
2519+
else:
2520+
_json = self._serialize.body(body, "{{JobStatusUpdate}}")
2521+
2522+
_request = build_pilot_set_job_statuses_request(
2523+
force=force,
2524+
content_type=content_type,
2525+
json=_json,
2526+
content=_content,
2527+
headers=_headers,
2528+
params=_params,
2529+
)
2530+
_request.url = self._client.format_url(_request.url)
2531+
2532+
_stream = False
2533+
pipeline_response: PipelineResponse = (
2534+
await self._client._pipeline.run( # pylint: disable=protected-access
2535+
_request, stream=_stream, **kwargs
2536+
)
2537+
)
2538+
2539+
response = pipeline_response.http_response
2540+
2541+
if response.status_code not in [200]:
2542+
map_error(
2543+
status_code=response.status_code, response=response, error_map=error_map
2544+
)
2545+
raise HttpResponseError(response=response)
2546+
2547+
deserialized = self._deserialize(
2548+
"SetJobStatusReturn", pipeline_response.http_response
2549+
)
2550+
2551+
if cls:
2552+
return cls(pipeline_response, deserialized, {}) # type: ignore
2553+
2554+
return deserialized # type: ignore
2555+
2556+
@overload
2557+
async def patch_metadata(
2558+
self,
2559+
body: Dict[str, Dict[str, Any]],
2560+
*,
2561+
content_type: str = "application/json",
2562+
**kwargs: Any,
2563+
) -> None:
2564+
"""Patch Metadata.
2565+
2566+
Patch Metadata.
2567+
2568+
:param body: Required.
2569+
:type body: dict[str, dict[str, any]]
2570+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2571+
Default value is "application/json".
2572+
:paramtype content_type: str
2573+
:return: None
2574+
:rtype: None
2575+
:raises ~azure.core.exceptions.HttpResponseError:
2576+
"""
2577+
2578+
@overload
2579+
async def patch_metadata(
2580+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
2581+
) -> None:
2582+
"""Patch Metadata.
2583+
2584+
Patch Metadata.
2585+
2586+
:param body: Required.
2587+
:type body: IO[bytes]
2588+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2589+
Default value is "application/json".
2590+
:paramtype content_type: str
2591+
:return: None
2592+
:rtype: None
2593+
:raises ~azure.core.exceptions.HttpResponseError:
2594+
"""
2595+
2596+
@distributed_trace_async
2597+
async def patch_metadata(
2598+
self, body: Union[Dict[str, Dict[str, Any]], IO[bytes]], **kwargs: Any
2599+
) -> None:
2600+
"""Patch Metadata.
2601+
2602+
Patch Metadata.
2603+
2604+
:param body: Is either a {str: {str: Any}} type or a IO[bytes] type. Required.
2605+
:type body: dict[str, dict[str, any]] or IO[bytes]
2606+
:return: None
2607+
:rtype: None
2608+
:raises ~azure.core.exceptions.HttpResponseError:
2609+
"""
2610+
error_map: MutableMapping = {
2611+
401: ClientAuthenticationError,
2612+
404: ResourceNotFoundError,
2613+
409: ResourceExistsError,
2614+
304: ResourceNotModifiedError,
2615+
}
2616+
error_map.update(kwargs.pop("error_map", {}) or {})
2617+
2618+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2619+
_params = kwargs.pop("params", {}) or {}
2620+
2621+
content_type: Optional[str] = kwargs.pop(
2622+
"content_type", _headers.pop("Content-Type", None)
2623+
)
2624+
cls: ClsType[None] = kwargs.pop("cls", None)
2625+
2626+
content_type = content_type or "application/json"
2627+
_json = None
2628+
_content = None
2629+
if isinstance(body, (IOBase, bytes)):
2630+
_content = body
2631+
else:
2632+
_json = self._serialize.body(body, "{{object}}")
2633+
2634+
_request = build_pilot_patch_metadata_request(
2635+
content_type=content_type,
2636+
json=_json,
2637+
content=_content,
2638+
headers=_headers,
2639+
params=_params,
2640+
)
2641+
_request.url = self._client.format_url(_request.url)
2642+
2643+
_stream = False
2644+
pipeline_response: PipelineResponse = (
2645+
await self._client._pipeline.run( # pylint: disable=protected-access
2646+
_request, stream=_stream, **kwargs
2647+
)
2648+
)
2649+
2650+
response = pipeline_response.http_response
2651+
2652+
if response.status_code not in [204]:
2653+
map_error(
2654+
status_code=response.status_code, response=response, error_map=error_map
2655+
)
2656+
raise HttpResponseError(response=response)
2657+
2658+
if cls:
2659+
return cls(pipeline_response, None, {}) # type: ignore

diracx-client/src/diracx/client/_generated/operations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ._operations import AuthOperations # type: ignore
1515
from ._operations import ConfigOperations # type: ignore
1616
from ._operations import JobsOperations # type: ignore
17+
from ._operations import PilotOperations # type: ignore
1718

1819
from ._patch import __all__ as _patch_all
1920
from ._patch import *
@@ -24,6 +25,7 @@
2425
"AuthOperations",
2526
"ConfigOperations",
2627
"JobsOperations",
28+
"PilotOperations",
2729
]
2830
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2931
_patch_sdk()

0 commit comments

Comments
 (0)