44 lines
965 B
Python
44 lines
965 B
Python
"""Agent schemas for API validation."""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class AgentRegisterRequest(BaseModel):
|
|
"""Schema for agent registration request."""
|
|
|
|
hostname: str = Field(..., min_length=1, max_length=255)
|
|
version: str = Field(..., min_length=1, max_length=50)
|
|
metadata: dict[str, Any] | None = None
|
|
|
|
|
|
class AgentRegisterResponse(BaseModel):
|
|
"""Schema for agent registration response."""
|
|
|
|
agent_id: uuid.UUID
|
|
token: str
|
|
|
|
|
|
class AgentHeartbeatResponse(BaseModel):
|
|
"""Schema for agent heartbeat response."""
|
|
|
|
status: str = "ok"
|
|
|
|
|
|
class AgentResponse(BaseModel):
|
|
"""Schema for agent response."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: uuid.UUID
|
|
tenant_id: uuid.UUID | None
|
|
name: str
|
|
version: str
|
|
status: str
|
|
last_heartbeat: datetime | None
|
|
created_at: datetime
|
|
updated_at: datetime
|