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

Large diffs are not rendered by default.

46 changes: 35 additions & 11 deletions sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal static PathProperties ToPathProperties(this BlobProperties blobProperti
AccessTierChangedOn = blobProperties.AccessTierChangedOn
};

internal static DataLakeLease ToDataLakeLease(this Blobs.Models.BlobLease blobLease) =>
internal static DataLakeLease ToDataLakeLease(this BlobLease blobLease) =>
new DataLakeLease()
{
ETag = blobLease.ETag,
Expand All @@ -107,16 +107,40 @@ internal static DataLakeLease ToDataLakeLease(this Blobs.Models.BlobLease blobLe
LeaseTime = blobLease.LeaseTime
};

internal static BlobHttpHeaders ToBlobHttpHeaders(this PathHttpHeaders pathHttpHeaders) =>
new BlobHttpHeaders()
{
ContentType = pathHttpHeaders.ContentType,
ContentHash = pathHttpHeaders.ContentHash,
ContentEncoding = new string[] { pathHttpHeaders.ContentEncoding },
ContentLanguage = new string[] { pathHttpHeaders.ContentLanguage },
ContentDisposition = pathHttpHeaders.ContentDisposition,
CacheControl = pathHttpHeaders.CacheControl
};
internal static BlobHttpHeaders ToBlobHttpHeaders(this PathHttpHeaders pathHttpHeaders)
{
if (pathHttpHeaders == null)
{
return null;
}

return new BlobHttpHeaders()
{
ContentType = pathHttpHeaders.ContentType,
ContentHash = pathHttpHeaders.ContentHash,
ContentEncoding = new string[] { pathHttpHeaders.ContentEncoding },
ContentLanguage = new string[] { pathHttpHeaders.ContentLanguage },
ContentDisposition = pathHttpHeaders.ContentDisposition,
CacheControl = pathHttpHeaders.CacheControl
};
}

internal static BlobRequestConditions ToBlobRequestConditions(this DataLakeRequestConditions dataLakeRequestConditions)
{
if (dataLakeRequestConditions == null)
{
return null;
}

return new BlobRequestConditions()
{
IfMatch = dataLakeRequestConditions.IfMatch,
IfNoneMatch = dataLakeRequestConditions.IfNoneMatch,
IfModifiedSince = dataLakeRequestConditions.IfModifiedSince,
IfUnmodifiedSince = dataLakeRequestConditions.IfUnmodifiedSince,
LeaseId = dataLakeRequestConditions.LeaseId
};
}

internal static PathItem ToPathItem(this Dictionary<string, string> dictionary)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
namespace Azure.Storage.Files.DataLake
{
/// <summary>
/// The <see cref="FileClient"/> allows you to manipulate Azure Data Lake files.
/// The <see cref="DataLakeFileClient"/> allows you to manipulate Azure Data Lake files.
/// </summary>
public class FileClient : PathClient
public class DataLakeFileClient : DataLakePathClient
{
/// <summary>
/// The name of the file.
Expand All @@ -36,15 +36,28 @@ public virtual string Name

#region ctors
/// <summary>
/// Initializes a new instance of the <see cref="FileClient"/>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/>
/// class for mocking.
/// </summary>
protected FileClient()
protected DataLakeFileClient()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="FileClient"/> class.
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
/// name of the account, the name of the file system, and the path of the
/// file.
/// </param>
public DataLakeFileClient(Uri fileUri)
: this(fileUri, (HttpPipelinePolicy)null, null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
Expand All @@ -56,13 +69,13 @@ protected FileClient()
/// pipeline policies for authentication, retries, etc., that are
/// applied to every request.
/// </param>
public FileClient(Uri fileUri, DataLakeClientOptions options = default)
public DataLakeFileClient(Uri fileUri, DataLakeClientOptions options)
: this(fileUri, (HttpPipelinePolicy)null, options)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="FileClient"/> class.
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
Expand All @@ -72,18 +85,71 @@ public FileClient(Uri fileUri, DataLakeClientOptions options = default)
/// <param name="credential">
/// The shared key credential used to sign requests.
/// </param>
public DataLakeFileClient(Uri fileUri, StorageSharedKeyCredential credential)
: this(fileUri, credential.AsPolicy(), null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
/// name of the account, the name of the file system, and the path of the
/// file.
/// </param>
/// <param name="credential">
/// The shared key credential used to sign requests.
/// </param>
/// <param name="options">
/// Optional <see cref="DataLakeClientOptions"/> that define the transport
/// pipeline policies for authentication, retries, etc., that are
/// applied to every request.
/// </param>
public DataLakeFileClient(Uri fileUri, StorageSharedKeyCredential credential, DataLakeClientOptions options)
: this(fileUri, credential.AsPolicy(), options)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
/// name of the account, the name of the file system, and the path of the
/// file.
/// </param>
/// <param name="credential">
/// The token credential used to sign requests.
/// </param>
public DataLakeFileClient(Uri fileUri, TokenCredential credential)
: this(fileUri, credential.AsPolicy(), null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
/// name of the account, the name of the file system, and the path of the
/// file.
/// </param>
/// <param name="credential">
/// The token credential used to sign requests.
/// </param>
/// <param name="options">
/// Optional <see cref="DataLakeClientOptions"/> that define the transport
/// pipeline policies for authentication, retries, etc., that are
/// applied to every request.
/// </param>
public FileClient(Uri fileUri, StorageSharedKeyCredential credential, DataLakeClientOptions options = default)
public DataLakeFileClient(Uri fileUri, TokenCredential credential, DataLakeClientOptions options)
: this(fileUri, credential.AsPolicy(), options)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="FileClient"/>
/// Initializes a new instance of the <see cref="DataLakeFileClient"/>
/// class.
/// </summary>
/// <param name="fileUri">
Expand All @@ -99,13 +165,13 @@ public FileClient(Uri fileUri, StorageSharedKeyCredential credential, DataLakeCl
/// policies for authentication, retries, etc., that are applied to
/// every request.
/// </param>
internal FileClient(Uri fileUri, HttpPipelinePolicy authentication, DataLakeClientOptions options)
internal DataLakeFileClient(Uri fileUri, HttpPipelinePolicy authentication, DataLakeClientOptions options)
: base(fileUri, authentication, options)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="FileClient"/> class.
/// Initializes a new instance of the <see cref="DataLakeFileClient"/> class.
/// </summary>
/// <param name="fileUri">
/// A <see cref="Uri"/> referencing the file that includes the
Expand All @@ -114,15 +180,15 @@ internal FileClient(Uri fileUri, HttpPipelinePolicy authentication, DataLakeClie
/// <param name="pipeline">
/// The transport pipeline used to send every request.
/// </param>
internal FileClient(Uri fileUri, HttpPipeline pipeline) : base(fileUri, pipeline)
internal DataLakeFileClient(Uri fileUri, HttpPipeline pipeline) : base(fileUri, pipeline)
{
}
#endregion ctors

/// <summary>
/// Sets the various name fields if they are currently null.
/// </summary>
protected override void SetNameFieldsIfNull()
internal override void SetNameFieldsIfNull()
{
base.SetNameFieldsIfNull();
if (_name == null)
Expand Down Expand Up @@ -178,7 +244,7 @@ protected override void SetNameFieldsIfNull()
/// </remarks>
[ForwardsClientCalls]
public virtual Response<PathInfo> Create(
PathHttpHeaders? httpHeaders = default,
PathHttpHeaders httpHeaders = default,
Metadata metadata = default,
string permissions = default,
string umask = default,
Expand Down Expand Up @@ -238,7 +304,7 @@ public virtual Response<PathInfo> Create(
/// </remarks>
[ForwardsClientCalls]
public virtual async Task<Response<PathInfo>> CreateAsync(
PathHttpHeaders? httpHeaders = default,
PathHttpHeaders httpHeaders = default,
Metadata metadata = default,
string permissions = default,
string umask = default,
Expand Down Expand Up @@ -350,20 +416,20 @@ public virtual async Task<Response> DeleteAsync(
/// a failure occurs.
/// </remarks>
[ForwardsClientCalls]
public new virtual Response<FileClient> Rename(
public new virtual Response<DataLakeFileClient> Rename(
string destinationPath,
DataLakeRequestConditions sourceConditions = default,
DataLakeRequestConditions destinationConditions = default,
CancellationToken cancellationToken = default)
{
Response<PathClient> response = base.Rename(
Response<DataLakePathClient> response = base.Rename(
destinationPath,
sourceConditions,
destinationConditions,
cancellationToken);

return Response.FromValue(
new FileClient(response.Value.DfsUri, response.Value.Pipeline),
new DataLakeFileClient(response.Value.DfsUri, response.Value.Pipeline),
response.GetRawResponse());
}

Expand Down Expand Up @@ -396,21 +462,21 @@ public virtual async Task<Response> DeleteAsync(
/// a failure occurs.
/// </remarks>
[ForwardsClientCalls]
public new virtual async Task<Response<FileClient>> RenameAsync(
public new virtual async Task<Response<DataLakeFileClient>> RenameAsync(
string destinationPath,
DataLakeRequestConditions sourceConditions = default,
DataLakeRequestConditions destinationConditions = default,
CancellationToken cancellationToken = default)
{
Response<PathClient> response = await base.RenameAsync(
Response<DataLakePathClient> response = await base.RenameAsync(
destinationPath,
sourceConditions,
destinationConditions,
cancellationToken)
.ConfigureAwait(false);

return Response.FromValue(
new FileClient(response.Value.DfsUri, response.Value.Pipeline),
new DataLakeFileClient(response.Value.DfsUri, response.Value.Pipeline),
response.GetRawResponse());
}
#endregion Move
Expand Down Expand Up @@ -570,10 +636,10 @@ private async Task<Response> AppendInternal(
bool async,
CancellationToken cancellationToken)
{
using (Pipeline.BeginLoggingScope(nameof(FileClient)))
using (Pipeline.BeginLoggingScope(nameof(DataLakeFileClient)))
{
Pipeline.LogMethodEnter(
nameof(FileClient),
nameof(DataLakeFileClient),
message:
$"{nameof(Uri)}: {Uri}\n" +
$"{nameof(offset)}: {offset}\n" +
Expand Down Expand Up @@ -602,7 +668,7 @@ private async Task<Response> AppendInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(FileClient));
Pipeline.LogMethodExit(nameof(DataLakeFileClient));
}
}
}
Expand Down Expand Up @@ -661,7 +727,7 @@ public virtual Response<PathInfo> Flush(
long position,
bool? retainUncommittedData = default,
bool? close = default,
PathHttpHeaders? httpHeaders = default,
PathHttpHeaders httpHeaders = default,
DataLakeRequestConditions conditions = default,
CancellationToken cancellationToken = default) =>
FlushInternal(
Expand Down Expand Up @@ -726,7 +792,7 @@ public virtual async Task<Response<PathInfo>> FlushAsync(
long position,
bool? retainUncommittedData = default,
bool? close = default,
PathHttpHeaders? httpHeaders = default,
PathHttpHeaders httpHeaders = default,
DataLakeRequestConditions conditions = default,
CancellationToken cancellationToken = default) =>
await FlushInternal(
Expand Down Expand Up @@ -793,15 +859,15 @@ private async Task<Response<PathInfo>> FlushInternal(
long position,
bool? retainUncommittedData,
bool? close,
PathHttpHeaders? httpHeaders,
PathHttpHeaders httpHeaders,
DataLakeRequestConditions conditions,
bool async,
CancellationToken cancellationToken)
{
using (Pipeline.BeginLoggingScope(nameof(FileClient)))
using (Pipeline.BeginLoggingScope(nameof(DataLakeFileClient)))
{
Pipeline.LogMethodEnter(
nameof(FileClient),
nameof(DataLakeFileClient),
message:
$"{nameof(Uri)}: {Uri}");

Expand Down Expand Up @@ -845,7 +911,7 @@ private async Task<Response<PathInfo>> FlushInternal(
}
finally
{
Pipeline.LogMethodExit(nameof(FileClient));
Pipeline.LogMethodExit(nameof(DataLakeFileClient));
}
}
}
Expand Down Expand Up @@ -1013,7 +1079,7 @@ public virtual Response<FileDownloadInfo> Read(
{
Response<Blobs.Models.BlobDownloadInfo> response = _blockBlobClient.Download(
range: range,
conditions: conditions,
conditions: conditions.ToBlobRequestConditions(),
rangeGetContentHash: rangeGetContentHash,
cancellationToken: cancellationToken);

Expand Down Expand Up @@ -1066,7 +1132,7 @@ public virtual async Task<Response<FileDownloadInfo>> ReadAsync(
{
Response<Blobs.Models.BlobDownloadInfo> response = await _blockBlobClient.DownloadAsync(
range: range,
conditions: conditions,
conditions: conditions.ToBlobRequestConditions(),
rangeGetContentHash: rangeGetContentHash,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
Expand Down
Loading