106 lines
1.7 KiB
Python
106 lines
1.7 KiB
Python
|
import uuid
|
||
|
from typing import List, Optional
|
||
|
from datetime import datetime
|
||
|
from pydantic import BaseModel
|
||
|
|
||
|
from barker.schemas import to_camel
|
||
|
|
||
|
|
||
|
class ClientIn(BaseModel):
|
||
|
name: str
|
||
|
enabled: bool
|
||
|
otp: Optional[int]
|
||
|
|
||
|
|
||
|
class Client(ClientIn):
|
||
|
id_: uuid.UUID
|
||
|
code: int
|
||
|
creation_date: datetime
|
||
|
|
||
|
|
||
|
class LoginHistory(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
user_id: uuid.UUID
|
||
|
client_id: uuid.UUID
|
||
|
date: datetime
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
anystr_strip_whitespace = True
|
||
|
alias_generator = to_camel
|
||
|
|
||
|
|
||
|
class PermissionItem(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
name: str
|
||
|
enabled: bool
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
|
||
|
|
||
|
class RoleIn(BaseModel):
|
||
|
name: str
|
||
|
permissions: List[PermissionItem]
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
anystr_strip_whitespace = True
|
||
|
|
||
|
|
||
|
class Role(RoleIn):
|
||
|
id_: uuid.UUID
|
||
|
|
||
|
|
||
|
class RoleList(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
name: str
|
||
|
permissions: List[str]
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
anystr_strip_whitespace = True
|
||
|
|
||
|
|
||
|
class RoleItem(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
name: str
|
||
|
enabled: bool
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
|
||
|
|
||
|
class UserIn(BaseModel):
|
||
|
name: str
|
||
|
password: str
|
||
|
locked_out: bool
|
||
|
roles: List[RoleItem]
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
anystr_strip_whitespace = True
|
||
|
alias_generator = to_camel
|
||
|
|
||
|
|
||
|
class User(UserIn):
|
||
|
id_: uuid.UUID
|
||
|
|
||
|
|
||
|
class UserList(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
name: str
|
||
|
roles: List[str]
|
||
|
|
||
|
class Config:
|
||
|
fields = {"id_": "id"}
|
||
|
anystr_strip_whitespace = True
|
||
|
|
||
|
|
||
|
class UserToken(BaseModel):
|
||
|
id_: uuid.UUID
|
||
|
name: str
|
||
|
locked_out: bool = None
|
||
|
password: str
|
||
|
permissions: List[str]
|