| 123456789101112131415161718192021222324 |
- import httpx
- from core_domain import ToolBindingDetailContract
- class ToolServiceClientError(Exception):
- pass
- class ToolServiceClient:
- 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_tool_binding_detail(
- self,
- *,
- binding_id: str) -> ToolBindingDetailContract:
- try:
- with httpx.Client(timeout=self.timeout_seconds) as client:
- response = client.get(f"{self.base_url}/tools/bindings/{binding_id}")
- response.raise_for_status()
- return ToolBindingDetailContract.model_validate(response.json())
- except httpx.HTTPError as exc:
- raise ToolServiceClientError(f"tool-service request failed: {exc}") from exc
|