"""Pydantic schemas for Technique endpoints."""

# Import uuid
import uuid

# Import datetime from datetime
from datetime import datetime

# Import BaseModel, ConfigDict from pydantic
from pydantic import BaseModel, ConfigDict

# Import TechniqueStatus from app.models.enums
from app.models.enums import TechniqueStatus

# ── Create ──────────────────────────────────────────────────────────

class TechniqueCreate(BaseModel):
    """Payload for creating a new technique."""

    # mitre_id: str
    mitre_id: str
    # name: str
    name: str
    # Assign description = None
    description: str | None = None
    # Assign tactic = None
    tactic: str | None = None
    # Assign platforms = None
    platforms: list[str] | None = None


# ── Update ──────────────────────────────────────────────────────────

class TechniqueUpdate(BaseModel):
    """Payload for partially updating an existing technique.

    Every field is optional so callers send only what changed.
    """

    # Assign name = None
    name: str | None = None
    # Assign description = None
    description: str | None = None
    # Assign tactic = None
    tactic: str | None = None
    # Assign platforms = None
    platforms: list[str] | None = None
    # Assign status_global = None
    status_global: TechniqueStatus | None = None


# ── Read (full) ─────────────────────────────────────────────────────

class TechniqueOut(BaseModel):
    """Complete representation returned by the API."""

    # id: uuid.UUID
    id: uuid.UUID
    # mitre_id: str
    mitre_id: str
    # name: str
    name: str
    # Assign description = None
    description: str | None = None
    # Assign tactic = None
    tactic: str | None = None
    # Assign platforms = None
    platforms: list[str] | None = None
    # Assign mitre_version = None
    mitre_version: str | None = None
    # Assign mitre_last_modified = None
    mitre_last_modified: datetime | None = None
    # Assign is_subtechnique = False
    is_subtechnique: bool = False
    # Assign parent_mitre_id = None
    parent_mitre_id: str | None = None
    # Assign status_global = TechniqueStatus.not_evaluated
    status_global: TechniqueStatus = TechniqueStatus.not_evaluated
    # Assign review_required = False
    review_required: bool = False
    # Assign last_review_date = None
    last_review_date: datetime | None = None

    # Assign model_config = ConfigDict(from_attributes=True)
    model_config = ConfigDict(from_attributes=True)


# ── Read (summary) ──────────────────────────────────────────────────

class TechniqueSummary(BaseModel):
    """Lightweight representation used in list endpoints."""

    # id: uuid.UUID
    id: uuid.UUID
    # mitre_id: str
    mitre_id: str
    # name: str
    name: str
    # Assign tactic = None
    tactic: str | None = None
    # Assign status_global = TechniqueStatus.not_evaluated
    status_global: TechniqueStatus = TechniqueStatus.not_evaluated

    # Assign model_config = ConfigDict(from_attributes=True)
    model_config = ConfigDict(from_attributes=True)
