status.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. """
  2. Status and Health Command Classes
  3. This module implements commands for system status and health monitoring.
  4. """
  5. from typing import Optional, Dict, Any
  6. from dataclasses import dataclass, field
  7. from .base import TrixyCommand, CommandResponse, ValidationError
  8. @dataclass
  9. class StatusRequestCommand(TrixyCommand):
  10. """Command to request system status."""
  11. status_type: str = field(default="general")
  12. target_component: str = field(default="all")
  13. def validate(self) -> bool:
  14. return True
  15. def get_command_name(self) -> str:
  16. return "StatusRequestCommand"
  17. @dataclass
  18. class HealthCheckCommand(TrixyCommand):
  19. """Command to perform health check."""
  20. check_type: str = field(default="basic")
  21. def validate(self) -> bool:
  22. return True
  23. def get_command_name(self) -> str:
  24. return "HealthCheckCommand"
  25. @dataclass
  26. class SystemInfoCommand(TrixyCommand):
  27. """Command to request system information."""
  28. info_type: str = field(default="general")
  29. def validate(self) -> bool:
  30. return True
  31. def get_command_name(self) -> str:
  32. return "SystemInfoCommand"
  33. @dataclass
  34. class StatusRequestResponse(CommandResponse):
  35. """Response to status request command."""
  36. status_data: Dict[str, Any] = field(default_factory=dict)
  37. def validate(self) -> bool:
  38. return True
  39. def get_response_name(self) -> str:
  40. return "StatusRequestResponse"
  41. @dataclass
  42. class HealthCheckResponse(CommandResponse):
  43. """Response to health check command."""
  44. health_status: str = field(default="unknown")
  45. health_data: Dict[str, Any] = field(default_factory=dict)
  46. def validate(self) -> bool:
  47. return True
  48. def get_response_name(self) -> str:
  49. return "HealthCheckResponse"
  50. @dataclass
  51. class SystemInfoResponse(CommandResponse):
  52. """Response to system info command."""
  53. system_info: Dict[str, Any] = field(default_factory=dict)
  54. def validate(self) -> bool:
  55. return True
  56. def get_response_name(self) -> str:
  57. return "SystemInfoResponse"
  58. __all__ = [
  59. "StatusRequestCommand", "HealthCheckCommand", "SystemInfoCommand",
  60. "StatusRequestResponse", "HealthCheckResponse", "SystemInfoResponse"
  61. ]