# retoor <retoor@molodetz.nl>

from __future__ import annotations

from typing import Optional

from devplacepy.schemas.base import _Out


class BackupStoragePathOut(_Out):
    key: str = ""
    label: str = ""
    path: str = ""
    size_bytes: int = 0
    size_human: str = ""
    file_count: int = 0
    exists: bool = False


class BackupOut(_Out):
    uid: str = ""
    job_uid: str = ""
    target: str = ""
    label: str = ""
    status: str = ""
    filename: str = ""
    size_bytes: int = 0
    size_human: str = ""
    bytes_in: int = 0
    file_count: int = 0
    dir_count: int = 0
    sha256: str = ""
    schedule_uid: str = ""
    created_by: str = ""
    created_at: Optional[str] = None
    completed_at: Optional[str] = None
    error: Optional[str] = None
    download_url: Optional[str] = None


class BackupJobOut(_Out):
    uid: str = ""
    kind: str = ""
    status: str = ""
    target: Optional[str] = None
    backup_uid: Optional[str] = None
    download_url: Optional[str] = None
    error: Optional[str] = None
    bytes_out: int = 0
    file_count: int = 0
    sha256: Optional[str] = None
    created_at: Optional[str] = None
    completed_at: Optional[str] = None


class BackupScheduleOut(_Out):
    uid: str = ""
    name: str = ""
    target: str = ""
    kind: str = ""
    every_seconds: int = 0
    cron: Optional[str] = None
    enabled: int = 0
    keep_last: int = 0
    next_run_at: Optional[str] = None
    last_run_at: Optional[str] = None
    last_job_uid: Optional[str] = None
    run_count: int = 0
    created_at: Optional[str] = None


class BackupDashboardOut(_Out):
    storage: dict = {}
    backups: list[BackupOut] = []
    schedules: list[BackupScheduleOut] = []
    targets: list[dict] = []
    metrics: dict = {}
    generated_at: Optional[str] = None
    can_download_backups: bool = False
    admin_section: Optional[str] = None
