using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Sas;
using Core.Blueprint.Storage.Adapters;
namespace Core.Blueprint.Storage.Contracts
{
    /// 
    /// Defines a contract for managing blobs and containers in Azure Blob Storage.
    /// 
    public interface IBlobStorageProvider
    {
        /// 
        /// Creates the blob container if it does not exist.
        /// 
        /// A  containing the container information.
        Task> CreateIfNotExistsAsync();
        /// 
        /// Deletes the blob container if it exists.
        /// 
        Task DeleteIfExistsAsync();
        /// 
        /// Gets properties of the blob container.
        /// 
        /// A  containing container properties.
        Task> GetPropertiesAsync();
        /// 
        /// Sets metadata for the blob container.
        /// 
        /// The metadata to set for the container.
        Task SetMetadataAsync(IDictionary metadata);
        /// 
        /// Uploads a blob to the container.
        /// 
        /// The name of the blob.
        /// The content to upload.
        /// A  containing blob content information.
        Task> UploadBlobAsync(string blobName, Stream content);
        /// 
        /// Downloads a blob from the container.
        /// 
        /// The name of the blob.
        /// A  containing blob download information.
        /// Thrown if the blob does not exist.
        Task> DownloadBlobAsync(string blobName);
        /// 
        /// Deletes a blob from the container.
        /// 
        /// The name of the blob.
        Task DeleteBlobAsync(string blobName);
        /// 
        /// Lists all blobs in the container with an optional prefix.
        /// 
        /// The prefix to filter blobs.
        /// A collection of .
        Task> ListBlobItemAsync(string? prefix = null);
        /// 
        /// Retrieves the account information for the associated Blob Service Client.
        /// 
        /// 
        /// A  that can be used to cancel the operation.
        /// 
        /// 
        /// A task that represents the asynchronous operation. The task result contains the
        ///  object, which provides details about the account, such as the SKU
        /// and account kind.
        Task GetAccountInfoAsync(CancellationToken cancellation);
        /// 
        /// Gets a blob client for a specific blob.
        /// 
        /// The name of the blob.
        /// A  for the blob.
        BlobClient GetBlobClient(string blobName);
        /// 
        /// Lists blobs hierarchically using a delimiter.
        /// 
        /// The prefix to filter blobs.
        /// The delimiter to use for hierarchy.
        /// A collection of .
        Task> ListBlobsByHierarchyAsync(string? prefix = null, string delimiter = "/");
        /// 
        /// Generates a SAS token for the container with specified permissions.
        /// 
        /// The permissions to assign to the SAS token.
        /// The expiration time for the SAS token.
        /// A  containing the SAS token.
        /// Thrown if SAS URI generation is not supported.
        Uri GenerateContainerSasUri(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn);
        /// 
        /// Acquires a lease on the blob container.
        /// 
        /// The optional proposed lease ID.
        /// The optional lease duration.
        /// A  containing lease information.
        Task> AcquireLeaseAsync(string? proposedId = null, TimeSpan? duration = null);
        /// 
        /// Releases a lease on the blob container.
        /// 
        /// The lease ID to release.
        Task ReleaseLeaseAsync(string leaseId);
        /// 
        /// Sets access policies for the blob container.
        /// 
        /// The type of public access to allow.
        /// The optional list of signed identifiers for access policy.
        Task SetAccessPolicyAsync(PublicAccessType accessType, IEnumerable? identifiers = null);
        /// 
        /// Lists blobs in the container with an optional prefix.
        /// 
        /// The prefix to filter blobs.
        /// A collection of .
        Task> ListBlobsAsync(string? prefix = null);
        /// 
        /// Uploads a blob to the container.
        /// 
        /// The blob to upload.
        /// A  representing the uploaded blob.
        Task UploadBlobAsync(BlobAddDto newBlob);
        /// 
        /// Deletes a blob from the container.
        /// 
        /// The name of the blob to delete.
        /// A  representing the deleted blob, or null if the blob was not found.
        Task DeleteBlobsAsync(string fileName);
        /// 
        /// Downloads a blob's content.
        /// 
        /// The name of the blob.
        /// A  representing the downloaded blob.
        /// Thrown if the blob does not exist.
        Task DownloadBlobsAsync(string blobName);
        /// 
        /// Generates a secure download URI for a specified blob in the storage container.
        /// 
        /// The name of the blob for which the download URI is being generated.
        /// 
        /// An instance of  containing the generated URI, blob name, and status.
        /// 
        /// 
        /// The generated URI includes a Shared Access Signature (SAS) token, which allows secure, time-limited access to the blob.
        /// The SAS token grants read-only access to the blob for a duration of 5 minutes starting from the current time.
        /// 
        /// Thrown if  is null or empty.
        /// Thrown if there is an issue communicating with the Azure Blob service.
        BlobDownloadUriAdapter GenerateBlobDownloadUri(string blobName);
        /// 
        /// Retrieves the hierarchical folder structure.
        /// 
        /// The prefix to start the hierarchy retrieval.
        /// A list of  representing the folder structure.
        Task> GetFolderHierarchyAsync(string prefix);
        /// 
        /// Lists neighboring folders based on a prefix.
        /// 
        /// The prefix to search for neighboring folders.
        /// A dictionary grouping folder names by their prefix.
        Task>> ListNeighborFoldersAsync(string? prefix);
    }
}