2026-06-29 00:10:10 +02:00
|
|
|
"""User schemas."""
|
2026-06-04 00:06:23 +00:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-06-29 00:10:10 +02:00
|
|
|
from pydantic import BaseModel, EmailStr, Field
|
2026-06-04 00:06:23 +00:00
|
|
|
|
|
|
|
|
|
2026-06-29 00:10:10 +02:00
|
|
|
class UserCreate(BaseModel):
|
2026-06-04 00:06:23 +00:00
|
|
|
email: EmailStr
|
2026-06-29 00:10:10 +02:00
|
|
|
name: str = Field(..., min_length=1, max_length=200)
|
|
|
|
|
password: str = Field(..., min_length=8)
|
|
|
|
|
role: str = Field(default="viewer")
|
|
|
|
|
is_active: bool = True
|
2026-06-04 00:06:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
2026-06-29 00:10:10 +02:00
|
|
|
name: str | None = Field(None, min_length=1, max_length=200)
|
|
|
|
|
role: str | None = None
|
|
|
|
|
is_active: bool | None = None
|
2026-06-04 00:06:23 +00:00
|
|
|
|
|
|
|
|
|
2026-06-29 00:10:10 +02:00
|
|
|
class UserResponse(BaseModel):
|
|
|
|
|
id: str
|
|
|
|
|
email: str
|
|
|
|
|
name: str
|
|
|
|
|
role: str
|
|
|
|
|
is_active: bool
|
|
|
|
|
tenant_id: str
|
2026-06-04 00:06:23 +00:00
|
|
|
|
|
|
|
|
|
2026-06-29 00:10:10 +02:00
|
|
|
class PaginatedUsers(BaseModel):
|
|
|
|
|
items: list[UserResponse]
|
2026-06-04 00:06:23 +00:00
|
|
|
total: int
|
|
|
|
|
page: int
|
|
|
|
|
page_size: int
|