from pydantic import BaseModel
from typing import Optional
from datetime import datetime

# 터널 생성 요청
class TunnelCreateRequest(BaseModel):
    vm_id: int
    node: str
    vm_ip: Optional[str] = None  # Guest Agent 없이 수동으로 IP 지정 가능

# 터널 생성 응답
class TunnelCreateResponse(BaseModel):
    success: bool
    message: str
    session_id: str
    tunnel_info: Optional['TunnelInfo'] = None

# 터널 정보
class TunnelInfo(BaseModel):
    session_id: str
    local_port: int
    remote_host: str
    remote_port: int
    vm_id: int
    vm_name: Optional[str] = None
    rdp_username: Optional[str] = None
    is_active: bool
    created_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True

# 터널 상태 응답
class TunnelStatusResponse(BaseModel):
    session_id: str
    is_active: bool
    uptime_seconds: Optional[int] = None
    created_at: datetime

# 터널 종료 응답
class TunnelCloseResponse(BaseModel):
    success: bool
    message: str
    session_id: str
