from enum import Enum as PyEnum
from pydantic import BaseModel


class Token(BaseModel):
    access_token: str
    token_type: str
    refresh_token: str | None = None


class TokenData(BaseModel):
    username: str | None = None
    scopes: list[str] = []


class RefreshTokenRequest(BaseModel):
    refresh_token: str


class LogoutRequest(BaseModel):
    refresh_token: str


class UserRole(str, PyEnum):
    ADMIN = "admin"
    USER = "user"


class UserCreate(BaseModel):
    username: str
    password: str
    name: str


class UserPatch(BaseModel):
    name: str | None = None


class UserResponse(BaseModel):
    uuid: str
    username: str
    name: str
    role: UserRole

    class Config:
        from_attributes = True
