Skip to content

Commit 9af20b4

Browse files
feat: Support diracx pilots for jobs
1 parent d5f4676 commit 9af20b4

File tree

11 files changed

+1861
-2
lines changed

11 files changed

+1861
-2
lines changed

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

Lines changed: 383 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858
build_pilots_clear_pilots_request,
5959
build_pilots_create_pilot_secrets_request,
6060
build_pilots_delete_pilots_request,
61+
build_pilots_pilot_add_heartbeat_request,
6162
build_pilots_pilot_login_request,
63+
build_pilots_pilot_patch_metadata_request,
64+
build_pilots_pilot_set_job_statuses_request,
6265
build_pilots_refresh_pilot_tokens_request,
6366
build_pilots_search_request,
6467
build_pilots_update_pilot_fields_request,
@@ -3176,3 +3179,383 @@ async def refresh_pilot_tokens(
31763179
return cls(pipeline_response, deserialized, {}) # type: ignore
31773180

31783181
return deserialized # type: ignore
3182+
3183+
@overload
3184+
async def pilot_set_job_statuses(
3185+
self,
3186+
body: Dict[str, Dict[str, _models.JobStatusUpdate]],
3187+
*,
3188+
force: bool = False,
3189+
authorization: Optional[str] = None,
3190+
content_type: str = "application/json",
3191+
**kwargs: Any
3192+
) -> _models.SetJobStatusReturn:
3193+
"""Pilot Set Job Statuses.
3194+
3195+
Pilot Set Job Statuses.
3196+
3197+
:param body: Required.
3198+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]]
3199+
:keyword force: Default value is False.
3200+
:paramtype force: bool
3201+
:keyword authorization: Default value is None.
3202+
:paramtype authorization: str
3203+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
3204+
Default value is "application/json".
3205+
:paramtype content_type: str
3206+
:return: SetJobStatusReturn
3207+
:rtype: ~_generated.models.SetJobStatusReturn
3208+
:raises ~azure.core.exceptions.HttpResponseError:
3209+
"""
3210+
3211+
@overload
3212+
async def pilot_set_job_statuses(
3213+
self,
3214+
body: IO[bytes],
3215+
*,
3216+
force: bool = False,
3217+
authorization: Optional[str] = None,
3218+
content_type: str = "application/json",
3219+
**kwargs: Any
3220+
) -> _models.SetJobStatusReturn:
3221+
"""Pilot Set Job Statuses.
3222+
3223+
Pilot Set Job Statuses.
3224+
3225+
:param body: Required.
3226+
:type body: IO[bytes]
3227+
:keyword force: Default value is False.
3228+
:paramtype force: bool
3229+
:keyword authorization: Default value is None.
3230+
:paramtype authorization: str
3231+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
3232+
Default value is "application/json".
3233+
:paramtype content_type: str
3234+
:return: SetJobStatusReturn
3235+
:rtype: ~_generated.models.SetJobStatusReturn
3236+
:raises ~azure.core.exceptions.HttpResponseError:
3237+
"""
3238+
3239+
@distributed_trace_async
3240+
async def pilot_set_job_statuses(
3241+
self,
3242+
body: Union[Dict[str, Dict[str, _models.JobStatusUpdate]], IO[bytes]],
3243+
*,
3244+
force: bool = False,
3245+
authorization: Optional[str] = None,
3246+
**kwargs: Any
3247+
) -> _models.SetJobStatusReturn:
3248+
"""Pilot Set Job Statuses.
3249+
3250+
Pilot Set Job Statuses.
3251+
3252+
:param body: Is either a {str: {str: JobStatusUpdate}} type or a IO[bytes] type. Required.
3253+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]] or IO[bytes]
3254+
:keyword force: Default value is False.
3255+
:paramtype force: bool
3256+
:keyword authorization: Default value is None.
3257+
:paramtype authorization: str
3258+
:return: SetJobStatusReturn
3259+
:rtype: ~_generated.models.SetJobStatusReturn
3260+
:raises ~azure.core.exceptions.HttpResponseError:
3261+
"""
3262+
error_map: MutableMapping = {
3263+
401: ClientAuthenticationError,
3264+
404: ResourceNotFoundError,
3265+
409: ResourceExistsError,
3266+
304: ResourceNotModifiedError,
3267+
}
3268+
error_map.update(kwargs.pop("error_map", {}) or {})
3269+
3270+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
3271+
_params = kwargs.pop("params", {}) or {}
3272+
3273+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
3274+
cls: ClsType[_models.SetJobStatusReturn] = kwargs.pop("cls", None)
3275+
3276+
content_type = content_type or "application/json"
3277+
_json = None
3278+
_content = None
3279+
if isinstance(body, (IOBase, bytes)):
3280+
_content = body
3281+
else:
3282+
_json = self._serialize.body(body, "{{JobStatusUpdate}}")
3283+
3284+
_request = build_pilots_pilot_set_job_statuses_request(
3285+
force=force,
3286+
authorization=authorization,
3287+
content_type=content_type,
3288+
json=_json,
3289+
content=_content,
3290+
headers=_headers,
3291+
params=_params,
3292+
)
3293+
_request.url = self._client.format_url(_request.url)
3294+
3295+
_stream = False
3296+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
3297+
_request, stream=_stream, **kwargs
3298+
)
3299+
3300+
response = pipeline_response.http_response
3301+
3302+
if response.status_code not in [200]:
3303+
map_error(status_code=response.status_code, response=response, error_map=error_map)
3304+
raise HttpResponseError(response=response)
3305+
3306+
deserialized = self._deserialize("SetJobStatusReturn", pipeline_response.http_response)
3307+
3308+
if cls:
3309+
return cls(pipeline_response, deserialized, {}) # type: ignore
3310+
3311+
return deserialized # type: ignore
3312+
3313+
@overload
3314+
async def pilot_add_heartbeat(
3315+
self,
3316+
body: Dict[str, _models.HeartbeatData],
3317+
*,
3318+
authorization: Optional[str] = None,
3319+
content_type: str = "application/json",
3320+
**kwargs: Any
3321+
) -> List[_models.JobCommand]:
3322+
"""Pilot Add Heartbeat.
3323+
3324+
Register a heartbeat from the job.
3325+
3326+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
3327+
receive job commands from the WMS. It also results in stalled jobs being
3328+
restored to the RUNNING status.
3329+
3330+
The ``data`` parameter and return value are mappings keyed by job ID.
3331+
3332+
:param body: Required.
3333+
:type body: dict[str, ~_generated.models.HeartbeatData]
3334+
:keyword authorization: Default value is None.
3335+
:paramtype authorization: str
3336+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
3337+
Default value is "application/json".
3338+
:paramtype content_type: str
3339+
:return: list of JobCommand
3340+
:rtype: list[~_generated.models.JobCommand]
3341+
:raises ~azure.core.exceptions.HttpResponseError:
3342+
"""
3343+
3344+
@overload
3345+
async def pilot_add_heartbeat(
3346+
self,
3347+
body: IO[bytes],
3348+
*,
3349+
authorization: Optional[str] = None,
3350+
content_type: str = "application/json",
3351+
**kwargs: Any
3352+
) -> List[_models.JobCommand]:
3353+
"""Pilot Add Heartbeat.
3354+
3355+
Register a heartbeat from the job.
3356+
3357+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
3358+
receive job commands from the WMS. It also results in stalled jobs being
3359+
restored to the RUNNING status.
3360+
3361+
The ``data`` parameter and return value are mappings keyed by job ID.
3362+
3363+
:param body: Required.
3364+
:type body: IO[bytes]
3365+
:keyword authorization: Default value is None.
3366+
:paramtype authorization: str
3367+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
3368+
Default value is "application/json".
3369+
:paramtype content_type: str
3370+
:return: list of JobCommand
3371+
:rtype: list[~_generated.models.JobCommand]
3372+
:raises ~azure.core.exceptions.HttpResponseError:
3373+
"""
3374+
3375+
@distributed_trace_async
3376+
async def pilot_add_heartbeat(
3377+
self,
3378+
body: Union[Dict[str, _models.HeartbeatData], IO[bytes]],
3379+
*,
3380+
authorization: Optional[str] = None,
3381+
**kwargs: Any
3382+
) -> List[_models.JobCommand]:
3383+
"""Pilot Add Heartbeat.
3384+
3385+
Register a heartbeat from the job.
3386+
3387+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
3388+
receive job commands from the WMS. It also results in stalled jobs being
3389+
restored to the RUNNING status.
3390+
3391+
The ``data`` parameter and return value are mappings keyed by job ID.
3392+
3393+
:param body: Is either a {str: HeartbeatData} type or a IO[bytes] type. Required.
3394+
:type body: dict[str, ~_generated.models.HeartbeatData] or IO[bytes]
3395+
:keyword authorization: Default value is None.
3396+
:paramtype authorization: str
3397+
:return: list of JobCommand
3398+
:rtype: list[~_generated.models.JobCommand]
3399+
:raises ~azure.core.exceptions.HttpResponseError:
3400+
"""
3401+
error_map: MutableMapping = {
3402+
401: ClientAuthenticationError,
3403+
404: ResourceNotFoundError,
3404+
409: ResourceExistsError,
3405+
304: ResourceNotModifiedError,
3406+
}
3407+
error_map.update(kwargs.pop("error_map", {}) or {})
3408+
3409+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
3410+
_params = kwargs.pop("params", {}) or {}
3411+
3412+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
3413+
cls: ClsType[List[_models.JobCommand]] = kwargs.pop("cls", None)
3414+
3415+
content_type = content_type or "application/json"
3416+
_json = None
3417+
_content = None
3418+
if isinstance(body, (IOBase, bytes)):
3419+
_content = body
3420+
else:
3421+
_json = self._serialize.body(body, "{HeartbeatData}")
3422+
3423+
_request = build_pilots_pilot_add_heartbeat_request(
3424+
authorization=authorization,
3425+
content_type=content_type,
3426+
json=_json,
3427+
content=_content,
3428+
headers=_headers,
3429+
params=_params,
3430+
)
3431+
_request.url = self._client.format_url(_request.url)
3432+
3433+
_stream = False
3434+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
3435+
_request, stream=_stream, **kwargs
3436+
)
3437+
3438+
response = pipeline_response.http_response
3439+
3440+
if response.status_code not in [200]:
3441+
map_error(status_code=response.status_code, response=response, error_map=error_map)
3442+
raise HttpResponseError(response=response)
3443+
3444+
deserialized = self._deserialize("[JobCommand]", pipeline_response.http_response)
3445+
3446+
if cls:
3447+
return cls(pipeline_response, deserialized, {}) # type: ignore
3448+
3449+
return deserialized # type: ignore
3450+
3451+
@overload
3452+
async def pilot_patch_metadata(
3453+
self,
3454+
body: Dict[str, Dict[str, Any]],
3455+
*,
3456+
authorization: Optional[str] = None,
3457+
content_type: str = "application/json",
3458+
**kwargs: Any
3459+
) -> None:
3460+
"""Pilot Patch Metadata.
3461+
3462+
Pilot Patch Metadata.
3463+
3464+
:param body: Required.
3465+
:type body: dict[str, dict[str, any]]
3466+
:keyword authorization: Default value is None.
3467+
:paramtype authorization: str
3468+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
3469+
Default value is "application/json".
3470+
:paramtype content_type: str
3471+
:return: None
3472+
:rtype: None
3473+
:raises ~azure.core.exceptions.HttpResponseError:
3474+
"""
3475+
3476+
@overload
3477+
async def pilot_patch_metadata(
3478+
self,
3479+
body: IO[bytes],
3480+
*,
3481+
authorization: Optional[str] = None,
3482+
content_type: str = "application/json",
3483+
**kwargs: Any
3484+
) -> None:
3485+
"""Pilot Patch Metadata.
3486+
3487+
Pilot Patch Metadata.
3488+
3489+
:param body: Required.
3490+
:type body: IO[bytes]
3491+
:keyword authorization: Default value is None.
3492+
:paramtype authorization: str
3493+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
3494+
Default value is "application/json".
3495+
:paramtype content_type: str
3496+
:return: None
3497+
:rtype: None
3498+
:raises ~azure.core.exceptions.HttpResponseError:
3499+
"""
3500+
3501+
@distributed_trace_async
3502+
async def pilot_patch_metadata(
3503+
self, body: Union[Dict[str, Dict[str, Any]], IO[bytes]], *, authorization: Optional[str] = None, **kwargs: Any
3504+
) -> None:
3505+
"""Pilot Patch Metadata.
3506+
3507+
Pilot Patch Metadata.
3508+
3509+
:param body: Is either a {str: {str: Any}} type or a IO[bytes] type. Required.
3510+
:type body: dict[str, dict[str, any]] or IO[bytes]
3511+
:keyword authorization: Default value is None.
3512+
:paramtype authorization: str
3513+
:return: None
3514+
:rtype: None
3515+
:raises ~azure.core.exceptions.HttpResponseError:
3516+
"""
3517+
error_map: MutableMapping = {
3518+
401: ClientAuthenticationError,
3519+
404: ResourceNotFoundError,
3520+
409: ResourceExistsError,
3521+
304: ResourceNotModifiedError,
3522+
}
3523+
error_map.update(kwargs.pop("error_map", {}) or {})
3524+
3525+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
3526+
_params = kwargs.pop("params", {}) or {}
3527+
3528+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
3529+
cls: ClsType[None] = kwargs.pop("cls", None)
3530+
3531+
content_type = content_type or "application/json"
3532+
_json = None
3533+
_content = None
3534+
if isinstance(body, (IOBase, bytes)):
3535+
_content = body
3536+
else:
3537+
_json = self._serialize.body(body, "{{object}}")
3538+
3539+
_request = build_pilots_pilot_patch_metadata_request(
3540+
authorization=authorization,
3541+
content_type=content_type,
3542+
json=_json,
3543+
content=_content,
3544+
headers=_headers,
3545+
params=_params,
3546+
)
3547+
_request.url = self._client.format_url(_request.url)
3548+
3549+
_stream = False
3550+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
3551+
_request, stream=_stream, **kwargs
3552+
)
3553+
3554+
response = pipeline_response.http_response
3555+
3556+
if response.status_code not in [204]:
3557+
map_error(status_code=response.status_code, response=response, error_map=error_map)
3558+
raise HttpResponseError(response=response)
3559+
3560+
if cls:
3561+
return cls(pipeline_response, None, {}) # type: ignore

0 commit comments

Comments
 (0)