package simplecloud.storage.interfaces;

import java.util.List;
import java.util.Map;

import base.interfaces.IItem;

/**
 * Common interface to all Storage providers.
 */
public interface IStorageAdapter {
	
	/**
	 * Fetches an item from the storage provider.
	 * 
	 * @param path is the path to the item to fetch
	 * @param options are provider-specific options for fetching the item
	 * @return IItem is the item fetched from the server
	 */
	public IItem fetchItem(String path, Map<Object, Object> options);
	
	/**
	 * Stores an item with the storage provider.
	 * 
	 * @param destinationPath is the path to store the item at
	 * @param item is the content to store on the provider
	 * @param metadata is metadata to associate with the item
	 * @param options are provider-specific options for storing the item
	 * @return true if the item was stored successfully, false otherwise
	 */
	public boolean storeItem(String destinationPath, IItem item, Map<String, String> metadata, Map<Object, Object> options);
	
	/**
	 * Deletes an item from the storage provider.
	 * 
	 * @param path is the path to the item to delete
	 * @param options are provider-specific options for deleting the item
	 */
	public void deleteItem(String path, Map<Object, Object> options);
	
	/**
	 * Copies an item from one location to another location.
	 * 
	 * @param sourcePath is the path to the item to copy
	 * @param destinationPath is the destination path for the item's copy
	 * @param options are provider-specific options for copying the item
	 */
	public void copyItem(String sourcePath, String destinationPath, Map<Object, Object> options);
	
	/**
	 * Moves an item from one location to another location.
	 * 
	 * @param sourcePath is the path to the item to move
	 * @param destinationPath is the item's new destination
	 * @param options are provider specific-options for moving the item
	 */
	public void moveItem(String sourcePath, String destinationPath, Map<Object, Object> options);
	
	/**
	 * Renames an item.
	 * 
	 * @param path is the path to the item to rename
	 * @param name is the new name of the item
	 * @param options are provider-specific options for renaming the item
	 */
	public void renameItem(String path, String name, Map<Object, Object> options);

	/**
	 * Lists the items at the given path.
	 * 
	 * @param path identifies the directory to list the contents of
	 * @param options are provider-specific options for listing the contents
	 * @return List<String> is a list of the items at the given path
	 */
	public List<String> listItems(String path, Map<Object, Object> options);
	
	/**
	 * Fetches the metadata of an item.
	 * 
	 * @param path identifies the item to fetch the metadata for
	 * @param options are provider-specific options for fetching the metadata
	 * @return Map<String, String> are key/value pairs composing the item's metadata
	 */
	public Map<String, String> fetchMetadata(String path, Map<Object, Object> options);
	
	/**
	 * Stores metadata for an item.
	 * 
	 * @param destinationPath identifies the item to associate with the metadata
	 * @param metadata are the key/value pairs composing the item's metadata
	 * @param options are provider-specific options for storing the metadata
	 */
	public void storeMetadata(String destinationPath, Map<String, String> metadata, Map<Object, Object> options);
	
	/**
	 * Deletes metadata associated with an item.
	 * 
	 * @param path identifies the item to delete the metadata from
	 * @param options are provider-specific options for deleting the metadata
	 */
	public void deleteMetadata(String path, Map<Object, Object> options);
}
