from pydantic import BaseModel, Field from typing import List, Optional, Dict from datetime import datetime from enum import Enum class ContainerStatus(str, Enum): RUNNING = "running" STOPPED = "stopped" PAUSED = "paused" RESTARTING = "restarting" REMOVED = "removed" DEAD = "dead" CREATED = "created" class Container(BaseModel): id: str name: str image: str status: ContainerStatus created: datetime ports: Dict[str, List[Dict[str, str]]] = Field(default_factory=dict) labels: Dict[str, str] = Field(default_factory=dict) networks: List[str] = Field(default_factory=list) volumes: List[str] = Field(default_factory=list) env_vars: Dict[str, str] = Field(default_factory=dict) restart_policy: Optional[str] = None cpu_usage: Optional[float] = None memory_usage: Optional[int] = None network_usage: Optional[Dict[str, int]] = None class Agent(BaseModel): id: str name: str hostname: str ip_address: str docker_version: str status: str last_seen: datetime containers: List[Container] = Field(default_factory=list) class LogEntry(BaseModel): container_id: str timestamp: datetime message: str stream: str # stdout ou stderr class ContainerUpdate(BaseModel): container_id: str action: str # start, stop, restart, update agent_id: Optional[str] = None class AgentRegistration(BaseModel): name: str hostname: str ip_address: str docker_version: str