You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.2 KiB
25 lines
1.2 KiB
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
|
|
class SSHExecRequest(BaseModel):
|
|
"""SSH执行命令请求模型"""
|
|
command: str = Field(..., description="要执行的命令")
|
|
timeout: Optional[int] = Field(30, description="执行超时时间(秒)", ge=1)
|
|
working_directory: Optional[str] = Field(None, description="工作目录")
|
|
|
|
class SSHExecResponse(BaseModel):
|
|
"""SSH执行命令响应模型"""
|
|
success: bool = Field(..., description="执行是否成功")
|
|
stdout: str = Field(..., description="标准输出")
|
|
stderr: str = Field(..., description="标准错误")
|
|
exit_code: int = Field(..., description="退出码")
|
|
execution_time: float = Field(..., description="执行时间(秒)")
|
|
|
|
class SSHConnectionInfo(BaseModel):
|
|
"""SSH连接信息模型"""
|
|
host: str = Field(..., description="主机地址")
|
|
port: int = Field(22, description="端口号", ge=1, le=65535)
|
|
username: str = Field(..., description="用户名")
|
|
password: Optional[str] = Field(None, description="密码")
|
|
key_file: Optional[str] = Field(None, description="私钥文件路径")
|
|
timeout: int = Field(30, description="连接超时时间(秒)", ge=1)
|