from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field

Username = str
Role = Literal["admin", "user"]
UserStatus = Literal["active", "disabled"]


class LoginBody(BaseModel):
    username: Username = Field(min_length=3, max_length=64)
    password: str = Field(min_length=1, max_length=128)


class CreateAuthUserBody(BaseModel):
    username: Username = Field(
        min_length=3,
        max_length=64,
        pattern=r"^[A-Za-z0-9_.-]+$",
    )
    password: str = Field(min_length=8, max_length=128)
    display_name: str = Field(min_length=1, max_length=128)
    role: Role = "user"


class UpdateAuthUserBody(BaseModel):
    display_name: str | None = Field(default=None, min_length=1, max_length=128)
    role: Role | None = None
    status: UserStatus | None = None
    password: str | None = Field(default=None, min_length=8, max_length=128)
