"""Audio processing template schemas."""

from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, Field

from .filters import FilterInstanceSchema


class AudioProcessingTemplateCreate(BaseModel):
    """Request to create an audio processing template."""

    name: str = Field(description="Template name", min_length=1, max_length=100)
    filters: List[FilterInstanceSchema] = Field(
        default_factory=list, description="Ordered list of audio filter instances"
    )
    description: Optional[str] = Field(None, description="Template description", max_length=500)
    tags: List[str] = Field(default_factory=list, description="User-defined tags")


class AudioProcessingTemplateUpdate(BaseModel):
    """Request to update an audio processing template."""

    name: Optional[str] = Field(None, description="Template name", min_length=1, max_length=100)
    filters: Optional[List[FilterInstanceSchema]] = Field(
        None, description="Ordered list of audio filter instances"
    )
    description: Optional[str] = Field(None, description="Template description", max_length=500)
    tags: Optional[List[str]] = None


class AudioProcessingTemplateResponse(BaseModel):
    """Audio processing template information response."""

    id: str = Field(description="Template ID")
    name: str = Field(description="Template name")
    filters: List[FilterInstanceSchema] = Field(
        description="Ordered list of audio filter instances"
    )
    tags: List[str] = Field(default_factory=list, description="User-defined tags")
    created_at: datetime = Field(description="Creation timestamp")
    updated_at: datetime = Field(description="Last update timestamp")
    description: Optional[str] = Field(None, description="Template description")


class AudioProcessingTemplateListResponse(BaseModel):
    """List of audio processing templates response."""

    templates: List[AudioProcessingTemplateResponse] = Field(
        description="List of audio processing templates"
    )
    count: int = Field(description="Number of templates")
