Skip to content

Commit b71aeec

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 76ebeff commit b71aeec

File tree

22 files changed

+1574
-11
lines changed

22 files changed

+1574
-11
lines changed

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_openid_configuration_request,
5860
)
@@ -2342,3 +2344,264 @@ async def submit_jdl_jobs(
23422344
return cls(pipeline_response, deserialized, {}) # type: ignore
23432345

23442346
return deserialized # type: ignore
2347+
2348+
2349+
class PilotOperations:
2350+
"""
2351+
.. warning::
2352+
**DO NOT** instantiate this class directly.
2353+
2354+
Instead, you should access the following operations through
2355+
:class:`~_generated.aio.Dirac`'s
2356+
:attr:`pilot` attribute.
2357+
"""
2358+
2359+
models = _models
2360+
2361+
def __init__(self, *args, **kwargs) -> None:
2362+
input_args = list(args)
2363+
self._client: AsyncPipelineClient = (
2364+
input_args.pop(0) if input_args else kwargs.pop("client")
2365+
)
2366+
self._config: DiracConfiguration = (
2367+
input_args.pop(0) if input_args else kwargs.pop("config")
2368+
)
2369+
self._serialize: Serializer = (
2370+
input_args.pop(0) if input_args else kwargs.pop("serializer")
2371+
)
2372+
self._deserialize: Deserializer = (
2373+
input_args.pop(0) if input_args else kwargs.pop("deserializer")
2374+
)
2375+
2376+
@overload
2377+
async def set_job_statuses(
2378+
self,
2379+
body: Dict[str, Dict[str, _models.JobStatusUpdate]],
2380+
*,
2381+
force: bool = False,
2382+
content_type: str = "application/json",
2383+
**kwargs: Any,
2384+
) -> _models.SetJobStatusReturn:
2385+
"""Set Job Statuses.
2386+
2387+
Set Job Statuses.
2388+
2389+
:param body: Required.
2390+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]]
2391+
:keyword force: Default value is False.
2392+
:paramtype force: bool
2393+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2394+
Default value is "application/json".
2395+
:paramtype content_type: str
2396+
:return: SetJobStatusReturn
2397+
:rtype: ~_generated.models.SetJobStatusReturn
2398+
:raises ~azure.core.exceptions.HttpResponseError:
2399+
"""
2400+
2401+
@overload
2402+
async def set_job_statuses(
2403+
self,
2404+
body: IO[bytes],
2405+
*,
2406+
force: bool = False,
2407+
content_type: str = "application/json",
2408+
**kwargs: Any,
2409+
) -> _models.SetJobStatusReturn:
2410+
"""Set Job Statuses.
2411+
2412+
Set Job Statuses.
2413+
2414+
:param body: Required.
2415+
:type body: IO[bytes]
2416+
:keyword force: Default value is False.
2417+
:paramtype force: bool
2418+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2419+
Default value is "application/json".
2420+
:paramtype content_type: str
2421+
:return: SetJobStatusReturn
2422+
:rtype: ~_generated.models.SetJobStatusReturn
2423+
:raises ~azure.core.exceptions.HttpResponseError:
2424+
"""
2425+
2426+
@distributed_trace_async
2427+
async def set_job_statuses(
2428+
self,
2429+
body: Union[Dict[str, Dict[str, _models.JobStatusUpdate]], IO[bytes]],
2430+
*,
2431+
force: bool = False,
2432+
**kwargs: Any,
2433+
) -> _models.SetJobStatusReturn:
2434+
"""Set Job Statuses.
2435+
2436+
Set Job Statuses.
2437+
2438+
:param body: Is either a {str: {str: JobStatusUpdate}} type or a IO[bytes] type. Required.
2439+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]] or IO[bytes]
2440+
:keyword force: Default value is False.
2441+
:paramtype force: bool
2442+
:return: SetJobStatusReturn
2443+
:rtype: ~_generated.models.SetJobStatusReturn
2444+
:raises ~azure.core.exceptions.HttpResponseError:
2445+
"""
2446+
error_map: MutableMapping = {
2447+
401: ClientAuthenticationError,
2448+
404: ResourceNotFoundError,
2449+
409: ResourceExistsError,
2450+
304: ResourceNotModifiedError,
2451+
}
2452+
error_map.update(kwargs.pop("error_map", {}) or {})
2453+
2454+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2455+
_params = kwargs.pop("params", {}) or {}
2456+
2457+
content_type: Optional[str] = kwargs.pop(
2458+
"content_type", _headers.pop("Content-Type", None)
2459+
)
2460+
cls: ClsType[_models.SetJobStatusReturn] = kwargs.pop("cls", None)
2461+
2462+
content_type = content_type or "application/json"
2463+
_json = None
2464+
_content = None
2465+
if isinstance(body, (IOBase, bytes)):
2466+
_content = body
2467+
else:
2468+
_json = self._serialize.body(body, "{{JobStatusUpdate}}")
2469+
2470+
_request = build_pilot_set_job_statuses_request(
2471+
force=force,
2472+
content_type=content_type,
2473+
json=_json,
2474+
content=_content,
2475+
headers=_headers,
2476+
params=_params,
2477+
)
2478+
_request.url = self._client.format_url(_request.url)
2479+
2480+
_stream = False
2481+
pipeline_response: PipelineResponse = (
2482+
await self._client._pipeline.run( # pylint: disable=protected-access
2483+
_request, stream=_stream, **kwargs
2484+
)
2485+
)
2486+
2487+
response = pipeline_response.http_response
2488+
2489+
if response.status_code not in [200]:
2490+
map_error(
2491+
status_code=response.status_code, response=response, error_map=error_map
2492+
)
2493+
raise HttpResponseError(response=response)
2494+
2495+
deserialized = self._deserialize(
2496+
"SetJobStatusReturn", pipeline_response.http_response
2497+
)
2498+
2499+
if cls:
2500+
return cls(pipeline_response, deserialized, {}) # type: ignore
2501+
2502+
return deserialized # type: ignore
2503+
2504+
@overload
2505+
async def patch_metadata(
2506+
self,
2507+
body: Dict[str, Dict[str, Any]],
2508+
*,
2509+
content_type: str = "application/json",
2510+
**kwargs: Any,
2511+
) -> None:
2512+
"""Patch Metadata.
2513+
2514+
Patch Metadata.
2515+
2516+
:param body: Required.
2517+
:type body: dict[str, dict[str, any]]
2518+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2519+
Default value is "application/json".
2520+
:paramtype content_type: str
2521+
:return: None
2522+
:rtype: None
2523+
:raises ~azure.core.exceptions.HttpResponseError:
2524+
"""
2525+
2526+
@overload
2527+
async def patch_metadata(
2528+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
2529+
) -> None:
2530+
"""Patch Metadata.
2531+
2532+
Patch Metadata.
2533+
2534+
:param body: Required.
2535+
:type body: IO[bytes]
2536+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2537+
Default value is "application/json".
2538+
:paramtype content_type: str
2539+
:return: None
2540+
:rtype: None
2541+
:raises ~azure.core.exceptions.HttpResponseError:
2542+
"""
2543+
2544+
@distributed_trace_async
2545+
async def patch_metadata(
2546+
self, body: Union[Dict[str, Dict[str, Any]], IO[bytes]], **kwargs: Any
2547+
) -> None:
2548+
"""Patch Metadata.
2549+
2550+
Patch Metadata.
2551+
2552+
:param body: Is either a {str: {str: Any}} type or a IO[bytes] type. Required.
2553+
:type body: dict[str, dict[str, any]] or IO[bytes]
2554+
:return: None
2555+
:rtype: None
2556+
:raises ~azure.core.exceptions.HttpResponseError:
2557+
"""
2558+
error_map: MutableMapping = {
2559+
401: ClientAuthenticationError,
2560+
404: ResourceNotFoundError,
2561+
409: ResourceExistsError,
2562+
304: ResourceNotModifiedError,
2563+
}
2564+
error_map.update(kwargs.pop("error_map", {}) or {})
2565+
2566+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2567+
_params = kwargs.pop("params", {}) or {}
2568+
2569+
content_type: Optional[str] = kwargs.pop(
2570+
"content_type", _headers.pop("Content-Type", None)
2571+
)
2572+
cls: ClsType[None] = kwargs.pop("cls", None)
2573+
2574+
content_type = content_type or "application/json"
2575+
_json = None
2576+
_content = None
2577+
if isinstance(body, (IOBase, bytes)):
2578+
_content = body
2579+
else:
2580+
_json = self._serialize.body(body, "{{object}}")
2581+
2582+
_request = build_pilot_patch_metadata_request(
2583+
content_type=content_type,
2584+
json=_json,
2585+
content=_content,
2586+
headers=_headers,
2587+
params=_params,
2588+
)
2589+
_request.url = self._client.format_url(_request.url)
2590+
2591+
_stream = False
2592+
pipeline_response: PipelineResponse = (
2593+
await self._client._pipeline.run( # pylint: disable=protected-access
2594+
_request, stream=_stream, **kwargs
2595+
)
2596+
)
2597+
2598+
response = pipeline_response.http_response
2599+
2600+
if response.status_code not in [204]:
2601+
map_error(
2602+
status_code=response.status_code, response=response, error_map=error_map
2603+
)
2604+
raise HttpResponseError(response=response)
2605+
2606+
if cls:
2607+
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)