79 lines
1.5 KiB
Python
79 lines
1.5 KiB
Python
from pydantic import BaseModel
|
|
from typing import List, Optional, Any
|
|
import datetime
|
|
|
|
class AccountBase(BaseModel):
|
|
google_email: str
|
|
|
|
class AccountCreate(AccountBase):
|
|
credentials: Any # Can be a dict or a JSON string
|
|
drive_space_total: int
|
|
drive_space_used: int
|
|
|
|
class Account(AccountBase):
|
|
id: int
|
|
user_id: int
|
|
credentials: Any
|
|
drive_space_total: int
|
|
drive_space_used: int
|
|
drive_space_reserved: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class FilePartBase(BaseModel):
|
|
part_index: int
|
|
size: int
|
|
drive_file_id: str
|
|
sha256: str
|
|
|
|
class FilePartCreate(FilePartBase):
|
|
pass
|
|
|
|
class FilePart(FilePartBase):
|
|
id: int
|
|
file_id: int
|
|
account_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class FileBase(BaseModel):
|
|
filename: str
|
|
original_size: int
|
|
sha256: str
|
|
|
|
class FileCreate(FileBase):
|
|
download_token: str
|
|
|
|
class File(FileBase):
|
|
id: int
|
|
user_id: int
|
|
upload_time: datetime.datetime
|
|
download_token: str
|
|
parts: List[FilePart] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class UserBase(BaseModel):
|
|
email: str
|
|
|
|
class UserCreate(UserBase):
|
|
pass
|
|
|
|
class User(UserBase):
|
|
id: int
|
|
created_at: datetime.datetime
|
|
accounts: List[Account] = []
|
|
files: List[File] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class StorageStatus(BaseModel):
|
|
total_space: int
|
|
used_space: int
|
|
free_space: int
|
|
accounts: List[Account]
|