| 1234567891011121314151617181920212223242526 |
- import httpx
- from core_domain import WorkflowVersionContract
- class WorkflowServiceClientError(Exception):
- pass
- class WorkflowServiceClient:
- def __init__(self, base_url: str, timeout_seconds: float = 10.0) -> None:
- self.base_url = base_url.rstrip("/")
- self.timeout_seconds = timeout_seconds
- def get_workflow_version(self, *, tenant_id: str, workflow_version_id: str) -> WorkflowVersionContract:
- try:
- with httpx.Client(timeout=self.timeout_seconds) as client:
- response = client.get(
- f"{self.base_url}/workflows/versions/{workflow_version_id}",
- params={"tenant_id": tenant_id},
- )
- response.raise_for_status()
- return WorkflowVersionContract.model_validate(response.json())
- except httpx.HTTPError as exc:
- raise WorkflowServiceClientError(f"workflow-service request failed: {exc}") from exc
|