File size: 1,716 Bytes
1e7e130 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
from pydantic import BaseModel
from typing import Optional, Dict, Any, List
# Request Schemas
class RegisterUserRequest(BaseModel):
phone: str
password: str
profile: Optional[str] = "default"
class LoginRequest(BaseModel):
phone: str
password: str
mac_address: str
ip_address: str
class SetUserStatusRequest(BaseModel):
phone: str
disabled: bool
# Response Schemas
class UserUsage(BaseModel):
bytes_in: int
bytes_out: int
total_bytes: int
download_mb: float
upload_mb: float
total_mb: float
class ActiveUser(BaseModel):
phone: str
uptime: str
mac_address: str
ip_address: str
usage: UserUsage
class UserStats(BaseModel):
phone: str
profile: str
status: str
uptime: str
usage: UserUsage
class UserListItem(BaseModel):
phone: str
profile: str
status: str
disabled: bool
comment: str
usage: UserUsage
# Base Response Schema
class APIResponse(BaseModel):
success: bool
message: str
data: Optional[Dict[str, Any]] = None
error: Optional[str] = None
# Specific Response Schemas
class RegisterUserResponse(APIResponse):
data: Optional[Dict[str, Any]] = None
class LoginResponse(APIResponse):
data: Optional[Dict[str, Any]] = None
class LogoutResponse(APIResponse):
data: Optional[Dict[str, Any]] = None
class UserStatusResponse(APIResponse):
data: Optional[Dict[str, Any]] = None
class ActiveUsersResponse(APIResponse):
data: Optional[List[ActiveUser]] = None
class UsersListResponse(APIResponse):
data: Optional[List[UserListItem]] = None
class UserStatsResponse(APIResponse):
data: Optional[List[UserStats]] = None
|