28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
# [DEF:FileCategory:Class]
|
|
class FileCategory(str, Enum):
|
|
BACKUP = "backups"
|
|
REPOSITORY = "repositorys"
|
|
# [/DEF:FileCategory:Class]
|
|
|
|
# [DEF:StorageConfig:Class]
|
|
class StorageConfig(BaseModel):
|
|
root_path: str = Field(default="backups", description="Absolute path to the storage root directory.")
|
|
backup_structure_pattern: str = Field(default="{category}/", description="Pattern for backup directory structure.")
|
|
repo_structure_pattern: str = Field(default="{category}/", description="Pattern for repository directory structure.")
|
|
filename_pattern: str = Field(default="{name}_{timestamp}", description="Pattern for filenames.")
|
|
# [/DEF:StorageConfig:Class]
|
|
|
|
# [DEF:StoredFile:Class]
|
|
class StoredFile(BaseModel):
|
|
name: str = Field(..., description="Name of the file (including extension).")
|
|
path: str = Field(..., description="Relative path from storage root.")
|
|
size: int = Field(..., ge=0, description="Size of the file in bytes.")
|
|
created_at: datetime = Field(..., description="Creation timestamp.")
|
|
category: FileCategory = Field(..., description="Category of the file.")
|
|
mime_type: Optional[str] = Field(None, description="MIME type of the file.")
|
|
# [/DEF:StoredFile:Class] |