"""Fetch staged destination terms for a transfer job from ows-royalties.""" from __future__ import annotations from typing import Any from src import config from src.errors import TransientError from src.ows_response import parse_json_response def fetch_staged_terms_for_job(job_id: int) -> list[dict[str, Any]]: """Call GET /transfer-job/{job_id}/terms on ows-royalties.""" config.logger.info("Fetching staged terms for job %d", job_id) resp = config.ows_client.get("ows-royalties", path=f"/transfer-job/{job_id}/terms") data = parse_json_response("ows-royalties", resp) if not isinstance(data, list): raise TransientError(f"ows-royalties staged-terms response is not a list: {data!r}") config.logger.info("Fetched %d staged term(s) for job %d.", len(data), job_id) return data