2022-04-03 13:51:26 +02:00
|
|
|
from typing import Any, List, Optional
|
2022-03-03 13:49:26 +01:00
|
|
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
class IotEntityBase(BaseModel):
|
2022-04-13 08:39:25 +02:00
|
|
|
bluetooth_mac: str
|
2022-03-03 13:49:26 +01:00
|
|
|
description: str
|
|
|
|
|
2022-04-13 07:34:12 +02:00
|
|
|
class UserBase(BaseModel):
|
|
|
|
email: str
|
|
|
|
username: str
|
2022-03-03 13:49:26 +01:00
|
|
|
|
|
|
|
class IotEntityCreate(IotEntityBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-04-13 07:34:12 +02:00
|
|
|
class UserCreate(UserBase):
|
|
|
|
password: str
|
|
|
|
|
2022-03-03 13:49:26 +01:00
|
|
|
class IotEntity(IotEntityBase):
|
|
|
|
id: int
|
|
|
|
description: str
|
2022-04-13 08:39:25 +02:00
|
|
|
bluetooth_mac: str
|
2022-04-13 07:34:12 +02:00
|
|
|
#authorized_users: List[User] = []
|
2022-04-18 00:43:12 +02:00
|
|
|
open_request: bool # Flag to open
|
2022-03-03 13:49:26 +01:00
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
2022-04-17 20:20:45 +02:00
|
|
|
class IotBluetoothMac(BaseModel):
|
|
|
|
bluetooth_mac : str
|
|
|
|
|
2022-03-03 13:49:26 +01:00
|
|
|
class User(UserBase):
|
|
|
|
id: int
|
|
|
|
is_active: bool
|
2022-04-03 13:51:26 +02:00
|
|
|
authorized_devices: List[IotEntity] = []
|
2022-03-03 13:49:26 +01:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
2022-04-13 04:24:06 +02:00
|
|
|
|
2022-04-13 07:34:12 +02:00
|
|
|
|
2022-04-13 04:24:06 +02:00
|
|
|
class Token(BaseModel):
|
|
|
|
access_token : str
|
|
|
|
token_type : str
|
|
|
|
|
|
|
|
class TokenData(BaseModel):
|
|
|
|
username : str
|
|
|
|
# Token can conatin information. But we are already recording this in a database
|
|
|
|
# for scalability.
|
2022-04-13 07:34:12 +02:00
|
|
|
|
2022-04-14 00:37:30 +02:00
|
|
|
class UserAllowForIotEntityRequestByID(BaseModel):
|
2022-04-13 07:34:12 +02:00
|
|
|
user_id: int
|
2022-04-14 00:37:30 +02:00
|
|
|
iot_entity_id: int
|
|
|
|
|
|
|
|
class UserAllowForIotEntityRequestByUsername(BaseModel):
|
|
|
|
username: str
|
2022-04-18 00:43:12 +02:00
|
|
|
description: str
|
|
|
|
|
|
|
|
class OpenDoorRequestBase(BaseModel):
|
|
|
|
username: str
|
|
|
|
bluetooth_mac: str
|
|
|
|
|
|
|
|
class OpenDoorRequestTime(OpenDoorRequestBase):
|
|
|
|
time_minutes: int
|