2020-05-08 04:52:25 +00:00
|
|
|
import uuid
|
2020-10-07 15:18:43 +00:00
|
|
|
|
2020-05-08 04:52:25 +00:00
|
|
|
from datetime import datetime
|
2020-10-07 15:18:43 +00:00
|
|
|
from typing import List, Optional
|
2020-05-08 04:52:25 +00:00
|
|
|
|
2020-05-14 16:19:22 +00:00
|
|
|
from brewman.schemas import to_camel
|
2020-10-07 15:18:43 +00:00
|
|
|
from pydantic import BaseModel
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
|
2020-05-10 17:08:35 +00:00
|
|
|
class ClientIn(BaseModel):
|
2020-05-08 04:52:25 +00:00
|
|
|
name: str
|
|
|
|
enabled: bool
|
2020-05-11 20:01:21 +00:00
|
|
|
otp: Optional[int]
|
2020-05-10 17:08:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Client(ClientIn):
|
|
|
|
id_: uuid.UUID
|
|
|
|
code: int
|
2020-05-08 04:52:25 +00:00
|
|
|
creation_date: datetime
|
|
|
|
|
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
class LoginHistory(BaseModel):
|
|
|
|
id_: uuid.UUID
|
|
|
|
user_id: uuid.UUID
|
|
|
|
client_id: uuid.UUID
|
|
|
|
date: datetime
|
|
|
|
|
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
anystr_strip_whitespace = True
|
|
|
|
alias_generator = to_camel
|
|
|
|
|
|
|
|
|
|
|
|
class PermissionItem(BaseModel):
|
|
|
|
id_: uuid.UUID
|
|
|
|
name: str
|
|
|
|
enabled: bool
|
|
|
|
|
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RoleIn(BaseModel):
|
|
|
|
name: str
|
|
|
|
permissions: List[PermissionItem]
|
|
|
|
|
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
anystr_strip_whitespace = True
|
|
|
|
|
|
|
|
|
|
|
|
class Role(RoleIn):
|
2020-05-08 04:52:25 +00:00
|
|
|
id_: uuid.UUID
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RoleList(BaseModel):
|
|
|
|
id_: uuid.UUID
|
|
|
|
name: str
|
|
|
|
permissions: List[str]
|
|
|
|
|
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
anystr_strip_whitespace = True
|
|
|
|
|
|
|
|
|
|
|
|
class RoleItem(BaseModel):
|
|
|
|
id_: uuid.UUID
|
|
|
|
name: str
|
|
|
|
enabled: bool
|
|
|
|
|
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserIn(BaseModel):
|
2020-05-08 04:52:25 +00:00
|
|
|
name: str
|
|
|
|
password: str
|
|
|
|
locked_out: bool
|
2020-05-10 15:06:19 +00:00
|
|
|
roles: List[RoleItem]
|
2020-05-08 04:52:25 +00:00
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
anystr_strip_whitespace = True
|
|
|
|
alias_generator = to_camel
|
2020-05-08 04:52:25 +00:00
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
class User(UserIn):
|
2020-05-08 04:52:25 +00:00
|
|
|
id_: uuid.UUID
|
|
|
|
|
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
class UserList(BaseModel):
|
2020-05-08 04:52:25 +00:00
|
|
|
id_: uuid.UUID
|
|
|
|
name: str
|
2020-05-10 15:06:19 +00:00
|
|
|
roles: List[str]
|
2020-05-08 04:52:25 +00:00
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
class Config:
|
2020-05-10 17:08:35 +00:00
|
|
|
fields = {"id_": "id"}
|
2020-05-10 15:06:19 +00:00
|
|
|
anystr_strip_whitespace = True
|
2020-05-08 04:52:25 +00:00
|
|
|
|
2020-05-10 15:06:19 +00:00
|
|
|
|
|
|
|
class UserToken(BaseModel):
|
2020-05-08 04:52:25 +00:00
|
|
|
id_: uuid.UUID
|
|
|
|
name: str
|
2020-05-10 15:06:19 +00:00
|
|
|
locked_out: bool = None
|
|
|
|
password: str
|
|
|
|
permissions: List[str]
|