Add user schema
This commit is contained in:
36
core/scripts/webpanel/routers/api/v1/schema/user.py
Normal file
36
core/scripts/webpanel/routers/api/v1/schema/user.py
Normal 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
|
||||
Reference in New Issue
Block a user