package leigh.elements.sdk;

import leigh.mecha.file.FileStat;

import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;

/**
 * A specific instance / deployment of a given elements application. Only one of these objects should exist
 * per-instance per-engine.
 *
 * @author Alex Leigh
 */
public interface AppInstance {
    /**
     * Create a new context within the given application instance.
     */
    AppContext newContext();

    App getApp();

    /**
     * Return a previously stored file from the application instance, or <code>null</code> if the file does not
     * exist in the application instance.
     *
     * @return
     */
    byte[] getBlob(UUID id);

    /**
     * Store a new file in the application instance, and return the UUID of the newly-created file to the caller.
     */
    UUID putBlob(InputStream is, FileStat stat) throws IOException;
}
