<?php

namespace interfaces;

use Exception;

interface minio_backups_i
{
    /**
     * Check if a backup exists in the Minio bucket
     * @param string $backup_uuid
     * @return bool
     */
    public function backup_exists(string $backup_uuid): bool;

    /**
     * Get the download URL for a backup
     * @param string $backup_uuid
     * @return string
     */
    public function getBackupDownloadUrl(string $backup_uuid): string;

    /**
     * Download a backup from the Minio bucket
     * @param string $backup_uuid
     * @return string The path to the downloaded file
     */
    public function download(string $backup_uuid): string;

    /**
     * Create a backup, upload it to the Minio bucket and return the UUID
     * @return string The UUID of the backup
     */
    public function createBackup(): string;

    /**
     * Create the metadata for a backup
     * @param string $backup_uuid
     * @param string $backup_name
     * @param string $backup_description
     * @return void
     */
    public function createBackupMetadata(string $backup_uuid, string $backup_name, string $backup_description): void;

    /**
     * Get the metadata for a backup
     * @param string $backup_uuid
     * @return array
     */
    public function getBackupMetadata(string $backup_uuid): array;

    /**
     * List all backups in the Minio bucket, from the metadata stored in the bucket
     * @return array
     */
    public function listBackups(): array;

    /**
     * Generate backup file, this is a helper function for createBackup
     * @return string The path to the backup file
     * @throws Exception if the backup file could not be created
     */
    public function generateBackupFile(): string;

    /**
     * Clean up backup files, this is a helper function for createBackup
     * This removes all local backup files, to prevent the disk from filling up.
     * @param string $backup_uuid
     * @return void
     */
    public function cleanupBackupFile(string $backup_uuid): void;

    /**
     * Backup the database, this is a helper function for generateBackupFile
     * @param string $backup_uuid
     * @return string The path to the backup file
     */
    public function backupDatabase(string $backup_uuid): string;

    /**
     * Validate the bucket, this is a helper function.
     * Checks if the buckets /metadata and /backups exist, and creates them if they don't.
     * @return void
     */
    public function validateBucket(): void;

    /**
     * Backup server files, this is a helper function for generateBackupFile
     * @param string $backup_uuid
     * @return string The path to the backup file
     */
    public function backupServerFiles(string $backup_uuid): string;

    /**
     * Backup the environment variables, this is a helper function for generateBackupFile
     * @param string $backup_uuid
     * @return string The path to the backup file
     */
    public function backupEnvironmentVariables(string $backup_uuid): string;

}