Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace Azure.Storage.Blobs.Specialized
{
/// <summary>
/// The <see cref="LeaseClient"/> allows you to manipulate Azure
/// The <see cref="BlobLeaseClient"/> allows you to manipulate Azure
/// Storage leases on containers and blobs.
/// </summary>
public class LeaseClient
public class BlobLeaseClient
{
/// <summary>
/// The <see cref="BlobClient"/> to manage leases for.
Expand Down Expand Up @@ -65,17 +65,17 @@ public class LeaseClient
public static readonly TimeSpan InfiniteLeaseDuration = TimeSpan.FromSeconds(Constants.Blob.Lease.InfiniteLeaseDuration);

/// <summary>
/// Initializes a new instance of the <see cref="LeaseClient"/> class
/// Initializes a new instance of the <see cref="BlobLeaseClient"/> class
/// for mocking.
/// </summary>
protected LeaseClient()
protected BlobLeaseClient()
{
_blob = null;
_container = null;
}

/// <summary>
/// Initializes a new instance of the <see cref="LeaseClient"/> class.
/// Initializes a new instance of the <see cref="BlobLeaseClient"/> class.
/// </summary>
/// <param name="client">
/// A <see cref="BlobClient"/> representing the blob being leased.
Expand All @@ -84,15 +84,15 @@ protected LeaseClient()
/// An optional lease ID. If no lease ID is provided, a random lease
/// ID will be created.
/// </param>
public LeaseClient(BlobBaseClient client, string leaseId = null)
public BlobLeaseClient(BlobBaseClient client, string leaseId = null)
{
_blob = client ?? throw Errors.ArgumentNull(nameof(client));
_container = null;
LeaseId = leaseId ?? CreateUniqueLeaseId();
}

/// <summary>
/// Initializes a new instance of the <see cref="LeaseClient"/> class.
/// Initializes a new instance of the <see cref="BlobLeaseClient"/> class.
/// </summary>
/// <param name="client">
/// A <see cref="BlobContainerClient"/> representing the blob container
Expand All @@ -102,7 +102,7 @@ public LeaseClient(BlobBaseClient client, string leaseId = null)
/// An optional lease ID. If no lease ID is provided, a random lease
/// ID will be created.
/// </param>
public LeaseClient(BlobContainerClient client, string leaseId = null)
public BlobLeaseClient(BlobContainerClient client, string leaseId = null)
{
_blob = null;
_container = client ?? throw Errors.ArgumentNull(nameof(client));
Expand All @@ -123,7 +123,7 @@ private void EnsureClient()
if (BlobClient == null && BlobContainerClient == null)
{
// This can only happen if someone's not being careful while mocking
throw BlobErrors.BlobOrContainerMissing(nameof(LeaseClient), nameof(BlobBaseClient), nameof(BlobContainerClient));
throw BlobErrors.BlobOrContainerMissing(nameof(BlobLeaseClient), nameof(BlobBaseClient), nameof(BlobContainerClient));
}
}

Expand Down Expand Up @@ -264,10 +264,10 @@ private async Task<Response<BlobLease>> AcquireInternal(
EnsureClient();
// Int64 is an overflow safe cast relative to TimeSpan.MaxValue
var serviceDuration = duration < TimeSpan.Zero ? Constants.Blob.Lease.InfiniteLeaseDuration : Convert.ToInt64(duration.TotalSeconds);
using (Pipeline.BeginLoggingScope(nameof(LeaseClient)))
using (Pipeline.BeginLoggingScope(nameof(BlobLeaseClient)))
{
Pipeline.LogMethodEnter(
nameof(LeaseClient),
nameof(BlobLeaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(LeaseId)}: {LeaseId}\n" +
Expand Down Expand Up @@ -320,7 +320,7 @@ private async Task<Response<BlobLease>> AcquireInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(LeaseClient));
Pipeline.LogMethodExit(nameof(BlobLeaseClient));
}
}
}
Expand Down Expand Up @@ -434,10 +434,10 @@ private async Task<Response<BlobLease>> RenewInternal(
bool async,
CancellationToken cancellationToken)
{
using (Pipeline.BeginLoggingScope(nameof(LeaseClient)))
using (Pipeline.BeginLoggingScope(nameof(BlobLeaseClient)))
{
Pipeline.LogMethodEnter(
nameof(LeaseClient),
nameof(BlobLeaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(LeaseId)}: {LeaseId}\n" +
Expand Down Expand Up @@ -488,7 +488,7 @@ private async Task<Response<BlobLease>> RenewInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(LeaseClient));
Pipeline.LogMethodExit(nameof(BlobLeaseClient));
}
}
}
Expand Down Expand Up @@ -603,10 +603,10 @@ public virtual async Task<Response<ReleasedObjectInfo>> ReleaseInternal(
CancellationToken cancellationToken)
{
EnsureClient();
using (Pipeline.BeginLoggingScope(nameof(LeaseClient)))
using (Pipeline.BeginLoggingScope(nameof(BlobLeaseClient)))
{
Pipeline.LogMethodEnter(
nameof(LeaseClient),
nameof(BlobLeaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(LeaseId)}: {LeaseId}\n" +
Expand Down Expand Up @@ -661,7 +661,7 @@ await BlobRestClient.Container.ReleaseLeaseAsync(
}
finally
{
Pipeline.LogMethodExit(nameof(LeaseClient));
Pipeline.LogMethodExit(nameof(BlobLeaseClient));
}
}
}
Expand Down Expand Up @@ -781,10 +781,10 @@ private async Task<Response<BlobLease>> ChangeInternal(
CancellationToken cancellationToken)
{
EnsureClient();
using (Pipeline.BeginLoggingScope(nameof(LeaseClient)))
using (Pipeline.BeginLoggingScope(nameof(BlobLeaseClient)))
{
Pipeline.LogMethodEnter(
nameof(LeaseClient),
nameof(BlobLeaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(LeaseId)}: {LeaseId}\n" +
Expand Down Expand Up @@ -838,7 +838,7 @@ private async Task<Response<BlobLease>> ChangeInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(LeaseClient));
Pipeline.LogMethodExit(nameof(BlobLeaseClient));
}
}
}
Expand Down Expand Up @@ -1013,10 +1013,10 @@ private async Task<Response<BlobLease>> BreakInternal(
{
EnsureClient();
long? serviceBreakPeriod = breakPeriod != null ? Convert.ToInt64(breakPeriod.Value.TotalSeconds) : (long?) null;
using (Pipeline.BeginLoggingScope(nameof(LeaseClient)))
using (Pipeline.BeginLoggingScope(nameof(BlobLeaseClient)))
{
Pipeline.LogMethodEnter(
nameof(LeaseClient),
nameof(BlobLeaseClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(breakPeriod)}: {breakPeriod}\n" +
Expand Down Expand Up @@ -1069,7 +1069,7 @@ private async Task<Response<BlobLease>> BreakInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(LeaseClient));
Pipeline.LogMethodExit(nameof(BlobLeaseClient));
}
}
}
Expand All @@ -1078,13 +1078,13 @@ private async Task<Response<BlobLease>> BreakInternal(

/// <summary>
/// Add easy to discover methods to <see cref="BlobContainerClient"/> and
/// <see cref="BlobClient"/> for easily creating <see cref="LeaseClient"/>
/// <see cref="BlobClient"/> for easily creating <see cref="BlobLeaseClient"/>
/// instances.
/// </summary>
public static partial class SpecializedBlobExtensions
{
/// <summary>
/// Initializes a new instance of the <see cref="LeaseClient"/> class.
/// Initializes a new instance of the <see cref="BlobLeaseClient"/> class.
/// </summary>
/// <param name="client">
/// A <see cref="BlobClient"/> representing the blob being leased.
Expand All @@ -1093,13 +1093,13 @@ public static partial class SpecializedBlobExtensions
/// An optional lease ID. If no lease ID is provided, a random lease
/// ID will be created.
/// </param>
public static LeaseClient GetLeaseClient(
public static BlobLeaseClient GetBlobLeaseClient(
this BlobBaseClient client,
string leaseId = null) =>
new LeaseClient(client, leaseId);
new BlobLeaseClient(client, leaseId);

/// <summary>
/// Initializes a new instance of the <see cref="LeaseClient"/> class.
/// Initializes a new instance of the <see cref="BlobLeaseClient"/> class.
/// </summary>
/// <param name="client">
/// A <see cref="BlobContainerClient"/> representing the container
Expand All @@ -1109,9 +1109,9 @@ public static LeaseClient GetLeaseClient(
/// An optional lease ID. If no lease ID is provided, a random lease
/// ID will be created.
/// </param>
public static LeaseClient GetLeaseClient(
public static BlobLeaseClient GetBlobLeaseClient(
this BlobContainerClient client,
string leaseId = null) =>
new LeaseClient(client, leaseId);
new BlobLeaseClient(client, leaseId);
}
}
Loading