"""finalize-job Lambda handler.""" from typing import Any from src import config from src.client import patch_transfer_job def _job_id_from_event(event: dict[str, Any]) -> int: raw_job_id = event["job_id"] if isinstance(raw_job_id, bool): raise ValueError("event['job_id'] must be an integer.") try: return int(raw_job_id) except (TypeError, ValueError) as exc: raise ValueError("event['job_id'] must be an integer.") from exc def handler(event: dict[str, Any], context: object) -> dict[str, Any]: del context job_id = _job_id_from_event(event) config.logger.info(f"Finalizing transfer job {job_id}") patch_transfer_job(job_id, {"status": "COMPLETED"}) config.logger.info(f"Transfer job {job_id} marked COMPLETED") return {"statusCode": 200}