/// <summary> /// List and get all blobs matching the provided blob name prefix. /// </summary> /// <remarks> /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para> /// </remarks> public static IEnumerable <T> ListBlobs <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> locationPrefix, int skip = 0, IDataSerializer serializer = null) { return(provider.ListBlobs <T>(locationPrefix.ContainerName, locationPrefix.Path, skip, serializer)); }
/// <summary> /// Inserts or updates a blob depending on whether it already exists or not. /// If the insert or update lambdas return empty, the blob will be deleted (if it exists). /// </summary> /// <remarks> /// <para> /// The provided lambdas can be executed multiple times in case of /// concurrency-related retrials, so be careful with side-effects /// (like incrementing a counter in them). /// </para> /// <para> /// This method is idempotent if and only if the provided lambdas are idempotent /// and if the object returned by the insert lambda is an invariant to the update lambda /// (if the second condition is not met, it is idempotent after the first successful call). /// </para> /// </remarks> /// <returns>The value returned by the lambda. If empty, then the blob has been deleted.</returns> public static Maybe <T> UpsertBlobOrDelete <T>( this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <Maybe <T> > insert, Func <T, Maybe <T> > update, IDataSerializer serializer = null) { return(provider.UpsertBlobOrDelete(location.ContainerName, location.Path, insert, update, serializer)); }
/// <summary> /// List the blob locations (with the provided type) of all blobs matching the provided blob name prefix. /// </summary> /// <remarks> /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para> /// </remarks> public static IEnumerable <IBlobLocationAndType <T> > ListBlobLocations <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> blobLocationPrefix) { return(provider.ListBlobNames(blobLocationPrefix.ContainerName, blobLocationPrefix.Path) .Select(name => new BlobLocationAndType <T>(blobLocationPrefix.ContainerName, name))); }
/// <summary> /// Updates a blob if it already exists. /// If the insert or update lambdas return empty, the blob will not be changed. /// </summary> /// <remarks> /// <para> /// The provided lambdas can be executed multiple times in case of /// concurrency-related retrials, so be careful with side-effects /// (like incrementing a counter in them). /// </para> /// <para>This method is idempotent if and only if the provided lambdas are idempotent.</para> /// </remarks> /// <returns>The value returned by the lambda, or empty if the blob did not exist or no change was applied.</returns> public static Maybe <T> UpdateBlobIfExistOrSkip <T>( this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T, Maybe <T> > update, IDataSerializer serializer = null) { return(provider.UpsertBlobOrSkip(location.ContainerName, location.Path, () => Maybe <T> .Empty, update, serializer)); }
/// <summary> /// Inserts or updates a blob depending on whether it already exists or not. /// </summary> /// <remarks> /// <para> /// The provided lambdas can be executed multiple times in case of /// concurrency-related retrials, so be careful with side-effects /// (like incrementing a counter in them). /// </para> /// <para> /// This method is idempotent if and only if the provided lambdas are idempotent /// and if the object returned by the insert lambda is an invariant to the update lambda /// (if the second condition is not met, it is idempotent after the first successful call). /// </para> /// </remarks> /// <returns>The value returned by the lambda.</returns> public static T UpsertBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T> insert, Func <T, T> update, IDataSerializer serializer = null) { return(provider.UpsertBlobOrSkip <T>(location.ContainerName, location.Path, () => insert(), t => update(t), serializer).Value); }
public static void PutBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, IDataSerializer serializer = null) { provider.PutBlob(location.ContainerName, location.Path, item, serializer); }
/// <summary>Push the blob only if etag is matching the etag of the blob in BlobStorage</summary> public static bool PutBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, string etag, IDataSerializer serializer = null) { return(provider.PutBlob(location.ContainerName, location.Path, item, etag, serializer)); }
public static Task <BlobWithETag <T> > GetBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, IDataSerializer serializer = null) { return(provider.GetBlobAsync <T>(location.ContainerName, location.Path, CancellationToken.None, serializer)); }
public static Maybe <T> GetBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, out string etag, IDataSerializer serializer = null) { return(provider.GetBlob <T>(location.ContainerName, location.Path, out etag, serializer)); }
public static Task <BlobWithETag <T> > UpdateBlobIfExistAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T, T> update, IDataSerializer serializer = null) { return(provider.UpsertBlobOrSkipAsync(location.ContainerName, location.Path, () => Maybe <T> .Empty, t => update(t), CancellationToken.None, serializer)); }
public static Task <BlobWithETag <T> > UpdateBlobIfExistOrDeleteAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T, Maybe <T> > update, IDataSerializer serializer = null) { return(provider.UpdateBlobIfExistOrDeleteAsync(location.ContainerName, location.Path, update, CancellationToken.None, serializer)); }
public static Task <BlobWithETag <T> > UpsertBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T> insert, Func <T, T> update, CancellationToken cancellationToken, IDataSerializer serializer = null) { return(provider.UpsertBlobOrSkipAsync <T>(location.ContainerName, location.Path, () => insert(), t => update(t), cancellationToken, serializer)); }
public static Task <string> PutBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, string expectedEtag, IDataSerializer serializer = null) { return(provider.PutBlobAsync(location.ContainerName, location.Path, item, typeof(T), true, expectedEtag, CancellationToken.None, serializer)); }
public static Task <string> PutBlobAsync <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, bool overwrite, CancellationToken cancellationToken, IDataSerializer serializer = null) { return(provider.PutBlobAsync(location.ContainerName, location.Path, item, typeof(T), overwrite, null, cancellationToken, serializer)); }
/// <summary>Push the blob only if etag is matching the etag of the blob in BlobStorage</summary> public static bool PutBlobStream(this IBlobStorageProvider provider, IBlobLocationAndType <Stream> location, Stream stream, string etag) { return(provider.PutBlobStream(location.ContainerName, location.Path, stream, etag)); }
public static void PutBlobStream(this IBlobStorageProvider provider, IBlobLocationAndType <Stream> location, Stream stream) { provider.PutBlobStream(location.ContainerName, location.Path, stream); }