< Summary

Class:Azure.Storage.Files.DataLake.DataLakePathClient
Assembly:Azure.Storage.Files.DataLake
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.DataLake\src\DataLakePathClient.cs
Covered lines:627
Uncovered lines:33
Coverable lines:660
Total lines:2693
Line coverage:95% (627 of 660)
Covered branches:103
Total branches:104
Branch coverage:99% (103 of 104)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_BlobClient()-100%100%
get_BlobUri()-100%100%
get_DfsUri()-100%100%
get_Uri()-100%100%
get_Pipeline()-100%100%
get_Version()-100%100%
get_ClientDiagnostics()-100%100%
get_AccountName()-100%100%
get_FileSystemName()-100%100%
get_Path()-100%100%
get_Name()-100%100%
.ctor()-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-66.67%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
Create(...)-100%100%
BuildMetadataString(...)-100%100%
SetNameFieldsIfNull()-100%100%
Create(...)-100%100%
CreateAsync()-100%100%
CreateInternal()-100%100%
CreateIfNotExists(...)-100%100%
CreateIfNotExistsAsync()-100%100%
CreateIfNotExistsInternal()-100%100%
Exists(...)-100%100%
ExistsAsync()-100%100%
Delete(...)-100%100%
DeleteAsync()-100%100%
DeleteInternal()-100%100%
DeleteIfExists(...)-100%100%
DeleteIfExistsAsync()-100%100%
DeleteIfExistsInternal()-100%100%
Rename(...)-93.75%100%
RenameAsync()-100%100%
RenameInternal()-100%96.43%
GetAccessControl(...)-100%100%
GetAccessControlAsync()-100%100%
GetAccessControlInternal()-100%100%
SetAccessControlList(...)-0%100%
SetAccessControlListAsync()-100%100%
SetAccessControlListInternal()-100%100%
SetPermissions(...)-81.25%100%
SetPermissionsAsync()-100%100%
SetPermissionsInternal()-100%100%
GetProperties(...)-100%100%
GetPropertiesAsync()-100%100%
SetHttpHeaders(...)-73.33%100%
SetHttpHeadersAsync()-100%100%
SetMetadata(...)-71.43%100%
SetMetadataAsync()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.DataLake\src\DataLakePathClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Text;
 7using System.Threading;
 8using System.Threading.Tasks;
 9using Azure.Core;
 10using Azure.Core.Pipeline;
 11using Azure.Storage.Blobs;
 12using Azure.Storage.Blobs.Specialized;
 13using Azure.Storage.Files.DataLake.Models;
 14using Azure.Storage.Sas;
 15using Azure.Storage.Shared;
 16using Metadata = System.Collections.Generic.IDictionary<string, string>;
 17
 18namespace Azure.Storage.Files.DataLake
 19{
 20    /// <summary>
 21    /// A PathClient represents a URI to the Azure DataLake service allowing you to manipulate a file or directory.
 22    /// </summary>
 23    public class DataLakePathClient
 24    {
 25        /// <summary>
 26        /// A <see cref="BlockBlobClient"/> associated with the path;
 27        /// </summary>
 28        internal readonly BlockBlobClient _blockBlobClient;
 29
 30        /// <summary>
 31        /// BlobClient
 32        /// </summary>
 54833        internal virtual BlockBlobClient BlobClient => _blockBlobClient;
 34
 35        /// <summary>
 36        /// The paths's primary <see cref="Uri"/> endpoint.
 37        /// </summary>
 38        private readonly Uri _uri;
 39
 40        /// <summary>
 41        /// The paths's blob <see cref="Uri"/> endpoint.
 42        /// </summary>
 43        private readonly Uri _blobUri;
 44
 45        /// <summary>
 46        /// The paths's blob <see cref="Uri"/> endpoint.
 47        /// </summary>
 13648        internal virtual Uri BlobUri => _blobUri;
 49
 50        /// <summary>
 51        /// The path's dfs <see cref="Uri"/> endpoint.
 52        /// </summary>
 53        private readonly Uri _dfsUri;
 54
 55        /// <summary>
 56        /// DFS Uri
 57        /// </summary>
 107258        internal virtual Uri DfsUri => _dfsUri;
 59
 60        /// <summary>
 61        /// Gets the directory's primary <see cref="Uri"/> endpoint.
 62        /// </summary>
 169263        public virtual Uri Uri => _uri;
 64
 65        /// <summary>
 66        /// The <see cref="HttpPipeline"/> transport pipeline used to send
 67        /// every request.
 68        /// </summary>
 69        private readonly HttpPipeline _pipeline;
 70
 71        /// <summary>
 72        /// Gets the <see cref="HttpPipeline"/> transport pipeline used to send
 73        /// every request.
 74        /// </summary>
 988075        internal virtual HttpPipeline Pipeline => _pipeline;
 76
 77        /// <summary>
 78        /// The version of the service to use when sending requests.
 79        /// </summary>
 80        private readonly DataLakeClientOptions.ServiceVersion _version;
 81
 82        /// <summary>
 83        /// The version of the service to use when sending requests.
 84        /// </summary>
 966485        internal virtual DataLakeClientOptions.ServiceVersion Version => _version;
 86
 87        /// <summary>
 88        /// The <see cref="ClientDiagnostics"/> instance used to create diagnostic scopes
 89        /// every request.
 90        /// </summary>
 91        private readonly ClientDiagnostics _clientDiagnostics;
 92
 93        /// <summary>
 94        /// The <see cref="ClientDiagnostics"/> instance used to create diagnostic scopes
 95        /// every request.
 96        /// </summary>
 1173697        internal virtual ClientDiagnostics ClientDiagnostics => _clientDiagnostics;
 98
 99        /// <summary>
 100        /// The Storage account name corresponding to the directory client.
 101        /// </summary>
 102        private string _accountName;
 103
 104        /// <summary>
 105        /// Gets the Storage account name corresponding to the directory client.
 106        /// </summary>
 107        public virtual string AccountName
 108        {
 109            get
 110            {
 16111                SetNameFieldsIfNull();
 16112                return _accountName;
 113            }
 114        }
 115
 116        /// <summary>
 117        /// The file system name corresponding to the directory client.
 118        /// </summary>
 119        private string _fileSystemName;
 120
 121        /// <summary>
 122        /// Gets the file system name name corresponding to the directory client.
 123        /// </summary>
 124        public virtual string FileSystemName
 125        {
 126            get
 127            {
 52128                SetNameFieldsIfNull();
 52129                return _fileSystemName;
 130            }
 131        }
 132
 133        /// <summary>
 134        /// The path corresponding to the path client.
 135        /// </summary>
 136        private string _path;
 137
 138        /// <summary>
 139        /// Gets the path corresponding to the path client.
 140        /// </summary>
 141        public virtual string Path
 142        {
 143            get
 144            {
 584145                SetNameFieldsIfNull();
 584146                return _path;
 147            }
 148        }
 149
 150        /// <summary>
 151        /// The name of the file or directory.
 152        /// </summary>
 153        private string _name;
 154
 155        /// <summary>
 156        /// Gets the name of the file or directory.
 157        /// </summary>
 158        public virtual string Name
 159        {
 160            get
 161            {
 336162                SetNameFieldsIfNull();
 336163                return _name;
 164            }
 165        }
 166
 167        #region ctors
 168        /// <summary>
 169        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 170        /// class for mocking.
 171        /// </summary>
 990172        protected DataLakePathClient()
 173        {
 990174        }
 175
 176        /// <summary>
 177        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 178        /// class.
 179        /// </summary>
 180        /// <param name="pathUri">
 181        /// A <see cref="Uri"/> referencing the resource that includes the
 182        /// name of the account, the name of the file system, and the path to the
 183        /// resource.
 184        /// </param>
 185        public DataLakePathClient(Uri pathUri)
 0186            : this(pathUri, (HttpPipelinePolicy)null, null)
 187        {
 0188        }
 189
 190        /// <summary>
 191        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 192        /// class.
 193        /// </summary>
 194        /// <param name="pathUri">
 195        /// A <see cref="Uri"/> referencing the resource that includes the
 196        /// name of the account, the name of the file system, and the path to the
 197        /// resource.
 198        /// </param>
 199        /// <param name="options">
 200        /// Optional <see cref="DataLakeClientOptions"/> that define the transport
 201        /// pipeline policies for authentication, retries, etc., that are
 202        /// applied to every request.
 203        /// </param>
 204        public DataLakePathClient(Uri pathUri, DataLakeClientOptions options)
 4205            : this(pathUri, (HttpPipelinePolicy)null, options)
 206        {
 4207        }
 208
 209        /// <summary>
 210        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 211        /// class.
 212        /// </summary>
 213        /// <param name="pathUri">
 214        /// A <see cref="Uri"/> referencing the resource that includes the
 215        /// name of the account, the name of the file system, and the path to the
 216        /// resource.
 217        /// </param>
 218        /// <param name="credential">
 219        /// The shared key credential used to sign requests.
 220        /// </param>
 221        public DataLakePathClient(Uri pathUri, StorageSharedKeyCredential credential)
 0222            : this(pathUri, credential.AsPolicy(), null)
 223        {
 0224        }
 225
 226        /// <summary>
 227        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 228        /// class.
 229        /// </summary>
 230        /// <param name="pathUri">
 231        /// A <see cref="Uri"/> referencing the resource that includes the
 232        /// name of the account, the name of the file system, and the path to the
 233        /// resource.
 234        /// </param>
 235        /// <param name="credential">
 236        /// The shared key credential used to sign requests.
 237        /// </param>
 238        /// <param name="options">
 239        /// Optional client options that define the transport pipeline
 240        /// policies for authentication, retries, etc., that are applied to
 241        /// every request.
 242        /// </param>
 243        public DataLakePathClient(Uri pathUri, StorageSharedKeyCredential credential, DataLakeClientOptions options)
 4244            : this(pathUri, credential.AsPolicy(), options)
 245        {
 4246        }
 247
 248        /// <summary>
 249        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 250        /// class.
 251        /// </summary>
 252        /// <param name="pathUri">
 253        /// A <see cref="Uri"/> referencing the resource that includes the
 254        /// name of the account, the name of the file system, and the path to the
 255        /// resource.
 256        /// </param>
 257        /// <param name="credential">
 258        /// The token credential used to sign requests.
 259        /// </param>
 260        public DataLakePathClient(Uri pathUri, TokenCredential credential)
 4261            : this(pathUri, credential.AsPolicy(), null)
 262        {
 4263            Errors.VerifyHttpsTokenAuth(pathUri);
 0264        }
 265
 266        /// <summary>
 267        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 268        /// class.
 269        /// </summary>
 270        /// <param name="pathUri">
 271        /// A <see cref="Uri"/> referencing the resource that includes the
 272        /// name of the account, the name of the file system, and the path to the
 273        /// resource.
 274        /// </param>
 275        /// <param name="credential">
 276        /// The token credential used to sign requests.
 277        /// </param>
 278        /// <param name="options">
 279        /// Optional client options that define the transport pipeline
 280        /// policies for authentication, retries, etc., that are applied to
 281        /// every request.
 282        /// </param>
 283        public DataLakePathClient(Uri pathUri, TokenCredential credential, DataLakeClientOptions options)
 8284            : this(pathUri, credential.AsPolicy(), options)
 285        {
 8286            Errors.VerifyHttpsTokenAuth(pathUri);
 4287        }
 288
 289        /// <summary>
 290        /// Initializes a new instance of the <see cref="DataLakePathClient"/>.
 291        /// </summary>
 292        /// <param name="fileSystemClient"><see cref="DataLakeFileSystemClient"/> of the path's File System.</param>
 293        /// <param name="path">The path to the <see cref="DataLakePathClient"/>.</param>
 294        public DataLakePathClient(DataLakeFileSystemClient fileSystemClient, string path)
 4295            : this(
 4296                  (new DataLakeUriBuilder(fileSystemClient.Uri) { DirectoryOrFilePath = path }).ToDfsUri(),
 4297                  fileSystemClient.Pipeline,
 4298                  fileSystemClient.Version,
 4299                  fileSystemClient.ClientDiagnostics)
 300        {
 4301        }
 302
 303        /// <summary>
 304        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 305        /// class.
 306        /// </summary>
 307        /// <param name="pathUri">
 308        /// A <see cref="Uri"/> referencing the path that includes the
 309        /// name of the account, the name of the file system, and the path to
 310        /// the resource.
 311        /// </param>
 312        /// <param name="authentication">
 313        /// An optional authentication policy used to sign requests.
 314        /// </param>
 315        /// <param name="options">
 316        /// Optional client options that define the transport pipeline
 317        /// policies for authentication, retries, etc., that are applied to
 318        /// every request.
 319        /// </param>
 120320        internal DataLakePathClient(Uri pathUri, HttpPipelinePolicy authentication, DataLakeClientOptions options)
 321        {
 120322            DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(pathUri);
 120323            options ??= new DataLakeClientOptions();
 120324            _uri = pathUri;
 120325            _blobUri = uriBuilder.ToBlobUri();
 120326            _dfsUri = uriBuilder.ToDfsUri();
 120327            _pipeline = options.Build(authentication);
 120328            _version = options.Version;
 120329            _clientDiagnostics = new ClientDiagnostics(options);
 120330            _blockBlobClient = BlockBlobClientInternals.Create(_blobUri, _pipeline, Version.AsBlobsVersion(), _clientDia
 120331        }
 332
 333        /// <summary>
 334        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 335        /// class.
 336        /// </summary>
 337        /// <param name="pathUri">
 338        /// A <see cref="Uri"/> referencing the directory that includes the
 339        /// name of the account, the name of the file system, and the path to the
 340        /// resource.
 341        /// </param>
 342        /// <param name="pipeline">
 343        /// The transport pipeline used to send every request.
 344        /// </param>
 345        /// <param name="options">
 346        /// Optional client options that define the transport pipeline
 347        /// policies for authentication, retries, etc., that are applied to
 348        /// every request.
 349        /// </param>
 204350        internal DataLakePathClient(Uri pathUri, HttpPipeline pipeline, DataLakeClientOptions options = default)
 351        {
 204352            options ??= new DataLakeClientOptions();
 204353            var uriBuilder = new DataLakeUriBuilder(pathUri);
 204354            _uri = pathUri;
 204355            _blobUri = uriBuilder.ToBlobUri();
 204356            _dfsUri = uriBuilder.ToDfsUri();
 204357            _pipeline = pipeline;
 204358            _version = options.Version;
 204359            _clientDiagnostics = new ClientDiagnostics(options);
 204360            _blockBlobClient = BlockBlobClientInternals.Create(_blobUri, _pipeline, Version.AsBlobsVersion(), _clientDia
 204361        }
 362
 363        /// <summary>
 364        /// Initializes a new instance of the <see cref="DataLakePathClient"/>
 365        /// class.
 366        /// </summary>
 367        /// <param name="pathUri">
 368        /// A <see cref="Uri"/> referencing the directory that includes the
 369        /// name of the account, the name of the file system, and the path to the
 370        /// resource.
 371        /// </param>
 372        /// <param name="pipeline">
 373        /// The transport pipeline used to send every request.
 374        /// </param>
 375        /// <param name="version">
 376        /// The version of the service to use when sending requests.
 377        /// </param>
 378        /// <param name="clientDiagnostics">
 379        /// The <see cref="ClientDiagnostics"/> instance used to create
 380        /// diagnostic scopes every request.
 381        /// </param>
 300382        internal DataLakePathClient(
 300383            Uri pathUri,
 300384            HttpPipeline pipeline,
 300385            DataLakeClientOptions.ServiceVersion version,
 300386            ClientDiagnostics clientDiagnostics)
 387        {
 300388            var uriBuilder = new DataLakeUriBuilder(pathUri);
 300389            _uri = pathUri;
 300390            _blobUri = uriBuilder.ToBlobUri();
 300391            _dfsUri = uriBuilder.ToDfsUri();
 300392            _pipeline = pipeline;
 300393            _version = version;
 300394            _clientDiagnostics = clientDiagnostics;
 300395            _blockBlobClient = BlockBlobClientInternals.Create(
 300396                _blobUri,
 300397                _pipeline,
 300398                Version.AsBlobsVersion(),
 300399                _clientDiagnostics);
 300400        }
 401
 3838402        internal DataLakePathClient(
 3838403            Uri fileSystemUri,
 3838404            string directoryOrFilePath,
 3838405            HttpPipeline pipeline,
 3838406            DataLakeClientOptions.ServiceVersion version,
 3838407            ClientDiagnostics clientDiagnostics)
 408        {
 3838409            DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(fileSystemUri)
 3838410            {
 3838411                DirectoryOrFilePath = directoryOrFilePath
 3838412            };
 3838413            _uri = uriBuilder.ToUri();
 3838414            _blobUri = uriBuilder.ToBlobUri();
 3838415            _dfsUri = uriBuilder.ToDfsUri();
 3838416            _pipeline = pipeline;
 3838417            _version = version;
 3838418            _clientDiagnostics = clientDiagnostics;
 3838419            _blockBlobClient = BlockBlobClientInternals.Create(
 3838420                _blobUri,
 3838421                _pipeline,
 3838422                Version.AsBlobsVersion(),
 3838423                _clientDiagnostics);
 3838424        }
 425
 426        /// <summary>
 427        /// Helper to access protected static members of BlockBlobClient
 428        /// that should not be exposed directly to customers.
 429        /// </summary>
 430        private class BlockBlobClientInternals : BlockBlobClient
 431        {
 432            public static BlockBlobClient Create(Uri uri, HttpPipeline pipeline, BlobClientOptions.ServiceVersion versio
 433            {
 4462434                return BlockBlobClient.CreateClient(
 4462435                    uri,
 4462436                    new BlobClientOptions(version)
 4462437                    {
 4462438                        Diagnostics = { IsDistributedTracingEnabled = diagnostics.IsActivityEnabled }
 4462439                    },
 4462440                    pipeline);
 441            }
 442        }
 443        #endregion
 444
 445        /// <summary>
 446        /// Converts metadata in DFS metadata string
 447        /// </summary>
 448        internal static string BuildMetadataString(Metadata metadata)
 449        {
 3058450            if (metadata == null)
 451            {
 3026452                return null;
 453            }
 32454            StringBuilder sb = new StringBuilder();
 320455            foreach (KeyValuePair<string, string> kv in metadata)
 456            {
 128457                sb.Append(kv.Key);
 128458                sb.Append("=");
 128459                byte[] valueBytes = Encoding.UTF8.GetBytes(kv.Value);
 128460                sb.Append(Convert.ToBase64String(valueBytes));
 128461                sb.Append(",");
 462            }
 32463            sb.Remove(sb.Length - 1, 1);
 32464            return sb.ToString();
 465        }
 466
 467        /// <summary>
 468        /// Sets the various name fields if they are currently null.
 469        /// </summary>
 470        internal virtual void SetNameFieldsIfNull()
 471        {
 988472            if (_fileSystemName == null
 988473                || _accountName == null
 988474                || _path == null
 988475                || _name == null)
 476            {
 792477                var builder = new DataLakeUriBuilder(Uri);
 792478                _fileSystemName = builder.FileSystemName;
 792479                _accountName = builder.AccountName;
 792480                _path = builder.DirectoryOrFilePath;
 792481                _name = builder.LastDirectoryOrFileName;
 482            }
 988483        }
 484
 485        #region Create
 486        /// <summary>
 487        /// The <see cref="Create"/> operation creates a file or directory.
 488        /// If the path already exists, it will be overwritten.  If you don't intent to overwrite
 489        /// an existing path, consider using the <see cref="CreateIfNotExists"/> API.
 490        ///
 491        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 492        /// </summary>
 493        /// <param name="resourceType">
 494        /// Resource type of this path - file or directory.
 495        /// </param>
 496        /// <param name="httpHeaders">
 497        /// Optional standard HTTP header properties that can be set for the
 498        /// new file or directory..
 499        /// </param>
 500        /// <param name="metadata">
 501        /// Optional custom metadata to set for this file or directory.
 502        /// </param>
 503        /// <param name="permissions">
 504        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 505        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 506        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 507        /// octal notation (e.g. 0766) are supported.
 508        /// </param>
 509        /// <param name="umask">
 510        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 511        /// When creating a file or directory and the parent folder does not have a default ACL,
 512        /// the umask restricts the permissions of the file or directory to be created. The resulting
 513        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 514        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 515        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 516        /// in 4-digit octal notation (e.g. 0766).
 517        /// </param>
 518        /// <param name="conditions">
 519        /// Optional <see cref="DataLakeRequestConditions"/> to add
 520        /// conditions on the creation of this file or directory.
 521        /// </param>
 522        /// <param name="cancellationToken">
 523        /// Optional <see cref="CancellationToken"/> to propagate
 524        /// notifications that the operation should be cancelled.
 525        /// </param>
 526        /// <returns>
 527        /// A <see cref="Response{PathInfo}"/> describing the
 528        /// newly created path.
 529        /// </returns>
 530        /// <remarks>
 531        /// A <see cref="RequestFailedException"/> will be thrown if
 532        /// a failure occurs.
 533        /// </remarks>
 534        public virtual Response<PathInfo> Create(
 535            PathResourceType resourceType,
 536            PathHttpHeaders httpHeaders = default,
 537            Metadata metadata = default,
 538            string permissions = default,
 539            string umask = default,
 540            DataLakeRequestConditions conditions = default,
 541            CancellationToken cancellationToken = default)
 542        {
 1228543            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Create)}");
 544
 545            try
 546            {
 1228547                scope.Start();
 548
 1228549                return CreateInternal(
 1228550                    resourceType,
 1228551                    httpHeaders,
 1228552                    metadata,
 1228553                    permissions,
 1228554                    umask,
 1228555                    conditions,
 1228556                    false, // async
 1228557                    cancellationToken)
 1228558                    .EnsureCompleted();
 559            }
 12560            catch (Exception ex)
 561            {
 12562                scope.Failed(ex);
 12563                throw;
 564            }
 565            finally
 566            {
 1228567                scope.Dispose();
 1228568            }
 1216569        }
 570
 571        /// <summary>
 572        /// The <see cref="Create"/> operation creates a file or directory.
 573        /// If the path already exists, it will be overwritten.  If you don't intent to overwrite
 574        /// an existing path, consider using the <see cref="CreateIfNotExists"/> API.
 575        ///
 576        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 577        /// </summary>
 578        /// <param name="resourceType">
 579        /// Resource type of this path - file or directory.
 580        /// </param>
 581        /// <param name="httpHeaders">
 582        /// Optional standard HTTP header properties that can be set for the
 583        /// new file or directory.
 584        /// </param>
 585        /// <param name="metadata">
 586        /// Optional custom metadata to set for this file or directory.
 587        /// </param>
 588        /// <param name="permissions">
 589        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 590        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 591        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 592        /// octal notation (e.g. 0766) are supported.
 593        /// </param>
 594        /// <param name="umask">
 595        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 596        /// When creating a file or directory and the parent folder does not have a default ACL,
 597        /// the umask restricts the permissions of the file or directory to be created. The resulting
 598        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 599        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 600        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 601        /// in 4-digit octal notation (e.g. 0766).
 602        /// </param>
 603        /// <param name="conditions">
 604        /// Optional <see cref="DataLakeRequestConditions"/> to add
 605        /// conditions on the creation of this file or directory.
 606        /// </param>
 607        /// <param name="cancellationToken">
 608        /// Optional <see cref="CancellationToken"/> to propagate
 609        /// notifications that the operation should be cancelled.
 610        /// </param>
 611        /// <returns>
 612        /// A <see cref="Response{PathInfo}"/> describing the
 613        /// newly created path.
 614        /// </returns>
 615        /// <remarks>
 616        /// A <see cref="RequestFailedException"/> will be thrown if
 617        /// a failure occurs.
 618        /// </remarks>
 619        public virtual async Task<Response<PathInfo>> CreateAsync(
 620            PathResourceType resourceType,
 621            PathHttpHeaders httpHeaders = default,
 622            Metadata metadata = default,
 623            string permissions = default,
 624            string umask = default,
 625            DataLakeRequestConditions conditions = default,
 626            CancellationToken cancellationToken = default)
 627        {
 1638628            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Create)}");
 629
 630            try
 631            {
 1638632                scope.Start();
 633
 1638634                return await CreateInternal(
 1638635                    resourceType,
 1638636                    httpHeaders,
 1638637                    metadata,
 1638638                    permissions,
 1638639                    umask,
 1638640                    conditions,
 1638641                    true, // async
 1638642                    cancellationToken)
 1638643                    .ConfigureAwait(false);
 644            }
 72645            catch (Exception ex)
 646            {
 72647                scope.Failed(ex);
 72648                throw;
 649            }
 650            finally
 651            {
 1638652                scope.Dispose();
 653            }
 1566654        }
 655
 656        /// <summary>
 657        /// The <see cref="Create"/> operation creates a file or directory.
 658        ///
 659        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 660        /// </summary>
 661        /// <param name="resourceType">
 662        /// Resource type of this path - file or directory.
 663        /// </param>
 664        /// <param name="httpHeaders">
 665        /// Optional standard HTTP header properties that can be set for the
 666        /// new file or directory.
 667        /// </param>
 668        /// <param name="metadata">
 669        /// Optional custom metadata to set for this file or directory.
 670        /// </param>
 671        /// <param name="permissions">
 672        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 673        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 674        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 675        /// octal notation (e.g. 0766) are supported.
 676        /// </param>
 677        /// <param name="umask">
 678        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 679        /// When creating a file or directory and the parent folder does not have a default ACL,
 680        /// the umask restricts the permissions of the file or directory to be created. The resulting
 681        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 682        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 683        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 684        /// in 4-digit octal notation (e.g. 0766).
 685        /// </param>
 686        /// <param name="conditions">
 687        /// Optional <see cref="DataLakeRequestConditions"/> to add
 688        /// conditions on the creation of this file or directory..
 689        /// </param>
 690        /// <param name="async">
 691        /// Whether to invoke the operation asynchronously.
 692        /// </param>
 693        /// <param name="cancellationToken">
 694        /// Optional <see cref="CancellationToken"/> to propagate
 695        /// notifications that the operation should be cancelled.
 696        /// </param>
 697        /// <returns>
 698        /// A <see cref="Response{PathInfo}"/> describing the
 699        /// newly created path.
 700        /// </returns>
 701        /// <remarks>
 702        /// A <see cref="RequestFailedException"/> will be thrown if
 703        /// a failure occurs.
 704        /// </remarks>
 705        internal virtual async Task<Response<PathInfo>> CreateInternal(
 706            PathResourceType resourceType,
 707            PathHttpHeaders httpHeaders,
 708            Metadata metadata,
 709            string permissions,
 710            string umask,
 711            DataLakeRequestConditions conditions,
 712            bool async,
 713            CancellationToken cancellationToken)
 714        {
 3058715            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 716            {
 717                Pipeline.LogMethodEnter(
 718                    nameof(DataLakePathClient),
 719                    message:
 720                    $"{nameof(Uri)}: {Uri}\n" +
 721                    $"{nameof(httpHeaders)}: {httpHeaders}\n" +
 722                    $"{nameof(metadata)}: {metadata}\n" +
 723                    $"{nameof(permissions)}: {permissions}\n" +
 724                    $"{nameof(umask)}: {umask}\n");
 725                try
 726                {
 727
 3058728                    Response<PathCreateResult> createResponse = await DataLakeRestClient.Path.CreateAsync(
 3058729                        clientDiagnostics: _clientDiagnostics,
 3058730                        pipeline: Pipeline,
 3058731                        resourceUri: _dfsUri,
 3058732                        version: Version.ToVersionString(),
 3058733                        resource: resourceType,
 3058734                        cacheControl: httpHeaders?.CacheControl,
 3058735                        contentEncoding: httpHeaders?.ContentEncoding,
 3058736                        contentDisposition: httpHeaders?.ContentDisposition,
 3058737                        contentType: httpHeaders?.ContentType,
 3058738                        contentLanguage: httpHeaders?.ContentLanguage,
 3058739                        leaseId: conditions?.LeaseId,
 3058740                        properties: BuildMetadataString(metadata),
 3058741                        permissions: permissions,
 3058742                        umask: umask,
 3058743                        ifMatch: conditions?.IfMatch,
 3058744                        ifNoneMatch: conditions?.IfNoneMatch,
 3058745                        ifModifiedSince: conditions?.IfModifiedSince,
 3058746                        ifUnmodifiedSince: conditions?.IfUnmodifiedSince,
 3058747                        async: async,
 3058748                        cancellationToken: cancellationToken)
 3058749                        .ConfigureAwait(false);
 750
 2950751                    return Response.FromValue(
 2950752                        new PathInfo()
 2950753                        {
 2950754                            ETag = createResponse.Value.ETag,
 2950755                            LastModified = createResponse.Value.LastModified
 2950756                        },
 2950757                        createResponse.GetRawResponse());
 758                }
 108759                catch (Exception ex)
 760                {
 761                    Pipeline.LogException(ex);
 108762                    throw;
 763                }
 764                finally
 765                {
 766                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 767                }
 768            }
 2950769        }
 770        #endregion Create
 771
 772        #region Create If Not Exists
 773        /// <summary>
 774        /// The <see cref="CreateIfNotExists(PathResourceType, PathHttpHeaders, Metadata, string, string, CancellationTo
 775        /// operation creates a file or directory.  If the file or directory already exists, it is not changed.
 776        ///
 777        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 778        /// </summary>
 779        /// <param name="resourceType">
 780        /// Resource type of this path - file or directory.
 781        /// </param>
 782        /// <param name="httpHeaders">
 783        /// Optional standard HTTP header properties that can be set for the
 784        /// new file or directory..
 785        /// </param>
 786        /// <param name="metadata">
 787        /// Optional custom metadata to set for this file or directory..
 788        /// </param>
 789        /// <param name="permissions">
 790        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 791        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 792        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 793        /// octal notation (e.g. 0766) are supported.
 794        /// </param>
 795        /// <param name="umask">
 796        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 797        /// When creating a file or directory and the parent folder does not have a default ACL,
 798        /// the umask restricts the permissions of the file or directory to be created. The resulting
 799        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 800        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 801        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 802        /// in 4-digit octal notation (e.g. 0766).
 803        /// </param>
 804        /// <param name="cancellationToken">
 805        /// Optional <see cref="CancellationToken"/> to propagate
 806        /// notifications that the operation should be cancelled.
 807        /// </param>
 808        /// <returns>
 809        /// A <see cref="Response{PathInfo}"/> describing the
 810        /// newly created path.
 811        /// </returns>
 812        /// <remarks>
 813        /// A <see cref="RequestFailedException"/> will be thrown if
 814        /// a failure occurs.
 815        /// </remarks>
 816        public virtual Response<PathInfo> CreateIfNotExists(
 817            PathResourceType resourceType,
 818            PathHttpHeaders httpHeaders = default,
 819            Metadata metadata = default,
 820            string permissions = default,
 821            string umask = default,
 822            CancellationToken cancellationToken = default)
 12823            => CreateIfNotExistsInternal(
 12824                    resourceType,
 12825                    httpHeaders,
 12826                    metadata,
 12827                    permissions,
 12828                    umask,
 12829                    false, // async
 12830                    cancellationToken)
 12831                    .EnsureCompleted();
 832
 833
 834        /// <summary>
 835        /// The <see cref="CreateIfNotExistsAsync(PathResourceType, PathHttpHeaders, Metadata, string, string, Cancellat
 836        /// operation creates a file or directory.  If the file or directory already exists, it is not changed.
 837        ///
 838        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 839        /// </summary>
 840        /// <param name="resourceType">
 841        /// Resource type of this path - file or directory.
 842        /// </param>
 843        /// <param name="httpHeaders">
 844        /// Optional standard HTTP header properties that can be set for the
 845        /// new file or directory.
 846        /// </param>
 847        /// <param name="metadata">
 848        /// Optional custom metadata to set for this file or directory..
 849        /// </param>
 850        /// <param name="permissions">
 851        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 852        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 853        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 854        /// octal notation (e.g. 0766) are supported.
 855        /// </param>
 856        /// <param name="umask">
 857        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 858        /// When creating a file or directory and the parent folder does not have a default ACL,
 859        /// the umask restricts the permissions of the file or directory to be created. The resulting
 860        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 861        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 862        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 863        /// in 4-digit octal notation (e.g. 0766).
 864        /// </param>
 865        /// <param name="cancellationToken">
 866        /// Optional <see cref="CancellationToken"/> to propagate
 867        /// notifications that the operation should be cancelled.
 868        /// </param>
 869        /// <returns>
 870        /// A <see cref="Response{PathInfo}"/> describing the
 871        /// newly created path.
 872        /// </returns>
 873        /// <remarks>
 874        /// A <see cref="RequestFailedException"/> will be thrown if
 875        /// a failure occurs.
 876        /// </remarks>
 877        public virtual async Task<Response<PathInfo>> CreateIfNotExistsAsync(
 878            PathResourceType resourceType,
 879            PathHttpHeaders httpHeaders = default,
 880            Metadata metadata = default,
 881            string permissions = default,
 882            string umask = default,
 883            CancellationToken cancellationToken = default)
 12884            => await CreateIfNotExistsInternal(
 12885                resourceType,
 12886                httpHeaders,
 12887                metadata,
 12888                permissions,
 12889                umask,
 12890                true, // async
 12891                cancellationToken)
 12892                .ConfigureAwait(false);
 893
 894
 895        /// <summary>
 896        /// The <see cref="CreateIfNotExistsInternal(PathResourceType, PathHttpHeaders, Metadata, string, string, bool, 
 897        /// operation creates a file or directory.  If the file or directory already exists, it is not changed.
 898        ///
 899        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 900        /// </summary>
 901        /// <param name="resourceType">
 902        /// Resource type of this path - file or directory.
 903        /// </param>
 904        /// <param name="httpHeaders">
 905        /// Optional standard HTTP header properties that can be set for the
 906        /// new file or directory.
 907        /// </param>
 908        /// <param name="metadata">
 909        /// Optional custom metadata to set for this file or directory.
 910        /// </param>
 911        /// <param name="permissions">
 912        /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access
 913        /// permissions for the file owner, the file owning group, and others. Each class may be granted read,
 914        /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit
 915        /// octal notation (e.g. 0766) are supported.
 916        /// </param>
 917        /// <param name="umask">
 918        /// Optional and only valid if Hierarchical Namespace is enabled for the account.
 919        /// When creating a file or directory and the parent folder does not have a default ACL,
 920        /// the umask restricts the permissions of the file or directory to be created. The resulting
 921        /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example,
 922        /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is
 923        /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified
 924        /// in 4-digit octal notation (e.g. 0766).
 925        /// </param>
 926        /// <param name="async">
 927        /// Whether to invoke the operation asynchronously.
 928        /// </param>
 929        /// <param name="cancellationToken">
 930        /// Optional <see cref="CancellationToken"/> to propagate
 931        /// notifications that the operation should be cancelled.
 932        /// </param>
 933        /// <returns>
 934        /// A <see cref="Response{PathInfo}"/> describing the
 935        /// newly created path.
 936        /// </returns>
 937        /// <remarks>
 938        /// A <see cref="RequestFailedException"/> will be thrown if
 939        /// a failure occurs.
 940        /// </remarks>
 941        private async Task<Response<PathInfo>> CreateIfNotExistsInternal(
 942            PathResourceType resourceType,
 943            PathHttpHeaders httpHeaders,
 944            Metadata metadata,
 945            string permissions,
 946            string umask,
 947            bool async,
 948            CancellationToken cancellationToken)
 949        {
 24950            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Create)}");
 951            Response<PathInfo> response;
 952            try
 953            {
 24954                scope.Start();
 24955                DataLakeRequestConditions conditions = new DataLakeRequestConditions { IfNoneMatch = new ETag(Constants.
 24956                response = await CreateInternal(
 24957                    resourceType,
 24958                    httpHeaders,
 24959                    metadata,
 24960                    permissions,
 24961                    umask,
 24962                    conditions,
 24963                    async,
 24964                    cancellationToken).ConfigureAwait(false);
 8965            }
 966            catch (RequestFailedException storageRequestFailedException)
 16967            when (storageRequestFailedException.ErrorCode == "PathAlreadyExists")
 968            {
 8969                response = default;
 8970            }
 8971            catch (Exception ex)
 972            {
 8973                scope.Failed(ex);
 8974                throw;
 975            }
 976            finally
 977            {
 24978                scope.Dispose();
 979            }
 16980            return response;
 16981        }
 982        #endregion Create If Not Exists
 983
 984        #region Exists
 985        /// <summary>
 986        /// The <see cref="Exists"/> operation can be called on a
 987        /// <see cref="DataLakePathClient"/> to see if the associated
 988        /// file or director exists in the file system.
 989        /// </summary>
 990        /// <param name="cancellationToken">
 991        /// Optional <see cref="CancellationToken"/> to propagate
 992        /// notifications that the operation should be cancelled.
 993        /// </param>
 994        /// <returns>
 995        /// Returns true if the file or directory exists.
 996        /// </returns>
 997        /// <remarks>
 998        /// A <see cref="RequestFailedException"/> will be thrown if
 999        /// a failure occurs. If you want to create the file system if
 1000        /// it doesn't exist, use
 1001        /// <see cref="CreateIfNotExists"/>
 1002        /// instead.
 1003        /// </remarks>
 1004        /// <remarks>
 1005        /// Note that if you call FileClient.Exists on a path that does not
 1006        /// represent a file, Exists will return true. Similarly, if you
 1007        /// call DirectoryClient.Exists on a path that is not a directory,
 1008        /// Exists will return true.
 1009        /// </remarks>
 1010        public virtual Response<bool> Exists(
 1011            CancellationToken cancellationToken = default)
 1012        {
 161013            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Exists)}");
 1014
 1015            try
 1016            {
 161017                scope.Start();
 1018
 161019                return _blockBlobClient.Exists(cancellationToken);
 1020            }
 41021            catch (Exception ex)
 1022            {
 41023                scope.Failed(ex);
 41024                throw;
 1025            }
 1026            finally
 1027            {
 161028                scope.Dispose();
 161029            }
 121030        }
 1031
 1032        /// <summary>
 1033        /// The <see cref="ExistsAsync"/> operation can be called on a
 1034        /// <see cref="DataLakePathClient"/> to see if the associated
 1035        /// file or directory exists in the file system.
 1036        /// </summary>
 1037        /// <param name="cancellationToken">
 1038        /// Optional <see cref="CancellationToken"/> to propagate
 1039        /// notifications that the operation should be cancelled.
 1040        /// </param>
 1041        /// <returns>
 1042        /// Returns true if the file or directory exists.
 1043        /// </returns>
 1044        /// <remarks>
 1045        /// A <see cref="RequestFailedException"/> will be thrown if
 1046        /// a failure occurs. If you want to create the file system if
 1047        /// it doesn't exist, use
 1048        /// <see cref="CreateIfNotExistsAsync"/>
 1049        /// instead.
 1050        /// </remarks>
 1051        /// <remarks>
 1052        /// Note that if you call FileClient.Exists on a path that does not
 1053        /// represent a file, Exists will return true. Similarly, if you
 1054        /// call DirectoryClient.Exists on a path that is not a directory,
 1055        /// Exists will return true.
 1056        /// </remarks>
 1057        public virtual async Task<Response<bool>> ExistsAsync(
 1058            CancellationToken cancellationToken = default)
 1059        {
 161060            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Exists)}");
 1061
 1062            try
 1063            {
 161064                scope.Start();
 1065
 161066                return await _blockBlobClient.ExistsAsync(cancellationToken).ConfigureAwait(false);
 1067            }
 41068            catch (Exception ex)
 1069            {
 41070                scope.Failed(ex);
 41071                throw;
 1072            }
 1073            finally
 1074            {
 161075                scope.Dispose();
 1076            }
 121077        }
 1078        #endregion Exists
 1079
 1080        #region Delete
 1081        /// <summary>
 1082        /// The <see cref="Delete"/> operation marks the specified path
 1083        /// deletion. The path is later deleted during
 1084        /// garbage collection.
 1085        ///
 1086        /// For more information, see
 1087        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1088        /// Delete Path</see>.
 1089        /// </summary>
 1090        /// <param name="recursive">
 1091        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1092        /// If "false" and the directory is non-empty, an error occurs.
 1093        /// </param>
 1094        /// <param name="conditions">
 1095        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1096        /// deleting this path.
 1097        /// </param>
 1098        /// <param name="cancellationToken">
 1099        /// Optional <see cref="CancellationToken"/> to propagate
 1100        /// notifications that the operation should be cancelled.
 1101        /// </param>
 1102        /// <returns>
 1103        /// A <see cref="Response"/> on successfully deleting.
 1104        /// </returns>
 1105        /// <remarks>
 1106        /// A <see cref="RequestFailedException"/> will be thrown if
 1107        /// a failure occurs.
 1108        /// </remarks>
 1109        public virtual Response Delete(
 1110            bool? recursive = default,
 1111            DataLakeRequestConditions conditions = default,
 1112            CancellationToken cancellationToken = default)
 1113        {
 121114            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Delete)}");
 1115
 1116            try
 1117            {
 121118                scope.Start();
 1119
 121120                return DeleteInternal(
 121121                    recursive,
 121122                    conditions,
 121123                    false, // async
 121124                    cancellationToken)
 121125                    .EnsureCompleted();
 1126            }
 61127            catch (Exception ex)
 1128            {
 61129                scope.Failed(ex);
 61130                throw;
 1131            }
 1132            finally
 1133            {
 121134                scope.Dispose();
 121135            }
 61136        }
 1137
 1138        /// <summary>
 1139        /// The <see cref="DeleteAsync"/> operation marks the specified path
 1140        /// deletion. The path is later deleted during
 1141        /// garbage collection.
 1142        ///
 1143        /// For more information, see
 1144        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1145        /// Delete Path</see>.
 1146        /// </summary>
 1147        /// <param name="recursive">
 1148        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1149        /// If "false" and the directory is non-empty, an error occurs.
 1150        /// </param>
 1151        /// <param name="conditions">
 1152        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1153        /// deleting this path.
 1154        /// </param>
 1155        /// <param name="cancellationToken">
 1156        /// Optional <see cref="CancellationToken"/> to propagate
 1157        /// notifications that the operation should be cancelled.
 1158        /// </param>
 1159        /// <returns>
 1160        /// A <see cref="Response"/> on successfully deleting.
 1161        /// </returns>
 1162        /// <remarks>
 1163        /// A <see cref="RequestFailedException"/> will be thrown if
 1164        /// a failure occurs.
 1165        /// </remarks>
 1166        public virtual async Task<Response> DeleteAsync(
 1167            bool? recursive = default,
 1168            DataLakeRequestConditions conditions = default,
 1169            CancellationToken cancellationToken = default)
 1170        {
 1561171            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Delete)}");
 1172
 1173            try
 1174            {
 1561175                scope.Start();
 1176
 1561177                return await DeleteInternal(
 1561178                    recursive,
 1561179                    conditions,
 1561180                    true, // async
 1561181                    cancellationToken)
 1561182                    .ConfigureAwait(false);
 1183            }
 701184            catch (Exception ex)
 1185            {
 701186                scope.Failed(ex);
 701187                throw;
 1188            }
 1189            finally
 1190            {
 1561191                scope.Dispose();
 1192            }
 861193        }
 1194
 1195        /// <summary>
 1196        /// The <see cref="DeleteInternal"/> operation marks the specified path
 1197        /// deletion. The path is later deleted during
 1198        /// garbage collection.
 1199        ///
 1200        /// For more information, see
 1201        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1202        /// Delete Path</see>.
 1203        /// </summary>
 1204        /// <param name="recursive">
 1205        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1206        /// If "false" and the directory is non-empty, an error occurs.
 1207        /// </param>
 1208        /// <param name="conditions">
 1209        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1210        /// deleting this path.
 1211        /// </param>
 1212        /// <param name="async">
 1213        /// Whether to invoke the operation asynchronously.
 1214        /// </param>
 1215        /// <param name="cancellationToken">
 1216        /// Optional <see cref="CancellationToken"/> to propagate
 1217        /// notifications that the operation should be cancelled.
 1218        /// </param>
 1219        /// <returns>
 1220        /// A <see cref="Response"/> on successfully deleting.
 1221        /// </returns>
 1222        /// <remarks>
 1223        /// A <see cref="RequestFailedException"/> will be thrown if
 1224        /// a failure occurs.
 1225        /// </remarks>
 1226        private async Task<Response> DeleteInternal(
 1227            bool? recursive,
 1228            DataLakeRequestConditions conditions,
 1229            bool async,
 1230            CancellationToken cancellationToken)
 1231        {
 2041232            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 1233            {
 1234                Pipeline.LogMethodEnter(
 1235                    nameof(DataLakePathClient),
 1236                    message:
 1237                    $"{nameof(Uri)}: {Uri}\n" +
 1238                    $"{nameof(recursive)}: {recursive}\n" +
 1239                    $"{nameof(conditions)}: {conditions}");
 1240                try
 1241                {
 2041242                    Response<PathDeleteResult> response = await DataLakeRestClient.Path.DeleteAsync(
 2041243                        clientDiagnostics: _clientDiagnostics,
 2041244                        pipeline: Pipeline,
 2041245                        resourceUri: _dfsUri,
 2041246                        version: Version.ToVersionString(),
 2041247                        recursive: recursive,
 2041248                        leaseId: conditions?.LeaseId,
 2041249                        ifMatch: conditions?.IfMatch,
 2041250                        ifNoneMatch: conditions?.IfNoneMatch,
 2041251                        ifModifiedSince: conditions?.IfModifiedSince,
 2041252                        ifUnmodifiedSince: conditions?.IfUnmodifiedSince,
 2041253                        async: async,
 2041254                        cancellationToken: cancellationToken)
 2041255                        .ConfigureAwait(false);
 1256
 1001257                    return response.GetRawResponse();
 1258                }
 1041259                catch (Exception ex)
 1260                {
 1261                    Pipeline.LogException(ex);
 1041262                    throw;
 1263                }
 1264                finally
 1265                {
 1266                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 1267                }
 1268            }
 1001269        }
 1270        #endregion Delete
 1271
 1272        #region Delete If Exists
 1273        /// <summary>
 1274        /// The <see cref="DeleteIfExists"/> operation marks the specified path
 1275        /// for deletion, if the path exists. The path is later deleted during
 1276        /// garbage collection.
 1277        ///
 1278        /// For more information, see
 1279        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1280        /// Delete Path</see>.
 1281        /// </summary>
 1282        /// <param name="recursive">
 1283        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1284        /// If "false" and the directory is non-empty, an error occurs.
 1285        /// </param>
 1286        /// <param name="conditions">
 1287        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1288        /// deleting this path.
 1289        /// </param>
 1290        /// <param name="cancellationToken">
 1291        /// Optional <see cref="CancellationToken"/> to propagate
 1292        /// notifications that the operation should be cancelled.
 1293        /// </param>
 1294        /// <returns>
 1295        /// A <see cref="Response"/> on successfully deleting.
 1296        /// </returns>
 1297        /// <remarks>
 1298        /// A <see cref="RequestFailedException"/> will be thrown if
 1299        /// a failure occurs.
 1300        /// </remarks>
 1301        public virtual Response<bool> DeleteIfExists(
 1302            bool? recursive = default,
 1303            DataLakeRequestConditions conditions = default,
 1304            CancellationToken cancellationToken = default)
 181305            => DeleteIfExistsInternal(
 181306                recursive,
 181307                conditions,
 181308                false, // async
 181309                cancellationToken)
 181310                .EnsureCompleted();
 1311
 1312        /// <summary>
 1313        /// The <see cref="DeleteIfExistsAsync"/> operation marks the specified path
 1314        /// deletion, if the path exists. The path is later deleted during
 1315        /// garbage collection.
 1316        ///
 1317        /// For more information, see
 1318        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1319        /// Delete Path</see>.
 1320        /// </summary>
 1321        /// <param name="recursive">
 1322        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1323        /// If "false" and the directory is non-empty, an error occurs.
 1324        /// </param>
 1325        /// <param name="conditions">
 1326        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1327        /// deleting this path.
 1328        /// </param>
 1329        /// <param name="cancellationToken">
 1330        /// Optional <see cref="CancellationToken"/> to propagate
 1331        /// notifications that the operation should be cancelled.
 1332        /// </param>
 1333        /// <returns>
 1334        /// A <see cref="Response"/> on successfully deleting.
 1335        /// </returns>
 1336        /// <remarks>
 1337        /// A <see cref="RequestFailedException"/> will be thrown if
 1338        /// a failure occurs.
 1339        /// </remarks>
 1340        public virtual async Task<Response<bool>> DeleteIfExistsAsync(
 1341            bool? recursive = default,
 1342            DataLakeRequestConditions conditions = default,
 1343            CancellationToken cancellationToken = default)
 181344            => await DeleteIfExistsInternal(
 181345                recursive,
 181346                conditions,
 181347                true, // async
 181348                cancellationToken)
 181349                .ConfigureAwait(false);
 1350
 1351        /// <summary>
 1352        /// The <see cref="DeleteIfExistsInternal"/> operation marks the specified path
 1353        /// deletion, if the path exists. The path is later deleted during
 1354        /// garbage collection.
 1355        ///
 1356        /// For more information, see
 1357        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete">
 1358        /// Delete Path</see>.
 1359        /// </summary>
 1360        /// <param name="recursive">
 1361        /// Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be
 1362        /// If "false" and the directory is non-empty, an error occurs.
 1363        /// </param>
 1364        /// <param name="conditions">
 1365        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1366        /// deleting this path.
 1367        /// </param>
 1368        /// <param name="async">
 1369        /// Whether to invoke the operation asynchronously.
 1370        /// </param>
 1371        /// <param name="cancellationToken">
 1372        /// Optional <see cref="CancellationToken"/> to propagate
 1373        /// notifications that the operation should be cancelled.
 1374        /// </param>
 1375        /// <returns>
 1376        /// A <see cref="Response"/> on successfully deleting.
 1377        /// </returns>
 1378        /// <remarks>
 1379        /// A <see cref="RequestFailedException"/> will be thrown if
 1380        /// a failure occurs.
 1381        /// </remarks>
 1382        private async Task<Response<bool>> DeleteIfExistsInternal(
 1383            bool? recursive,
 1384            DataLakeRequestConditions conditions,
 1385            bool async,
 1386            CancellationToken cancellationToken)
 1387        {
 361388            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(DeleteIfExists)
 1389            try
 1390            {
 361391                scope.Start();
 361392                Response response = await DeleteInternal(
 361393                    recursive: recursive,
 361394                    conditions: conditions,
 361395                    async: async,
 361396                    cancellationToken: cancellationToken)
 361397                    .ConfigureAwait(false);
 1398
 81399                return Response.FromValue(true, response);
 1400            }
 1401            catch (RequestFailedException ex)
 281402            when (ex.ErrorCode == Constants.DataLake.PathNotFound
 281403                || ex.ErrorCode == Constants.DataLake.FilesystemNotFound)
 1404            {
 201405                return Response.FromValue(false, default);
 1406            }
 81407            catch (Exception ex)
 1408            {
 81409                scope.Failed(ex);
 81410                throw;
 1411            }
 1412            finally
 1413            {
 361414                scope.Dispose();
 1415            }
 281416        }
 1417        #endregion Delete If Exists
 1418
 1419        #region Rename
 1420        /// <summary>
 1421        /// The <see cref="Rename"/> operation renames a file or directory.
 1422        ///
 1423        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 1424        /// </summary>
 1425        /// <param name="destinationPath">
 1426        /// The destination path to rename the path to.
 1427        /// </param>
 1428        /// <param name="destinationFileSystem">
 1429        /// Optional destination file system.  If null, path will be renamed within the
 1430        /// current file system.
 1431        /// </param>
 1432        /// <param name="sourceConditions">
 1433        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1434        /// conditions on the source on the creation of this file or directory.
 1435        /// </param>
 1436        /// <param name="destinationConditions">
 1437        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1438        /// conditions on the creation of this file or directory.
 1439        /// </param>
 1440        /// <param name="cancellationToken">
 1441        /// Optional <see cref="CancellationToken"/> to propagate
 1442        /// notifications that the operation should be cancelled.
 1443        /// </param>
 1444        /// <returns>
 1445        /// A <see cref="Response{PathInfo}"/> describing the
 1446        /// newly created path.
 1447        /// </returns>
 1448        /// <remarks>
 1449        /// A <see cref="RequestFailedException"/> will be thrown if
 1450        /// a failure occurs.
 1451        /// </remarks>
 1452        public virtual Response<DataLakePathClient> Rename(
 1453            string destinationPath,
 1454            string destinationFileSystem = default,
 1455            DataLakeRequestConditions sourceConditions = default,
 1456            DataLakeRequestConditions destinationConditions = default,
 1457            CancellationToken cancellationToken = default)
 1458        {
 41459            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Rename)}");
 1460
 1461            try
 1462            {
 41463                scope.Start();
 1464
 41465                return RenameInternal(
 41466                    destinationFileSystem,
 41467                    destinationPath,
 41468                    sourceConditions,
 41469                    destinationConditions,
 41470                    false, // async
 41471                    cancellationToken)
 41472                    .EnsureCompleted();
 1473            }
 41474            catch (Exception ex)
 1475            {
 41476                scope.Failed(ex);
 41477                throw;
 1478            }
 1479            finally
 1480            {
 41481                scope.Dispose();
 41482            }
 01483        }
 1484
 1485        /// <summary>
 1486        /// The <see cref="RenameAsync"/> operation renames a file or directory.
 1487        ///
 1488        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 1489        /// </summary>
 1490        /// <param name="destinationPath">
 1491        /// The destination path to rename the path to.
 1492        /// </param>
 1493        /// <param name="destinationFileSystem">
 1494        /// Optional destination file system.  If null, path will be renamed within the
 1495        /// current file system.
 1496        /// </param>
 1497        /// <param name="sourceConditions">
 1498        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1499        /// conditions on the source on the creation of this file or directory.
 1500        /// </param>
 1501        /// <param name="destinationConditions">
 1502        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1503        /// conditions on the creation of this file or directory.
 1504        /// </param>
 1505        /// <param name="cancellationToken">
 1506        /// Optional <see cref="CancellationToken"/> to propagate
 1507        /// notifications that the operation should be cancelled.
 1508        /// </param>
 1509        /// <returns>
 1510        /// A <see cref="Response{PathInfo}"/> describing the
 1511        /// newly created path.
 1512        /// </returns>
 1513        /// <remarks>
 1514        /// A <see cref="RequestFailedException"/> will be thrown if
 1515        /// a failure occurs.
 1516        /// </remarks>
 1517        public virtual async Task<Response<DataLakePathClient>> RenameAsync(
 1518            string destinationPath,
 1519            string destinationFileSystem = default,
 1520            DataLakeRequestConditions sourceConditions = default,
 1521            DataLakeRequestConditions destinationConditions = default,
 1522            CancellationToken cancellationToken = default)
 1523        {
 2001524            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(Rename)}");
 1525
 1526            try
 1527            {
 2001528                scope.Start();
 1529
 2001530                return await RenameInternal(
 2001531                    destinationFileSystem,
 2001532                    destinationPath,
 2001533                    sourceConditions,
 2001534                    destinationConditions,
 2001535                    true, // async
 2001536                    cancellationToken)
 2001537                    .ConfigureAwait(false);
 1538            }
 841539            catch (Exception ex)
 1540            {
 841541                scope.Failed(ex);
 841542                throw;
 1543            }
 1544            finally
 1545            {
 2001546                scope.Dispose();
 1547            }
 1161548        }
 1549
 1550        /// <summary>
 1551        /// The <see cref="RenameInternal"/> operation renames a file or directory.
 1552        ///
 1553        /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path
 1554        /// </summary>
 1555        /// <param name="destinationPath">
 1556        /// The destination path to rename the path to.
 1557        /// </param>
 1558        /// <param name="destinationFileSystem">
 1559        /// Optional destination file system.  If null, path will be renamed within the
 1560        /// current file system.
 1561        /// </param>
 1562        /// <param name="sourceConditions">
 1563        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1564        /// conditions on the source on the creation of this file or directory.
 1565        /// </param>
 1566        /// <param name="destinationConditions">
 1567        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1568        /// conditions on the creation of this file or directory.
 1569        /// </param>
 1570        /// <param name="async">
 1571        /// Whether to invoke the operation asynchronously.
 1572        /// </param>
 1573        /// <param name="cancellationToken">
 1574        /// Optional <see cref="CancellationToken"/> to propagate
 1575        /// notifications that the operation should be cancelled.
 1576        /// </param>
 1577        /// <returns>
 1578        /// A <see cref="Response{PathInfo}"/> describing the
 1579        /// newly created path.
 1580        /// </returns>
 1581        /// <remarks>
 1582        /// A <see cref="RequestFailedException"/> will be thrown if
 1583        /// a failure occurs.
 1584        /// </remarks>
 1585        private async Task<Response<DataLakePathClient>> RenameInternal(
 1586            string destinationPath,
 1587            string destinationFileSystem,
 1588            DataLakeRequestConditions sourceConditions,
 1589            DataLakeRequestConditions destinationConditions,
 1590            bool async,
 1591            CancellationToken cancellationToken)
 1592        {
 2041593            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 1594            {
 1595                Pipeline.LogMethodEnter(
 1596                    nameof(DataLakePathClient),
 1597                    message:
 1598                    $"{nameof(Uri)}: {Uri}\n" +
 1599                    $"{nameof(destinationFileSystem)}: {destinationFileSystem}\n" +
 1600                    $"{nameof(destinationPath)}: {destinationPath}\n" +
 1601                    $"{nameof(destinationConditions)}: {destinationConditions}\n" +
 1602                    $"{nameof(sourceConditions)}: {sourceConditions}");
 1603                try
 1604                {
 1605                    // Build renameSource
 2041606                    DataLakeUriBuilder sourceUriBuilder = new DataLakeUriBuilder(_dfsUri);
 2041607                    string renameSource = "/" + sourceUriBuilder.FileSystemName + "/" + sourceUriBuilder.DirectoryOrFile
 1608
 2041609                    if (sourceUriBuilder.Sas != null)
 1610                    {
 41611                        renameSource += "?" + sourceUriBuilder.Sas;
 1612                    }
 1613
 1614                    // Build destination URI
 2041615                    DataLakeUriBuilder destUriBuilder = new DataLakeUriBuilder(_dfsUri)
 2041616                    {
 2041617                        Sas = null,
 2041618                        Query = null
 2041619                    };
 2041620                    destUriBuilder.FileSystemName = destinationFileSystem ?? destUriBuilder.FileSystemName;
 1621
 1622                    // DataLakeUriBuider will encode the DirectoryOrFilePath.  We don't want the query parameters,
 1623                    // especially SAS, to be encoded.
 2041624                    string[] split = destinationPath.Split('?');
 2041625                    if (split.Length == 2)
 1626                    {
 41627                        destUriBuilder.DirectoryOrFilePath = split[0];
 41628                        destUriBuilder.Query = split[1];
 1629                    }
 1630                    else
 1631                    {
 2001632                        destUriBuilder.DirectoryOrFilePath = destinationPath;
 1633                    }
 1634
 1635                    // Build destPathClient
 2041636                    DataLakePathClient destPathClient = new DataLakePathClient(destUriBuilder.ToUri(), Pipeline);
 1637
 2041638                    Response<PathCreateResult> response = await DataLakeRestClient.Path.CreateAsync(
 2041639                        clientDiagnostics: _clientDiagnostics,
 2041640                        pipeline: Pipeline,
 2041641                        resourceUri: destPathClient.DfsUri,
 2041642                        version: Version.ToVersionString(),
 2041643                        mode: PathRenameMode.Legacy,
 2041644                        renameSource: renameSource,
 2041645                        leaseId: destinationConditions?.LeaseId,
 2041646                        sourceLeaseId: sourceConditions?.LeaseId,
 2041647                        ifMatch: destinationConditions?.IfMatch,
 2041648                        ifNoneMatch: destinationConditions?.IfNoneMatch,
 2041649                        ifModifiedSince: destinationConditions?.IfModifiedSince,
 2041650                        ifUnmodifiedSince: destinationConditions?.IfUnmodifiedSince,
 2041651                        sourceIfMatch: sourceConditions?.IfMatch,
 2041652                        sourceIfNoneMatch: sourceConditions?.IfNoneMatch,
 2041653                        sourceIfModifiedSince: sourceConditions?.IfModifiedSince,
 2041654                        sourceIfUnmodifiedSince: sourceConditions?.IfUnmodifiedSince,
 2041655                        async: async,
 2041656                        cancellationToken: cancellationToken)
 2041657                        .ConfigureAwait(false);
 1658
 1161659                    return Response.FromValue(
 1161660                        destPathClient,
 1161661                        response.GetRawResponse());
 1662                }
 881663                catch (Exception ex)
 1664                {
 1665                    Pipeline.LogException(ex);
 881666                    throw;
 1667                }
 1668                finally
 1669                {
 1670                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 1671                }
 1672            }
 1161673        }
 1674        #endregion Rename
 1675
 1676        #region Get Access Control
 1677        /// <summary>
 1678        /// The <see cref="GetAccessControl"/> operation returns the
 1679        /// access control data for a path.
 1680        ///
 1681        /// For more information, see
 1682        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties"
 1683        /// Get Properties</see>.
 1684        /// </summary>
 1685        /// <param name="userPrincipalName">
 1686        /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true",
 1687        /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response
 1688        /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names.
 1689        /// If "false", the values will be returned as Azure Active Directory Object IDs.The default
 1690        /// value is false. Note that group and application Object IDs are not translated because they
 1691        /// do not have unique friendly names.
 1692        /// </param>
 1693        /// <param name="conditions">
 1694        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1695        /// conditions on getting the path's access control.
 1696        /// </param>
 1697        /// <param name="cancellationToken">
 1698        /// Optional <see cref="CancellationToken"/> to propagate
 1699        /// notifications that the operation should be cancelled.
 1700        /// </param>
 1701        /// <returns>
 1702        /// A <see cref="Response{PathAccessControl}"/> describing the
 1703        /// path's access control.
 1704        /// </returns>
 1705        /// <remarks>
 1706        /// A <see cref="RequestFailedException"/> will be thrown if
 1707        /// a failure occurs.
 1708        /// </remarks>
 1709        public virtual Response<PathAccessControl> GetAccessControl(
 1710            bool? userPrincipalName = default,
 1711            DataLakeRequestConditions conditions = default,
 1712            CancellationToken cancellationToken = default)
 1713        {
 341714            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(GetAccessContro
 1715
 1716            try
 1717            {
 341718                scope.Start();
 1719
 341720                return GetAccessControlInternal(
 341721                    userPrincipalName,
 341722                    conditions,
 341723                    false, // async
 341724                    cancellationToken)
 341725                    .EnsureCompleted();
 1726            }
 41727            catch (Exception ex)
 1728            {
 41729                scope.Failed(ex);
 41730                throw;
 1731            }
 1732            finally
 1733            {
 341734                scope.Dispose();
 341735            }
 301736        }
 1737
 1738        /// <summary>
 1739        /// The <see cref="GetAccessControlAsync"/> operation returns the
 1740        /// access control data for a path.
 1741        ///
 1742        /// For more information, see
 1743        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties"
 1744        /// Get Properties</see>.
 1745        /// </summary>
 1746        /// <param name="userPrincipalName">
 1747        /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true",
 1748        /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response
 1749        /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names.
 1750        /// If "false", the values will be returned as Azure Active Directory Object IDs.The default
 1751        /// value is false. Note that group and application Object IDs are not translated because they
 1752        /// do not have unique friendly names.
 1753        /// </param>
 1754        /// <param name="conditions">
 1755        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1756        /// conditions on getting the path's access control.
 1757        /// </param>
 1758        /// <param name="cancellationToken">
 1759        /// Optional <see cref="CancellationToken"/> to propagate
 1760        /// notifications that the operation should be cancelled.
 1761        /// </param>
 1762        /// <returns>
 1763        /// A <see cref="Response{PathAccessControl}"/> describing the
 1764        /// path's access control.
 1765        /// </returns>
 1766        /// <remarks>
 1767        /// A <see cref="RequestFailedException"/> will be thrown if
 1768        /// a failure occurs.
 1769        /// </remarks>
 1770        public virtual async Task<Response<PathAccessControl>> GetAccessControlAsync(
 1771            bool? userPrincipalName = default,
 1772            DataLakeRequestConditions conditions = default,
 1773            CancellationToken cancellationToken = default)
 1774        {
 1101775            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(GetAccessContro
 1776
 1777            try
 1778            {
 1101779                scope.Start();
 1780
 1101781                return await GetAccessControlInternal(
 1101782                    userPrincipalName,
 1101783                    conditions,
 1101784                    true, // async
 1101785                    cancellationToken)
 1101786                    .ConfigureAwait(false);
 1787            }
 41788            catch (Exception ex)
 1789            {
 41790                scope.Failed(ex);
 41791                throw;
 1792            }
 1793            finally
 1794            {
 1101795                scope.Dispose();
 1796            }
 1061797        }
 1798
 1799        /// <summary>
 1800        /// The <see cref="GetAccessControlInternal"/> operation returns the
 1801        /// access control data for a path.
 1802        ///
 1803        /// For more information, see
 1804        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties"
 1805        /// Get Properties</see>.
 1806        /// </summary>
 1807        /// <param name="userPrincipalName">
 1808        /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true",
 1809        /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response
 1810        /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names.
 1811        /// If "false", the values will be returned as Azure Active Directory Object IDs.The default
 1812        /// value is false. Note that group and application Object IDs are not translated because they
 1813        /// do not have unique friendly names.
 1814        /// </param>
 1815        /// <param name="conditions">
 1816        /// Optional <see cref="DataLakeRequestConditions"/> to add
 1817        /// conditions on getting the path's access control.
 1818        /// </param>
 1819        /// <param name="async">
 1820        /// Whether to invoke the operation asynchronously.
 1821        /// </param>
 1822        /// <param name="cancellationToken">
 1823        /// Optional <see cref="CancellationToken"/> to propagate
 1824        /// notifications that the operation should be cancelled.
 1825        /// </param>
 1826        /// <returns>
 1827        /// A <see cref="Response{PathAccessControl}"/> describing the
 1828        /// path's access control.
 1829        /// </returns>
 1830        /// <remarks>
 1831        /// A <see cref="RequestFailedException"/> will be thrown if
 1832        /// a failure occurs.
 1833        /// </remarks>
 1834        private async Task<Response<PathAccessControl>> GetAccessControlInternal(
 1835            bool? userPrincipalName,
 1836            DataLakeRequestConditions conditions,
 1837            bool async,
 1838            CancellationToken cancellationToken)
 1839        {
 1441840            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 1841            {
 1842                Pipeline.LogMethodEnter(
 1843                    nameof(DataLakePathClient),
 1844                    message:
 1845                    $"{nameof(Uri)}: {Uri}\n");
 1846                try
 1847                {
 1441848                    Response<PathGetPropertiesResult> response = await DataLakeRestClient.Path.GetPropertiesAsync(
 1441849                        clientDiagnostics: _clientDiagnostics,
 1441850                        pipeline: Pipeline,
 1441851                        resourceUri: _dfsUri,
 1441852                        version: Version.ToVersionString(),
 1441853                        action: PathGetPropertiesAction.GetAccessControl,
 1441854                        upn: userPrincipalName,
 1441855                        leaseId: conditions?.LeaseId,
 1441856                        ifMatch: conditions?.IfMatch,
 1441857                        ifNoneMatch: conditions?.IfNoneMatch,
 1441858                        ifModifiedSince: conditions?.IfModifiedSince,
 1441859                        ifUnmodifiedSince: conditions?.IfUnmodifiedSince,
 1441860                        async: async,
 1441861                        cancellationToken: cancellationToken)
 1441862                        .ConfigureAwait(false);
 1863
 1361864                    return Response.FromValue(
 1361865                        new PathAccessControl()
 1361866                        {
 1361867                            Owner = response.Value.Owner,
 1361868                            Group = response.Value.Group,
 1361869                            Permissions = PathPermissions.ParseSymbolicPermissions(response.Value.Permissions),
 1361870                            AccessControlList = PathAccessControlExtensions.ParseAccessControlList(response.Value.ACL)
 1361871                        },
 1361872                        response.GetRawResponse());
 1873                }
 81874                catch (Exception ex)
 1875                {
 1876                    Pipeline.LogException(ex);
 81877                    throw;
 1878                }
 1879                finally
 1880                {
 1881                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 1882                }
 1883            }
 1361884        }
 1885        #endregion Get Access Control
 1886
 1887        #region Set Access Control
 1888        /// <summary>
 1889        /// The <see cref="SetAccessControlList"/> operation sets the
 1890        /// Access Control on a path
 1891        ///
 1892        /// For more information, see
 1893        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 1894        /// Update Path</see>.
 1895        /// </summary>
 1896        /// <param name="accessControlList">
 1897        /// The POSIX access control list for the file or directory.
 1898        /// </param>
 1899        /// <param name="owner">
 1900        /// The owner of the file or directory.
 1901        /// </param>
 1902        /// <param name="group">
 1903        /// The owning group of the file or directory.
 1904        /// </param>
 1905        /// <param name="conditions">
 1906        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1907        /// setting the the path's access control.
 1908        /// </param>
 1909        /// <param name="cancellationToken">
 1910        /// Optional <see cref="CancellationToken"/> to propagate
 1911        /// notifications that the operation should be cancelled.
 1912        /// </param>
 1913        /// <returns>
 1914        /// A <see cref="Response{PathInfo}"/> describing the updated
 1915        /// path.
 1916        /// </returns>
 1917        /// <remarks>
 1918        /// A <see cref="RequestFailedException"/> will be thrown if
 1919        /// a failure occurs.
 1920        /// </remarks>
 1921        public virtual Response<PathInfo> SetAccessControlList(
 1922            IList<PathAccessControlItem> accessControlList,
 1923            string owner = default,
 1924            string group = default,
 1925            DataLakeRequestConditions conditions = default,
 1926            CancellationToken cancellationToken = default)
 1927        {
 01928            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetAccessContro
 1929
 1930            try
 1931            {
 01932                scope.Start();
 1933
 01934                return SetAccessControlListInternal(
 01935                    accessControlList,
 01936                    owner,
 01937                    group,
 01938                    conditions,
 01939                    false, // async
 01940                    cancellationToken)
 01941                    .EnsureCompleted();
 1942            }
 01943            catch (Exception ex)
 1944            {
 01945                scope.Failed(ex);
 01946                throw;
 1947            }
 1948            finally
 1949            {
 01950                scope.Dispose();
 01951            }
 01952        }
 1953
 1954        /// <summary>
 1955        /// The <see cref="SetAccessControlListAsync"/> operation sets the
 1956        /// Access Control on a path
 1957        ///
 1958        /// For more information, see
 1959        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 1960        /// Update Path</see>.
 1961        /// </summary>
 1962        /// <param name="accessControlList">
 1963        /// The POSIX access control list for the file or directory.
 1964        /// </param>
 1965        /// <param name="owner">
 1966        /// The owner of the file or directory.
 1967        /// </param>
 1968        /// <param name="group">
 1969        /// The owning group of the file or directory.
 1970        /// </param>
 1971        /// <param name="conditions">
 1972        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 1973        /// setting the the path's access control.
 1974        /// </param>
 1975        /// <param name="cancellationToken">
 1976        /// Optional <see cref="CancellationToken"/> to propagate
 1977        /// notifications that the operation should be cancelled.
 1978        /// </param>
 1979        /// <returns>
 1980        /// A <see cref="Response{PathInfo}"/> describing the updated
 1981        /// path.
 1982        /// </returns>
 1983        /// <remarks>
 1984        /// A <see cref="RequestFailedException"/> will be thrown if
 1985        /// a failure occurs.
 1986        /// </remarks>
 1987        public virtual async Task<Response<PathInfo>> SetAccessControlListAsync(
 1988            IList<PathAccessControlItem> accessControlList,
 1989            string owner = default,
 1990            string group = default,
 1991            DataLakeRequestConditions conditions = default,
 1992            CancellationToken cancellationToken = default)
 1993        {
 961994            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetAccessContro
 1995
 1996            try
 1997            {
 961998                scope.Start();
 1999
 962000                return await SetAccessControlListInternal(
 962001                    accessControlList,
 962002                    owner,
 962003                    group,
 962004                    conditions,
 962005                    true, // async
 962006                    cancellationToken)
 962007                    .ConfigureAwait(false);
 2008            }
 402009            catch (Exception ex)
 2010            {
 402011                scope.Failed(ex);
 402012                throw;
 2013            }
 2014            finally
 2015            {
 962016                scope.Dispose();
 2017            }
 562018        }
 2019
 2020        /// <summary>
 2021        /// The <see cref="SetAccessControlListInternal"/> operation sets the
 2022        /// Access Control on a path
 2023        ///
 2024        /// For more information, see
 2025        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 2026        /// Update Path</see>.
 2027        /// </summary>
 2028        /// <param name="accessControlList">
 2029        /// The POSIX access control list for the file or directory.
 2030        /// </param>
 2031        /// <param name="owner">
 2032        /// The owner of the file or directory.
 2033        /// </param>
 2034        /// <param name="group">
 2035        /// The owning group of the file or directory.
 2036        /// </param>
 2037        /// <param name="conditions">
 2038        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2039        /// setting the the path's access control.
 2040        /// </param>
 2041        /// <param name="async">
 2042        /// Whether to invoke the operation asynchronously.
 2043        /// </param>
 2044        /// <param name="cancellationToken">
 2045        /// Optional <see cref="CancellationToken"/> to propagate
 2046        /// notifications that the operation should be cancelled.
 2047        /// </param>
 2048        /// <returns>
 2049        /// A <see cref="Response{PathInfo}"/> describing the updated
 2050        /// path.
 2051        /// </returns>
 2052        /// <remarks>
 2053        /// A <see cref="RequestFailedException"/> will be thrown if
 2054        /// a failure occurs.
 2055        /// </remarks>
 2056        private async Task<Response<PathInfo>> SetAccessControlListInternal(
 2057            IList<PathAccessControlItem> accessControlList,
 2058            string owner,
 2059            string group,
 2060            DataLakeRequestConditions conditions,
 2061            bool async,
 2062            CancellationToken cancellationToken)
 2063        {
 962064            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 2065            {
 2066                Pipeline.LogMethodEnter(
 2067                    nameof(DataLakePathClient),
 2068                    message:
 2069                    $"{nameof(Uri)}: {Uri}\n" +
 2070                    $"{nameof(accessControlList)}: {accessControlList}\n" +
 2071                    $"{nameof(owner)}: {owner}\n" +
 2072                    $"{nameof(group)}: {group}\n" +
 2073                    $"{nameof(conditions)}: {conditions}");
 2074                try
 2075                {
 962076                    Response<PathSetAccessControlResult> response =
 962077                        await DataLakeRestClient.Path.SetAccessControlAsync(
 962078                            clientDiagnostics: _clientDiagnostics,
 962079                            pipeline: Pipeline,
 962080                            resourceUri: _dfsUri,
 962081                            version: Version.ToVersionString(),
 962082                            leaseId: conditions?.LeaseId,
 962083                            owner: owner,
 962084                            group: group,
 962085                            acl: PathAccessControlExtensions.ToAccessControlListString(accessControlList),
 962086                            ifMatch: conditions?.IfMatch,
 962087                            ifNoneMatch: conditions?.IfNoneMatch,
 962088                            ifModifiedSince: conditions?.IfModifiedSince,
 962089                            ifUnmodifiedSince: conditions?.IfUnmodifiedSince,
 962090                            async: async,
 962091                            cancellationToken: cancellationToken)
 962092                        .ConfigureAwait(false);
 2093
 562094                    return Response.FromValue(
 562095                        new PathInfo()
 562096                        {
 562097                            ETag = response.Value.ETag,
 562098                            LastModified = response.Value.LastModified
 562099                        },
 562100                        response.GetRawResponse());
 2101                }
 402102                catch (Exception ex)
 2103                {
 2104                    Pipeline.LogException(ex);
 402105                    throw;
 2106                }
 2107                finally
 2108                {
 2109                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 2110                }
 2111            }
 562112        }
 2113        #endregion Set Access Control
 2114
 2115        #region Set Permissions
 2116        /// <summary>
 2117        /// The <see cref="SetPermissions"/> operation sets the
 2118        /// file permissions on a path.
 2119        ///
 2120        /// For more information, see
 2121        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 2122        /// Update Path</see>.
 2123        /// </summary>
 2124        /// <param name="permissions">
 2125        ///  The POSIX access permissions for the file owner, the file owning group, and others.
 2126        /// </param>
 2127        /// <param name="owner">
 2128        /// The owner of the file or directory.
 2129        /// </param>
 2130        /// <param name="group">
 2131        /// The owning group of the file or directory.
 2132        /// </param>
 2133        /// <param name="conditions">
 2134        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2135        /// setting the the path's access control.
 2136        /// </param>
 2137        /// <param name="cancellationToken">
 2138        /// Optional <see cref="CancellationToken"/> to propagate
 2139        /// notifications that the operation should be cancelled.
 2140        /// </param>
 2141        /// <returns>
 2142        /// A <see cref="Response{PathInfo}"/> describing the updated
 2143        /// path.
 2144        /// </returns>
 2145        /// <remarks>
 2146        /// A <see cref="RequestFailedException"/> will be thrown if
 2147        /// a failure occurs.
 2148        /// </remarks>
 2149        public virtual Response<PathInfo> SetPermissions(
 2150            PathPermissions permissions,
 2151            string owner = default,
 2152            string group = default,
 2153            DataLakeRequestConditions conditions = default,
 2154            CancellationToken cancellationToken = default)
 2155        {
 42156            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetPermissions)
 2157
 2158            try
 2159            {
 42160                scope.Start();
 2161
 42162                return SetPermissionsInternal(
 42163                    permissions,
 42164                    owner,
 42165                    group,
 42166                    conditions,
 42167                    false, // async
 42168                    cancellationToken)
 42169                    .EnsureCompleted();
 2170            }
 02171            catch (Exception ex)
 2172            {
 02173                scope.Failed(ex);
 02174                throw;
 2175            }
 2176            finally
 2177            {
 42178                scope.Dispose();
 42179            }
 2180
 42181        }
 2182
 2183        /// <summary>
 2184        /// The <see cref="SetPermissionsAsync"/> operation sets the
 2185        /// file permissions on a path.
 2186        ///
 2187        /// For more information, see
 2188        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 2189        /// Update Path</see>.
 2190        /// </summary>
 2191        /// <param name="permissions">
 2192        ///  The POSIX access permissions for the file owner, the file owning group, and others.
 2193        /// </param>
 2194        /// <param name="owner">
 2195        /// The owner of the file or directory.
 2196        /// </param>
 2197        /// <param name="group">
 2198        /// The owning group of the file or directory.
 2199        /// </param>
 2200        /// <param name="conditions">
 2201        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2202        /// setting the the path's access control.
 2203        /// </param>
 2204        /// <param name="cancellationToken">
 2205        /// Optional <see cref="CancellationToken"/> to propagate
 2206        /// notifications that the operation should be cancelled.
 2207        /// </param>
 2208        /// <returns>
 2209        /// A <see cref="Response{PathInfo}"/> describing the updated
 2210        /// path.
 2211        /// </returns>
 2212        /// <remarks>
 2213        /// A <see cref="RequestFailedException"/> will be thrown if
 2214        /// a failure occurs.
 2215        /// </remarks>
 2216        public virtual async Task<Response<PathInfo>> SetPermissionsAsync(
 2217            PathPermissions permissions,
 2218            string owner = default,
 2219            string group = default,
 2220            DataLakeRequestConditions conditions = default,
 2221            CancellationToken cancellationToken = default)
 2222        {
 1002223            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetPermissions)
 2224
 2225            try
 2226            {
 1002227                scope.Start();
 2228
 1002229                return await SetPermissionsInternal(
 1002230                    permissions,
 1002231                    owner,
 1002232                    group,
 1002233                    conditions,
 1002234                    true, // async
 1002235                    cancellationToken)
 1002236                    .ConfigureAwait(false);
 2237            }
 402238            catch (Exception ex)
 2239            {
 402240                scope.Failed(ex);
 402241                throw;
 2242            }
 2243            finally
 2244            {
 1002245                scope.Dispose();
 2246            }
 602247        }
 2248
 2249        /// <summary>
 2250        /// The <see cref="SetPermissionsInternal"/> operation sets the
 2251        /// file permissions on a path.
 2252        ///
 2253        /// For more information, see
 2254        /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update">
 2255        /// Update Path</see>.
 2256        /// </summary>
 2257        /// <param name="permissions">
 2258        ///  The POSIX access permissions for the file owner, the file owning group, and others.
 2259        /// </param>
 2260        /// <param name="owner">
 2261        /// The owner of the file or directory.
 2262        /// </param>
 2263        /// <param name="group">
 2264        /// The owning group of the file or directory.
 2265        /// </param>
 2266        /// <param name="conditions">
 2267        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2268        /// setting the the path's access control.
 2269        /// </param>
 2270        /// <param name="async">
 2271        /// Whether to invoke the operation asynchronously.
 2272        /// </param>
 2273        /// <param name="cancellationToken">
 2274        /// Optional <see cref="CancellationToken"/> to propagate
 2275        /// notifications that the operation should be cancelled.
 2276        /// </param>
 2277        /// <returns>
 2278        /// A <see cref="Response{PathInfo}"/> describing the updated
 2279        /// path.
 2280        /// </returns>
 2281        /// <remarks>
 2282        /// A <see cref="RequestFailedException"/> will be thrown if
 2283        /// a failure occurs.
 2284        /// </remarks>
 2285        private async Task<Response<PathInfo>> SetPermissionsInternal(
 2286            PathPermissions permissions,
 2287            string owner,
 2288            string group,
 2289            DataLakeRequestConditions conditions,
 2290            bool async,
 2291            CancellationToken cancellationToken)
 2292        {
 1042293            using (Pipeline.BeginLoggingScope(nameof(DataLakePathClient)))
 2294            {
 2295                Pipeline.LogMethodEnter(
 2296                    nameof(DataLakePathClient),
 2297                    message:
 2298                    $"{nameof(Uri)}: {Uri}\n" +
 2299                    $"{nameof(permissions)}: {permissions}\n" +
 2300                    $"{nameof(owner)}: {owner}\n" +
 2301                    $"{nameof(group)}: {group}\n" +
 2302                    $"{nameof(conditions)}: {conditions}");
 2303                try
 2304                {
 1042305                    Response<PathSetAccessControlResult> response =
 1042306                        await DataLakeRestClient.Path.SetAccessControlAsync(
 1042307                            clientDiagnostics: _clientDiagnostics,
 1042308                            pipeline: Pipeline,
 1042309                            resourceUri: _dfsUri,
 1042310                            version: Version.ToVersionString(),
 1042311                            leaseId: conditions?.LeaseId,
 1042312                            owner: owner,
 1042313                            group: group,
 1042314                            permissions: permissions.ToSymbolicPermissions(),
 1042315                            ifMatch: conditions?.IfMatch,
 1042316                            ifNoneMatch: conditions?.IfNoneMatch,
 1042317                            ifModifiedSince: conditions?.IfModifiedSince,
 1042318                            ifUnmodifiedSince: conditions?.IfUnmodifiedSince,
 1042319                            async: async,
 1042320                            cancellationToken: cancellationToken)
 1042321                        .ConfigureAwait(false);
 2322
 642323                    return Response.FromValue(
 642324                        new PathInfo()
 642325                        {
 642326                            ETag = response.Value.ETag,
 642327                            LastModified = response.Value.LastModified
 642328                        },
 642329                        response.GetRawResponse());
 2330                }
 402331                catch (Exception ex)
 2332                {
 2333                    Pipeline.LogException(ex);
 402334                    throw;
 2335                }
 2336                finally
 2337                {
 2338                    Pipeline.LogMethodExit(nameof(DataLakePathClient));
 2339                }
 2340            }
 642341        }
 2342        #endregion Set Permission
 2343
 2344        #region Get Properties
 2345        /// <summary>
 2346        /// The <see cref="GetProperties"/> operation returns all
 2347        /// user-defined metadata, standard HTTP properties, and system
 2348        /// properties for the path. It does not return the content of the
 2349        /// path.
 2350        ///
 2351        /// For more information, see
 2352        /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties">
 2353        /// Get Properties</see>.
 2354        /// </summary>
 2355        /// <param name="conditions">
 2356        /// Optional <see cref="DataLakeRequestConditions"/> to add
 2357        /// conditions on getting the path's properties.
 2358        /// </param>
 2359        /// <param name="cancellationToken">
 2360        /// Optional <see cref="CancellationToken"/> to propagate
 2361        /// notifications that the operation should be cancelled.
 2362        /// </param>
 2363        /// <returns>
 2364        /// A <see cref="Response{PathProperties}"/> describing the
 2365        /// path's properties.
 2366        /// </returns>
 2367        /// <remarks>
 2368        /// A <see cref="RequestFailedException"/> will be thrown if
 2369        /// a failure occurs.
 2370        /// </remarks>
 2371        public virtual Response<PathProperties> GetProperties(
 2372            DataLakeRequestConditions conditions = default,
 2373            CancellationToken cancellationToken = default)
 2374        {
 682375            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(GetProperties)}
 2376
 2377            try
 2378            {
 682379                scope.Start();
 2380
 682381                Response<Blobs.Models.BlobProperties> response = _blockBlobClient.GetProperties(
 682382                    conditions.ToBlobRequestConditions(),
 682383                    cancellationToken);
 2384
 642385                return Response.FromValue(
 642386                    response.Value.ToPathProperties(),
 642387                    response.GetRawResponse());
 2388            }
 42389            catch (Exception ex)
 2390            {
 42391                scope.Failed(ex);
 42392                throw;
 2393            }
 2394            finally
 2395            {
 682396                scope.Dispose();
 682397            }
 642398        }
 2399
 2400        /// <summary>
 2401        /// The <see cref="GetPropertiesAsync"/> operation returns all
 2402        /// user-defined metadata, standard HTTP properties, and system
 2403        /// properties for the path. It does not return the content of the
 2404        /// path.
 2405        ///
 2406        /// For more information, see
 2407        /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties">
 2408        /// Get Properties</see>.
 2409        /// </summary>
 2410        /// <param name="conditions">
 2411        /// Optional <see cref="DataLakeRequestConditions"/> to add
 2412        /// conditions on getting the path's properties.
 2413        /// </param>
 2414        /// <param name="cancellationToken">
 2415        /// Optional <see cref="CancellationToken"/> to propagate
 2416        /// notifications that the operation should be cancelled.
 2417        /// </param>
 2418        /// <returns>
 2419        /// A <see cref="Response{PathProperties}"/> describing the
 2420        /// paths's properties.
 2421        /// </returns>
 2422        /// <remarks>
 2423        /// A <see cref="RequestFailedException"/> will be thrown if
 2424        /// a failure occurs.
 2425        /// </remarks>
 2426        public virtual async Task<Response<PathProperties>> GetPropertiesAsync(
 2427            DataLakeRequestConditions conditions = default,
 2428            CancellationToken cancellationToken = default)
 2429        {
 6162430            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(GetProperties)}
 2431
 2432            try
 2433            {
 6162434                scope.Start();
 2435
 6162436                Response<Blobs.Models.BlobProperties> response = await _blockBlobClient.GetPropertiesAsync(
 6162437                    conditions.ToBlobRequestConditions(),
 6162438                    cancellationToken)
 6162439                    .ConfigureAwait(false);
 2440
 5722441                return Response.FromValue(
 5722442                    response.Value.ToPathProperties(),
 5722443                    response.GetRawResponse());
 2444            }
 442445            catch (Exception ex)
 2446            {
 442447                scope.Failed(ex);
 442448                throw;
 2449            }
 2450            finally
 2451            {
 6162452                scope.Dispose();
 2453            }
 5722454        }
 2455        #endregion Get Properties
 2456
 2457        #region Set Http Headers
 2458        /// <summary>
 2459        /// The <see cref="SetHttpHeaders"/> operation sets system
 2460        /// properties on the path.
 2461        ///
 2462        /// For more information, see
 2463        /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties">
 2464        /// Set Properties</see>.
 2465        /// </summary>
 2466        /// <param name="httpHeaders">
 2467        /// Optional. The standard HTTP header system properties to set.  If not specified, existing values will be clea
 2468        /// </param>
 2469        /// <param name="conditions">
 2470        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2471        /// setting the paths's HTTP headers.
 2472        /// </param>
 2473        /// <param name="cancellationToken">
 2474        /// Optional <see cref="CancellationToken"/> to propagate
 2475        /// notifications that the operation should be cancelled.
 2476        /// </param>
 2477        /// <returns>
 2478        /// A <see cref="Response{httpHeaders}"/> describing the updated
 2479        /// path.
 2480        /// </returns>
 2481        /// <remarks>
 2482        /// A <see cref="RequestFailedException"/> will be thrown if
 2483        /// a failure occurs.
 2484        /// </remarks>
 2485        public virtual Response<PathInfo> SetHttpHeaders(
 2486            PathHttpHeaders httpHeaders = default,
 2487            DataLakeRequestConditions conditions = default,
 2488            CancellationToken cancellationToken = default)
 2489        {
 42490            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetHttpHeaders)
 2491
 2492            try
 2493            {
 42494                scope.Start();
 2495
 42496                Response<Blobs.Models.BlobInfo> response = _blockBlobClient.SetHttpHeaders(
 42497                    httpHeaders.ToBlobHttpHeaders(),
 42498                    conditions.ToBlobRequestConditions(),
 42499                    cancellationToken);
 2500
 02501                return Response.FromValue(
 02502                    response.Value.ToPathInfo(),
 02503                    response.GetRawResponse());
 2504            }
 42505            catch (Exception ex)
 2506            {
 42507                scope.Failed(ex);
 42508                throw;
 2509            }
 2510            finally
 2511            {
 42512                scope.Dispose();
 42513            }
 02514        }
 2515
 2516        /// <summary>
 2517        /// The <see cref="SetHttpHeadersAsync"/> operation sets system
 2518        /// properties on the PATH.
 2519        ///
 2520        /// For more information, see
 2521        /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties">
 2522        /// Set Properties</see>.
 2523        /// </summary>
 2524        /// <param name="httpHeaders">
 2525        /// Optional. The standard HTTP header system properties to set.  If not specified, existing values will be clea
 2526        /// </param>
 2527        /// <param name="conditions">
 2528        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2529        /// setting the path's HTTP headers.
 2530        /// </param>
 2531        /// <param name="cancellationToken">
 2532        /// Optional <see cref="CancellationToken"/> to propagate
 2533        /// notifications that the operation should be cancelled.
 2534        /// </param>
 2535        /// <returns>
 2536        /// A <see cref="Response{PathInfo}"/> describing the updated
 2537        /// path.
 2538        /// </returns>
 2539        /// <remarks>
 2540        /// A <see cref="RequestFailedException"/> will be thrown if
 2541        /// a failure occurs.
 2542        /// </remarks>
 2543        public virtual async Task<Response<PathInfo>> SetHttpHeadersAsync(
 2544            PathHttpHeaders httpHeaders = default,
 2545            DataLakeRequestConditions conditions = default,
 2546            CancellationToken cancellationToken = default)
 2547        {
 1002548            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetHttpHeaders)
 2549
 2550            try
 2551            {
 1002552                scope.Start();
 2553
 1002554                Response<Blobs.Models.BlobInfo> response = await _blockBlobClient.SetHttpHeadersAsync(
 1002555                    httpHeaders.ToBlobHttpHeaders(),
 1002556                    conditions.ToBlobRequestConditions(),
 1002557                    cancellationToken)
 1002558                    .ConfigureAwait(false);
 2559
 562560                return Response.FromValue(
 562561                    response.Value.ToPathInfo(),
 562562                    response.GetRawResponse());
 2563            }
 442564            catch (Exception ex)
 2565            {
 442566                scope.Failed(ex);
 442567                throw;
 2568            }
 2569            finally
 2570            {
 1002571                scope.Dispose();
 2572            }
 562573        }
 2574        #endregion Set Http Headers
 2575
 2576        #region Set Metadata
 2577        /// <summary>
 2578        /// The <see cref="SetMetadata"/> operation sets user-defined
 2579        /// metadata for the specified path as one or more name-value pairs.
 2580        ///
 2581        /// For more information, see
 2582        /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata">
 2583        /// Set Metadata</see>.
 2584        /// </summary>
 2585        /// <param name="metadata">
 2586        /// Custom metadata to set for this path.
 2587        /// </param>
 2588        /// <param name="conditions">
 2589        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2590        /// setting the path's metadata.
 2591        /// </param>
 2592        /// <param name="cancellationToken">
 2593        /// Optional <see cref="CancellationToken"/> to propagate
 2594        /// notifications that the operation should be cancelled.
 2595        /// </param>
 2596        /// <returns>
 2597        /// A <see cref="Response{PathInfo}"/> describing the updated
 2598        /// path.
 2599        /// </returns>
 2600        /// <remarks>
 2601        /// A <see cref="RequestFailedException"/> will be thrown if
 2602        /// a failure occurs.
 2603        /// </remarks>
 2604        public virtual Response<PathInfo> SetMetadata(
 2605            Metadata metadata,
 2606            DataLakeRequestConditions conditions = default,
 2607            CancellationToken cancellationToken = default)
 2608        {
 42609            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetMetadata)}")
 2610
 2611            try
 2612            {
 42613                scope.Start();
 2614
 42615                Response<Blobs.Models.BlobInfo> response = _blockBlobClient.SetMetadata(
 42616                    metadata,
 42617                    conditions.ToBlobRequestConditions());
 2618
 02619                return Response.FromValue(
 02620                    response.Value.ToPathInfo(),
 02621                    response.GetRawResponse());
 2622            }
 42623            catch (Exception ex)
 2624            {
 42625                scope.Failed(ex);
 42626                throw;
 2627            }
 2628            finally
 2629            {
 42630                scope.Dispose();
 42631            }
 02632        }
 2633
 2634        /// <summary>
 2635        /// The <see cref="SetMetadataAsync"/> operation sets user-defined
 2636        /// metadata for the specified path as one or more name-value pairs.
 2637        ///
 2638        ///For more information, see
 2639        /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata">
 2640        /// Set Metadata</see>.
 2641        /// </summary>
 2642        /// <param name="metadata">
 2643        /// Custom metadata to set for this path.
 2644        /// </param>
 2645        /// <param name="conditions">
 2646        /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on
 2647        /// setting the path's metadata.
 2648        /// </param>
 2649        /// <param name="cancellationToken">
 2650        /// Optional <see cref="CancellationToken"/> to propagate
 2651        /// notifications that the operation should be cancelled.
 2652        /// </param>
 2653        /// <returns>
 2654        /// A <see cref="Response{BlobInfo}"/> describing the updated
 2655        /// path.
 2656        /// </returns>
 2657        /// <remarks>
 2658        /// A <see cref="RequestFailedException"/> will be thrown if
 2659        /// a failure occurs.
 2660        /// </remarks>
 2661        public virtual async Task<Response<PathInfo>> SetMetadataAsync(
 2662            Metadata metadata,
 2663            DataLakeRequestConditions conditions = default,
 2664            CancellationToken cancellationToken = default)
 2665        {
 1002666            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakePathClient)}.{nameof(SetMetadata)}")
 2667
 2668            try
 2669            {
 1002670                scope.Start();
 2671
 1002672                Response<Blobs.Models.BlobInfo> response = await _blockBlobClient.SetMetadataAsync(
 1002673                    metadata,
 1002674                    conditions.ToBlobRequestConditions())
 1002675                    .ConfigureAwait(false);
 2676
 562677                return Response.FromValue(
 562678                    response.Value.ToPathInfo(),
 562679                    response.GetRawResponse());
 2680            }
 442681            catch (Exception ex)
 2682            {
 442683                scope.Failed(ex);
 442684                throw;
 2685            }
 2686            finally
 2687            {
 1002688                scope.Dispose();
 2689            }
 562690        }
 2691        #endregion Set Metadata
 2692    }
 2693}