"""Pydantic schemas for device types."""
from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field


class DeviceTypeCreate(BaseModel):
    slug: str = Field(min_length=1, max_length=50, pattern=r"^[a-z0-9\-]+$")
    label: str = Field(min_length=1, max_length=100)
    category: str = Field(
        min_length=1, max_length=50,
        pattern=r"^(network|compute|storage|cloud|endpoint|infrastructure|security)$",
    )
    sort_order: int = Field(default=0, ge=0)


class DeviceTypeUpdate(BaseModel):
    label: str | None = Field(default=None, min_length=1, max_length=100)
    category: str | None = Field(
        default=None, min_length=1, max_length=50,
        pattern=r"^(network|compute|storage|cloud|endpoint|infrastructure|security)$",
    )
    sort_order: int | None = Field(default=None, ge=0)


class DeviceTypeResponse(BaseModel):
    id: UUID
    slug: str
    label: str
    category: str
    is_system: bool
    account_id: UUID
    sort_order: int
    created_at: datetime

    model_config = {"from_attributes": True}
