server.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from __future__ import annotations # for Python 3.10+
  2. from typing import Optional
  3. from typing_extensions import deprecated
  4. class ServerMixins:
  5. @deprecated("Use client.system.health() instead")
  6. async def health(self) -> dict:
  7. return await self._make_request("GET", "health") # type: ignore
  8. async def server_stats(self) -> dict:
  9. """
  10. Get statistics about the server, including the start time, uptime, CPU usage, and memory usage.
  11. Returns:
  12. dict: The server statistics.
  13. """
  14. return await self._make_request("GET", "server_stats") # type: ignore
  15. @deprecated("Use client.system.logs() instead")
  16. async def logs(
  17. self,
  18. offset: Optional[int] = None,
  19. limit: Optional[int] = None,
  20. run_type_filter: Optional[str] = None,
  21. ) -> dict:
  22. """
  23. Get logs from the server.
  24. Args:
  25. offset (Optional[int]): The offset to start from.
  26. limit (Optional[int]): The maximum number of logs to return.
  27. run_type_filter (Optional[str]): The run type to filter by.
  28. Returns:
  29. dict: The logs from the server.
  30. """
  31. params = {
  32. key: value
  33. for key, value in {
  34. "offset": offset,
  35. "limit": limit,
  36. "run_type_filter": run_type_filter,
  37. }.items()
  38. if value is not None
  39. }
  40. return await self._make_request("GET", "logs", params=params) # type: ignore