import uuid
from pydantic import BaseModel, Field


class SmtpConfigOut(BaseModel):
    model_config = {"from_attributes": True}

    id: uuid.UUID
    company_id: uuid.UUID
    host: str
    port: int
    use_tls: bool
    use_starttls: bool
    username: str | None
    from_email: str
    from_name: str
    is_enabled: bool
    # password_encrypted wird nie zurückgegeben


class SmtpConfigSave(BaseModel):
    host: str = Field(min_length=1, max_length=255)
    port: int = Field(default=587, ge=1, le=65535)
    use_tls: bool = False
    use_starttls: bool = True
    username: str | None = Field(None, max_length=255)
    password: str | None = None          # Klartext – wird serverseitig verschlüsselt
    from_email: str = Field(min_length=5, max_length=255)
    from_name: str = Field(default="TimeMaster", min_length=1, max_length=255)
    is_enabled: bool = True


class SmtpTestRequest(BaseModel):
    to: str = Field(min_length=5, max_length=255)
