system.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from shared.api.models import (
  2. WrappedGenericMessageResponse,
  3. WrappedServerStatsResponse,
  4. WrappedSettingsResponse,
  5. )
  6. class SystemSDK:
  7. def __init__(self, client):
  8. self.client = client
  9. def health(self) -> WrappedGenericMessageResponse:
  10. """Check the health of the R2R server."""
  11. response_dict = self.client._make_request(
  12. "GET", "health", version="v3"
  13. )
  14. return WrappedGenericMessageResponse(**response_dict)
  15. def settings(self) -> WrappedSettingsResponse:
  16. """Get the configuration settings for the R2R server.
  17. Returns:
  18. dict: The server settings.
  19. """
  20. response_dict = self.client._make_request(
  21. "GET", "system/settings", version="v3"
  22. )
  23. return WrappedSettingsResponse(**response_dict)
  24. def status(self) -> WrappedServerStatsResponse:
  25. """Get statistics about the server, including the start time, uptime,
  26. CPU usage, and memory usage.
  27. Returns:
  28. dict: The server statistics.
  29. """
  30. response_dict = self.client._make_request(
  31. "GET", "system/status", version="v3"
  32. )
  33. return WrappedServerStatsResponse(**response_dict)