Add user schema

This commit is contained in:
Iam54r1n4
2025-01-25 15:48:14 +00:00
parent 1d3567b603
commit 0a8ab55abb

View File

@ -0,0 +1,36 @@
from pydantic import BaseModel
from pydantic import BaseModel, RootModel
# WE CAN'T USE SHARED SCHEMA BECAUSE THE CLI IS RETURNING SAME FIELD IN DIFFERENT NAMES SOMETIMES
# WHAT I'M SAYING IS THAT OUR CODE IN HERE WILL BE SPAGHETTI CODE IF WE WANT TO HAVE CONSISTENCY IN ALL RESPONSES OF THE APIs
# THE MAIN PROBLEM IS IN THE CLI CODE NOT IN THE WEB PANEL CODE (HERE)
class UserInfo(BaseModel):
password: str
max_download_bytes: int
expiration_days: int
account_creation_date: str
blocked: bool
class UserList(RootModel):
root: dict[str, UserInfo]
class AddUserInputBody(BaseModel):
username: str
traffic_limit: int
expiration_days: int
password: str | None = None
creation_date: str | None = None
class EditUserInputBody(BaseModel):
# username: str
new_username: str | None = None
new_traffic_limit: int | None = None
new_expiration_days: int | None = None
renew_password: bool = False
renew_creation_date: bool = False
blocked: bool = False