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
70 changes: 26 additions & 44 deletions sdk/storage/Azure.Storage.Files/src/DirectoryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,28 @@ internal DirectoryClient(Uri directoryUri, HttpPipeline pipeline, ClientDiagnost
}
#endregion ctors

/// <summary>
/// Initializes a new instance of the <see cref="DirectoryClient"/>
/// class with an identical <see cref="Uri"/> source but the specified
/// <paramref name="snapshot"/> timestamp.
///
/// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-share"/>.
/// </summary>
/// <remarks>
/// Pass null or empty string to remove the snapshot returning a URL to the base directory.
/// </remarks>
/// <param name="snapshot">
/// The snapshot identifier.
/// </param>
/// <returns>
/// A new <see cref="DirectoryClient"/> instance.
/// </returns>
public virtual DirectoryClient WithSnapshot(string snapshot)
{
var p = new FileUriBuilder(Uri) { Snapshot = snapshot };
return new DirectoryClient(p.ToUri(), Pipeline, ClientDiagnostics);
}

/// <summary>
/// Creates a new <see cref="FileClient"/> object by appending
/// <paramref name="fileName"/> to the end of <see cref="Uri"/>. The
Expand Down Expand Up @@ -578,11 +600,6 @@ private async Task<Response> DeleteInternal(
///
/// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties"/>.
/// </summary>
/// <param name="shareSnapshot">
/// Optionally specifies the share snapshot to retrieve the directory properties
/// from. For more information on working with share snapshots, see
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-share"/>.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -596,10 +613,8 @@ private async Task<Response> DeleteInternal(
/// a failure occurs.
/// </remarks>
public virtual Response<StorageDirectoryProperties> GetProperties(
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
GetPropertiesInternal(
shareSnapshot,
false, // async
cancellationToken)
.EnsureCompleted();
Expand All @@ -612,11 +627,6 @@ public virtual Response<StorageDirectoryProperties> GetProperties(
///
/// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties"/>.
/// </summary>
/// <param name="shareSnapshot">
/// Optionally specifies the share snapshot to retrieve the directory properties
/// from. For more information on working with share snapshots, see
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-share"/>.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -630,10 +640,8 @@ public virtual Response<StorageDirectoryProperties> GetProperties(
/// a failure occurs.
/// </remarks>
public virtual async Task<Response<StorageDirectoryProperties>> GetPropertiesAsync(
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
await GetPropertiesInternal(
shareSnapshot,
true, // async
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -646,11 +654,6 @@ await GetPropertiesInternal(
///
/// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties"/>.
/// </summary>
/// <param name="shareSnapshot">
/// Optionally specifies the share snapshot to retrieve the directory properties
/// from. For more information on working with share snapshots, see
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-share"/>.
/// </param>
/// <param name="async">
/// Whether to invoke the operation asynchronously.
/// </param>
Expand All @@ -667,7 +670,6 @@ await GetPropertiesInternal(
/// a failure occurs.
/// </remarks>
private async Task<Response<StorageDirectoryProperties>> GetPropertiesInternal(
string shareSnapshot,
bool async,
CancellationToken cancellationToken)
{
Expand All @@ -676,15 +678,13 @@ private async Task<Response<StorageDirectoryProperties>> GetPropertiesInternal(
Pipeline.LogMethodEnter(
nameof(DirectoryClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(shareSnapshot)}: {shareSnapshot}");
$"{nameof(Uri)}: {Uri}");
try
{
Response<RawStorageDirectoryProperties> response = await FileRestClient.Directory.GetPropertiesAsync(
ClientDiagnostics,
Pipeline,
Uri,
sharesnapshot: shareSnapshot,
Comment thread
seanmcc-msft marked this conversation as resolved.
async: async,
operationName: Constants.File.Directory.GetPropertiesOperationName,
cancellationToken: cancellationToken)
Expand Down Expand Up @@ -987,9 +987,6 @@ private async Task<Response<StorageDirectoryInfo>> SetMetadataInternal(
/// Optional string that filters the results to return only
/// files and directories whose name begins with the specified prefix.
/// </param>
/// <param name="shareSnapshot">
/// Optional share snapshot to query.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -1004,9 +1001,8 @@ private async Task<Response<StorageDirectoryInfo>> SetMetadataInternal(
/// </remarks>
public virtual Pageable<StorageFileItem> GetFilesAndDirectories(
string prefix = default,
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
new GetFilesAndDirectoriesAsyncCollection(this, prefix, shareSnapshot).ToSyncCollection(cancellationToken);
new GetFilesAndDirectoriesAsyncCollection(this, prefix).ToSyncCollection(cancellationToken);

/// <summary>
/// The <see cref="GetFilesAndDirectoriesAsync"/> operation returns an
Expand All @@ -1020,9 +1016,6 @@ public virtual Pageable<StorageFileItem> GetFilesAndDirectories(
/// Optional string that filters the results to return only
/// files and directories whose name begins with the specified prefix.
/// </param>
/// <param name="shareSnapshot">
/// Optional share snapshot to query.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -1037,9 +1030,8 @@ public virtual Pageable<StorageFileItem> GetFilesAndDirectories(
/// </remarks>
public virtual AsyncPageable<StorageFileItem> GetFilesAndDirectoriesAsync(
string prefix = default,
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
new GetFilesAndDirectoriesAsyncCollection(this, prefix, shareSnapshot).ToAsyncCollection(cancellationToken);
new GetFilesAndDirectoriesAsyncCollection(this, prefix).ToAsyncCollection(cancellationToken);

/// <summary>
/// The <see cref="GetFilesAndDirectoriesInternal"/> operation returns a
Expand All @@ -1061,9 +1053,6 @@ public virtual AsyncPageable<StorageFileItem> GetFilesAndDirectoriesAsync(
/// Optional string that filters the results to return only
/// files and directories whose name begins with the specified prefix.
/// </param>
/// <param name="shareSnapshot">
/// Optional share snapshot to query.
/// </param>
/// <param name="pageSizeHint">
/// Gets or sets a value indicating the size of the page that should be
/// requested.
Expand All @@ -1086,7 +1075,6 @@ public virtual AsyncPageable<StorageFileItem> GetFilesAndDirectoriesAsync(
internal async Task<Response<FilesAndDirectoriesSegment>> GetFilesAndDirectoriesInternal(
string marker,
string prefix,
string shareSnapshot,
int? pageSizeHint,
bool async,
CancellationToken cancellationToken)
Expand All @@ -1098,8 +1086,7 @@ internal async Task<Response<FilesAndDirectoriesSegment>> GetFilesAndDirectories
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(marker)}: {marker}\n" +
$"{nameof(prefix)}: {prefix}\n" +
$"{nameof(shareSnapshot)}: {shareSnapshot}");
$"{nameof(prefix)}: {prefix}");
try
{
return await FileRestClient.Directory.ListFilesAndDirectoriesSegmentAsync(
Expand All @@ -1109,7 +1096,6 @@ internal async Task<Response<FilesAndDirectoriesSegment>> GetFilesAndDirectories
marker: marker,
prefix: prefix,
maxresults: pageSizeHint,
sharesnapshot: shareSnapshot,
Comment thread
seanmcc-msft marked this conversation as resolved.
async: async,
operationName: Constants.File.Directory.ListFilesAndDirectoriesSegmentOperationName,
cancellationToken: cancellationToken)
Expand Down Expand Up @@ -1228,8 +1214,6 @@ internal async Task<Response<StorageHandlesSegment>> GetHandlesInternal(
bool async,
CancellationToken cancellationToken)
{
// TODO Support share snapshot

using (Pipeline.BeginLoggingScope(nameof(DirectoryClient)))
{
Pipeline.LogMethodEnter(
Expand Down Expand Up @@ -1529,8 +1513,6 @@ private async Task<Response<StorageClosedHandlesSegment>> ForceCloseHandlesInter
CancellationToken cancellationToken,
string operationName = Constants.File.Directory.ForceCloseAllHandlesOperationName)
{
// TODO Support share snapshot

using (Pipeline.BeginLoggingScope(nameof(DirectoryClient)))
{
Pipeline.LogMethodEnter(
Expand Down
36 changes: 2 additions & 34 deletions sdk/storage/Azure.Storage.Files/src/FileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,6 @@ private async Task<Response> DeleteInternal(
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/get-file-properties"/>
/// </summary>
/// <param name="shareSnapshot">
/// Optional. The snapshot identifier.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -1142,10 +1139,8 @@ private async Task<Response> DeleteInternal(
/// a failure occurs.
/// </remarks>
public virtual Response<StorageFileProperties> GetProperties(
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
GetPropertiesInternal(
shareSnapshot,
false, // async
cancellationToken)
.EnsureCompleted();
Expand All @@ -1158,9 +1153,6 @@ public virtual Response<StorageFileProperties> GetProperties(
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/get-file-properties"/>
/// </summary>
/// <param name="shareSnapshot">
/// Optional. The snapshot identifier.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -1174,10 +1166,8 @@ public virtual Response<StorageFileProperties> GetProperties(
/// a failure occurs.
/// </remarks>
public virtual async Task<Response<StorageFileProperties>> GetPropertiesAsync(
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
await GetPropertiesInternal(
shareSnapshot,
true, // async
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -1190,9 +1180,6 @@ await GetPropertiesInternal(
///
/// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/get-file-properties"/>
/// </summary>
/// <param name="shareSnapshot">
/// Optional. The snapshot identifier.
/// </param>
/// <param name="async">
/// Whether to invoke the operation asynchronously.
/// </param>
Expand All @@ -1209,7 +1196,6 @@ await GetPropertiesInternal(
/// a failure occurs.
/// </remarks>
private async Task<Response<StorageFileProperties>> GetPropertiesInternal(
string shareSnapshot,
bool async,
CancellationToken cancellationToken)
{
Expand All @@ -1218,15 +1204,13 @@ private async Task<Response<StorageFileProperties>> GetPropertiesInternal(
Pipeline.LogMethodEnter(
nameof(FileClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(shareSnapshot)}: {shareSnapshot}");
$"{nameof(Uri)}: {Uri}");
try
{
Response<RawStorageFileProperties> response = await FileRestClient.File.GetPropertiesAsync(
ClientDiagnostics,
Pipeline,
Uri,
sharesnapshot: shareSnapshot,
Comment thread
seanmcc-msft marked this conversation as resolved.
async: async,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
Expand Down Expand Up @@ -2138,9 +2122,6 @@ await content.ReadAsync(segment.Array, 0, singleRangeThreshold, cancellationToke
/// <param name="range">
/// Optional. Specifies the range of bytes over which to list ranges, inclusively. If omitted, then all ranges for the file are returned.
/// </param>
/// <param name="shareSnapshot">
/// Optional. Specifies the share snapshot to query.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -2155,11 +2136,9 @@ await content.ReadAsync(segment.Array, 0, singleRangeThreshold, cancellationToke
/// </remarks>
public virtual Response<StorageFileRangeInfo> GetRangeList(
HttpRange range,
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
GetRangeListInternal(
range,
shareSnapshot,
false, // async
cancellationToken)
.EnsureCompleted();
Expand All @@ -2172,9 +2151,6 @@ public virtual Response<StorageFileRangeInfo> GetRangeList(
/// <param name="range">
/// Optional. Specifies the range of bytes over which to list ranges, inclusively. If omitted, then all ranges for the file are returned.
/// </param>
/// <param name="shareSnapshot">
/// Optional. Specifies the share snapshot to query.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
Expand All @@ -2189,11 +2165,9 @@ public virtual Response<StorageFileRangeInfo> GetRangeList(
/// </remarks>
public virtual async Task<Response<StorageFileRangeInfo>> GetRangeListAsync(
HttpRange range,
string shareSnapshot = default,
CancellationToken cancellationToken = default) =>
await GetRangeListInternal(
range,
shareSnapshot,
true, // async
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -2206,9 +2180,6 @@ await GetRangeListInternal(
/// <param name="range">
/// Optional. Specifies the range of bytes over which to list ranges, inclusively. If omitted, then all ranges for the file are returned.
/// </param>
/// <param name="shareSnapshot">
/// Optional. Specifies the share snapshot to query.
/// </param>
/// <param name="async">
/// Whether to invoke the operation asynchronously.
/// </param>
Expand All @@ -2226,7 +2197,6 @@ await GetRangeListInternal(
/// </remarks>
private async Task<Response<StorageFileRangeInfo>> GetRangeListInternal(
HttpRange range,
string shareSnapshot,
bool async,
CancellationToken cancellationToken)
{
Expand All @@ -2235,15 +2205,13 @@ private async Task<Response<StorageFileRangeInfo>> GetRangeListInternal(
Pipeline.LogMethodEnter(
nameof(FileClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(shareSnapshot)}: {shareSnapshot}");
$"{nameof(Uri)}: {Uri}");
try
{
return await FileRestClient.File.GetRangeListAsync(
ClientDiagnostics,
Pipeline,
Uri,
sharesnapshot: shareSnapshot,
Comment thread
seanmcc-msft marked this conversation as resolved.
range: range.ToString(),
async: async,
cancellationToken: cancellationToken)
Expand Down
Loading