package com.atlassian.stash.internal.backup;

import com.google.common.io.InputSupplier;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;

/**
 * Represents a single system backup.
 *
 * @since 2.1
 */
public interface Backup extends InputSupplier<InputStream> {

    /**
     * Retrieve an {@code InputStream} which can be used to read the backup on disk.
     * <p>
     * Implementations shall return a distinct stream for each invocation. Callers should ensure the stream is always
     * closed after it has been used.
     *
     * @return a stream for reading the backup
     * @throws IOException if the backup cannot be opened for reading
     */
    @Nonnull
    @Override
    InputStream getInput() throws IOException;

    /**
     * Retrieves the modification timestamp for the backup, which represents the time the backup was completed.
     *
     * @return the backup's last modified timestamp
     */
    long getModified();

    /**
     * Retrieves the name for this backup, which will be unique across all backups.
     *
     * @return the backup's name
     */
    @Nonnull
    String getName();

    /**
     * Retrieves the size, in bytes, for the backup.
     *
     * @return the backup's size, in bytes
     */
    long getSize();
}
