Master API client that contains all version-specific clients. This client provides a unified interface for accessing different API versions. It lazily initializes version-specific clients when they are first accessed.
| 18 | |
| 19 | |
| 20 | class ApiClient: |
| 21 | """ |
| 22 | Master API client that contains all version-specific clients. |
| 23 | |
| 24 | This client provides a unified interface for accessing different API versions. |
| 25 | It lazily initializes version-specific clients when they are first accessed. |
| 26 | """ |
| 27 | |
| 28 | def __init__(self, endpoint: str = "https://api.agentops.ai"): |
| 29 | """ |
| 30 | Initialize the master API client. |
| 31 | |
| 32 | Args: |
| 33 | endpoint: The base URL for the API |
| 34 | """ |
| 35 | self.endpoint = endpoint |
| 36 | self._clients: Dict[str, BaseApiClient] = {} |
| 37 | |
| 38 | @property |
| 39 | def v3(self) -> V3Client: |
| 40 | """ |
| 41 | Get the V3 API client. |
| 42 | |
| 43 | Returns: |
| 44 | The V3 API client |
| 45 | """ |
| 46 | return self._get_client("v3", V3Client) |
| 47 | |
| 48 | @property |
| 49 | def v4(self) -> V4Client: |
| 50 | """ |
| 51 | Get the V4 API client. |
| 52 | |
| 53 | Returns: |
| 54 | The V4 API client |
| 55 | """ |
| 56 | return self._get_client("v4", V4Client) |
| 57 | |
| 58 | def _get_client(self, version: str, client_class: Type[T]) -> T: |
| 59 | """ |
| 60 | Get or create a version-specific client. |
| 61 | |
| 62 | Args: |
| 63 | version: The API version |
| 64 | client_class: The client class to instantiate |
| 65 | |
| 66 | Returns: |
| 67 | The version-specific client |
| 68 | """ |
| 69 | if version not in self._clients: |
| 70 | self._clients[version] = client_class(self.endpoint) |
| 71 | return cast(T, self._clients[version]) |
no outgoing calls
no test coverage detected
searching dependent graphs…