| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Threading; |
| | 7 | | using System.Threading.Tasks; |
| | 8 | | using Azure.Core; |
| | 9 | | using Azure.Core.Pipeline; |
| | 10 | | using Azure.Storage.Files.DataLake.Models; |
| | 11 | | using Metadata = System.Collections.Generic.IDictionary<string, string>; |
| | 12 | |
|
| | 13 | | namespace Azure.Storage.Files.DataLake |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// A DirectoryClient represents a URI to the Azure DataLake service allowing you to manipulate a directory. |
| | 17 | | /// </summary> |
| | 18 | | public class DataLakeDirectoryClient : DataLakePathClient |
| | 19 | | { |
| | 20 | | #region ctors |
| | 21 | | /// <summary> |
| | 22 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 23 | | /// class for mocking. |
| | 24 | | /// </summary> |
| 474 | 25 | | protected DataLakeDirectoryClient() |
| | 26 | | { |
| 474 | 27 | | } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 31 | | /// class. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="directoryUri"> |
| | 34 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 35 | | /// name of the account, the name of the file system, and the path of the |
| | 36 | | /// directory. |
| | 37 | | /// </param> |
| | 38 | | public DataLakeDirectoryClient(Uri directoryUri) |
| 0 | 39 | | : this(directoryUri, (HttpPipelinePolicy)null, null) |
| | 40 | | { |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 45 | | /// class. |
| | 46 | | /// </summary> |
| | 47 | | /// <param name="directoryUri"> |
| | 48 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 49 | | /// name of the account, the name of the file system, and the path of the |
| | 50 | | /// directory. |
| | 51 | | /// </param> |
| | 52 | | /// <param name="options"> |
| | 53 | | /// Optional <see cref="DataLakeClientOptions"/> that define the transport |
| | 54 | | /// pipeline policies for authentication, retries, etc., that are |
| | 55 | | /// applied to every request. |
| | 56 | | /// </param> |
| | 57 | | public DataLakeDirectoryClient(Uri directoryUri, DataLakeClientOptions options) |
| 20 | 58 | | : this(directoryUri, (HttpPipelinePolicy)null, options) |
| | 59 | | { |
| 20 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> |
| | 63 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 64 | | /// class. |
| | 65 | | /// </summary> |
| | 66 | | /// <param name="directoryUri"> |
| | 67 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 68 | | /// name of the account, the name of the file system, and the path of the |
| | 69 | | /// directory. |
| | 70 | | /// </param> |
| | 71 | | /// <param name="credential"> |
| | 72 | | /// The shared key credential used to sign requests. |
| | 73 | | /// </param> |
| | 74 | | public DataLakeDirectoryClient(Uri directoryUri, StorageSharedKeyCredential credential) |
| 0 | 75 | | : this(directoryUri, credential.AsPolicy(), null) |
| | 76 | | { |
| 0 | 77 | | } |
| | 78 | |
|
| | 79 | | /// <summary> |
| | 80 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 81 | | /// class. |
| | 82 | | /// </summary> |
| | 83 | | /// <param name="directoryUri"> |
| | 84 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 85 | | /// name of the account, the name of the file system, and the path of the |
| | 86 | | /// directory. |
| | 87 | | /// </param> |
| | 88 | | /// <param name="credential"> |
| | 89 | | /// The shared key credential used to sign requests. |
| | 90 | | /// </param> |
| | 91 | | /// <param name="options"> |
| | 92 | | /// Optional client options that define the transport pipeline |
| | 93 | | /// policies for authentication, retries, etc., that are applied to |
| | 94 | | /// every request. |
| | 95 | | /// </param> |
| | 96 | | public DataLakeDirectoryClient(Uri directoryUri, StorageSharedKeyCredential credential, DataLakeClientOptions op |
| 4 | 97 | | : this(directoryUri, credential.AsPolicy(), options) |
| | 98 | | { |
| 4 | 99 | | } |
| | 100 | |
|
| | 101 | | /// <summary> |
| | 102 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 103 | | /// class. |
| | 104 | | /// </summary> |
| | 105 | | /// <param name="directoryUri"> |
| | 106 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 107 | | /// name of the account, the name of the file system, and the path of the |
| | 108 | | /// directory. |
| | 109 | | /// </param> |
| | 110 | | /// <param name="credential"> |
| | 111 | | /// The token credential used to sign requests. |
| | 112 | | /// </param> |
| | 113 | | public DataLakeDirectoryClient(Uri directoryUri, TokenCredential credential) |
| 4 | 114 | | : this(directoryUri, credential.AsPolicy(), null) |
| | 115 | | { |
| 4 | 116 | | Errors.VerifyHttpsTokenAuth(directoryUri); |
| 0 | 117 | | } |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 121 | | /// class. |
| | 122 | | /// </summary> |
| | 123 | | /// <param name="directoryUri"> |
| | 124 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 125 | | /// name of the account, the name of the file system, and the path of the |
| | 126 | | /// directory. |
| | 127 | | /// </param> |
| | 128 | | /// <param name="credential"> |
| | 129 | | /// The token credential used to sign requests. |
| | 130 | | /// </param> |
| | 131 | | /// <param name="options"> |
| | 132 | | /// Optional client options that define the transport pipeline |
| | 133 | | /// policies for authentication, retries, etc., that are applied to |
| | 134 | | /// every request. |
| | 135 | | /// </param> |
| | 136 | | public DataLakeDirectoryClient(Uri directoryUri, TokenCredential credential, DataLakeClientOptions options) |
| 8 | 137 | | : this(directoryUri, credential.AsPolicy(), options) |
| | 138 | | { |
| 8 | 139 | | Errors.VerifyHttpsTokenAuth(directoryUri); |
| 4 | 140 | | } |
| | 141 | |
|
| | 142 | | /// <summary> |
| | 143 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 144 | | /// class. |
| | 145 | | /// </summary> |
| | 146 | | /// <param name="directoryUri"> |
| | 147 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 148 | | /// name of the account, the name of the file system, and the path of the |
| | 149 | | /// directory. |
| | 150 | | /// </param> |
| | 151 | | /// <param name="authentication"> |
| | 152 | | /// An optional authentication policy used to sign requests. |
| | 153 | | /// </param> |
| | 154 | | /// <param name="options"> |
| | 155 | | /// Optional client options that define the transport pipeline |
| | 156 | | /// policies for authentication, retries, etc., that are applied to |
| | 157 | | /// every request. |
| | 158 | | /// </param> |
| | 159 | | internal DataLakeDirectoryClient(Uri directoryUri, HttpPipelinePolicy authentication, DataLakeClientOptions opti |
| 36 | 160 | | : base(directoryUri, authentication, options) |
| | 161 | | { |
| 36 | 162 | | } |
| | 163 | |
|
| | 164 | | /// <summary> |
| | 165 | | /// Initializes a new instance of the <see cref="DataLakeDirectoryClient"/> |
| | 166 | | /// class. |
| | 167 | | /// </summary> |
| | 168 | | /// <param name="directoryUri"> |
| | 169 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | 170 | | /// name of the account, the name of the file system, and the path of the |
| | 171 | | /// directory. |
| | 172 | | /// </param> |
| | 173 | | /// <param name="pipeline"> |
| | 174 | | /// The transport pipeline used to send every request. |
| | 175 | | /// </param> |
| | 176 | | /// <param name="version"> |
| | 177 | | /// The version of the service to use when sending requests. |
| | 178 | | /// </param> |
| | 179 | | /// <param name="clientDiagnostics"> |
| | 180 | | /// The <see cref="ClientDiagnostics"/> instance used to create |
| | 181 | | /// diagnostic scopes every request. |
| | 182 | | /// </param> |
| | 183 | | internal DataLakeDirectoryClient( |
| | 184 | | Uri directoryUri, |
| | 185 | | HttpPipeline pipeline, |
| | 186 | | DataLakeClientOptions.ServiceVersion version, |
| | 187 | | ClientDiagnostics clientDiagnostics) |
| 72 | 188 | | : base( |
| 72 | 189 | | directoryUri, |
| 72 | 190 | | pipeline, |
| 72 | 191 | | version, |
| 72 | 192 | | clientDiagnostics) |
| | 193 | | { |
| 72 | 194 | | } |
| | 195 | |
|
| | 196 | | internal DataLakeDirectoryClient( |
| | 197 | | Uri fileSystemUri, |
| | 198 | | string directoryPath, |
| | 199 | | HttpPipeline pipeline, |
| | 200 | | DataLakeClientOptions.ServiceVersion version, |
| | 201 | | ClientDiagnostics clientDiagnostics) |
| 2394 | 202 | | : base( |
| 2394 | 203 | | fileSystemUri, |
| 2394 | 204 | | directoryPath, |
| 2394 | 205 | | pipeline, |
| 2394 | 206 | | version, |
| 2394 | 207 | | clientDiagnostics) |
| | 208 | | { |
| 2394 | 209 | | } |
| | 210 | | #endregion ctors |
| | 211 | |
|
| | 212 | | /// <summary> |
| | 213 | | /// Creates a new <see cref="DataLakeFileClient"/> object by appending |
| | 214 | | /// <paramref name="fileName"/> to the end of <see cref="Uri"/>. The |
| | 215 | | /// new <see cref="DataLakeFileClient"/> uses the same request policy |
| | 216 | | /// pipeline as the <see cref="DataLakeDirectoryClient"/>. |
| | 217 | | /// </summary> |
| | 218 | | /// <param name="fileName">The name of the file.</param> |
| | 219 | | /// <returns>A new <see cref="DataLakeFileClient"/> instance.</returns> |
| | 220 | | public virtual DataLakeFileClient GetFileClient(string fileName) |
| 272 | 221 | | => new DataLakeFileClient( |
| 272 | 222 | | Uri, |
| 272 | 223 | | $"{Path}/{fileName}", |
| 272 | 224 | | Pipeline, |
| 272 | 225 | | Version, |
| 272 | 226 | | ClientDiagnostics); |
| | 227 | |
|
| | 228 | | /// <summary> |
| | 229 | | /// Creates a new <see cref="DataLakeDirectoryClient"/> object by appending |
| | 230 | | /// <paramref name="subdirectoryName"/> to the end of <see cref="Uri"/>. |
| | 231 | | /// The new <see cref="DataLakeDirectoryClient"/> uses the same request policy |
| | 232 | | /// pipeline as the <see cref="DataLakeDirectoryClient"/>. |
| | 233 | | /// </summary> |
| | 234 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | 235 | | /// <returns>A new <see cref="DataLakeDirectoryClient"/> instance.</returns> |
| | 236 | | public virtual DataLakeDirectoryClient GetSubDirectoryClient(string subdirectoryName) |
| 172 | 237 | | => new DataLakeDirectoryClient( |
| 172 | 238 | | Uri, |
| 172 | 239 | | $"{Path}/{subdirectoryName}", |
| 172 | 240 | | Pipeline, |
| 172 | 241 | | Version, |
| 172 | 242 | | ClientDiagnostics); |
| | 243 | |
|
| | 244 | | #region Create |
| | 245 | | /// <summary> |
| | 246 | | /// The <see cref="Create"/> operation creates a directory. |
| | 247 | | /// If the directory already exists, it will be overwritten. If you don't intent to overwrite |
| | 248 | | /// an existing directory, consider using the <see cref="CreateIfNotExists"/> API. |
| | 249 | | /// |
| | 250 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 251 | | /// </summary> |
| | 252 | | /// <param name="httpHeaders"> |
| | 253 | | /// Optional standard HTTP header properties that can be set for the |
| | 254 | | /// new file or directory.. |
| | 255 | | /// </param> |
| | 256 | | /// <param name="metadata"> |
| | 257 | | /// Optional custom metadata to set for this file or directory. |
| | 258 | | /// </param> |
| | 259 | | /// <param name="permissions"> |
| | 260 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 261 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 262 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 263 | | /// octal notation (e.g. 0766) are supported. |
| | 264 | | /// </param> |
| | 265 | | /// <param name="umask"> |
| | 266 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 267 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 268 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 269 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 270 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 271 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 272 | | /// in 4-digit octal notation (e.g. 0766). |
| | 273 | | /// </param> |
| | 274 | | /// <param name="conditions"> |
| | 275 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 276 | | /// conditions on the creation of this file or directory. |
| | 277 | | /// </param> |
| | 278 | | /// <param name="cancellationToken"> |
| | 279 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 280 | | /// notifications that the operation should be cancelled. |
| | 281 | | /// </param> |
| | 282 | | /// <returns> |
| | 283 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | 284 | | /// newly created directory. |
| | 285 | | /// </returns> |
| | 286 | | /// <remarks> |
| | 287 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 288 | | /// a failure occurs. |
| | 289 | | /// </remarks> |
| | 290 | | public virtual Response<PathInfo> Create( |
| | 291 | | PathHttpHeaders httpHeaders = default, |
| | 292 | | Metadata metadata = default, |
| | 293 | | string permissions = default, |
| | 294 | | string umask = default, |
| | 295 | | DataLakeRequestConditions conditions = default, |
| | 296 | | CancellationToken cancellationToken = default) |
| | 297 | | { |
| 728 | 298 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Create)}") |
| | 299 | |
|
| | 300 | | try |
| | 301 | | { |
| 728 | 302 | | scope.Start(); |
| | 303 | |
|
| 728 | 304 | | return base.Create( |
| 728 | 305 | | PathResourceType.Directory, |
| 728 | 306 | | httpHeaders, |
| 728 | 307 | | metadata, |
| 728 | 308 | | permissions, |
| 728 | 309 | | umask, |
| 728 | 310 | | conditions, |
| 728 | 311 | | cancellationToken); |
| | 312 | | } |
| 6 | 313 | | catch (Exception ex) |
| | 314 | | { |
| 6 | 315 | | scope.Failed(ex); |
| 6 | 316 | | throw; |
| | 317 | | } |
| | 318 | | finally |
| | 319 | | { |
| 728 | 320 | | scope.Dispose(); |
| 728 | 321 | | } |
| 722 | 322 | | } |
| | 323 | |
|
| | 324 | | /// <summary> |
| | 325 | | /// The <see cref="Create"/> operation creates a directory. |
| | 326 | | /// If the directory already exists, it will be overwritten. If you don't intent to overwrite |
| | 327 | | /// an existing directory, consider using the <see cref="DataLakeDirectoryClient.CreateIfNotExistsAsync"/> API. |
| | 328 | | /// |
| | 329 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 330 | | /// </summary> |
| | 331 | | /// <param name="httpHeaders"> |
| | 332 | | /// Optional standard HTTP header properties that can be set for the |
| | 333 | | /// new file or directory.. |
| | 334 | | /// </param> |
| | 335 | | /// <param name="metadata"> |
| | 336 | | /// Optional custom metadata to set for this file or directory. |
| | 337 | | /// </param> |
| | 338 | | /// <param name="permissions"> |
| | 339 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 340 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 341 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 342 | | /// octal notation (e.g. 0766) are supported. |
| | 343 | | /// </param> |
| | 344 | | /// <param name="umask"> |
| | 345 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 346 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 347 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 348 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 349 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 350 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 351 | | /// in 4-digit octal notation (e.g. 0766). |
| | 352 | | /// </param> |
| | 353 | | /// <param name="conditions"> |
| | 354 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 355 | | /// conditions on the creation of this file or directory. |
| | 356 | | /// </param> |
| | 357 | | /// <param name="cancellationToken"> |
| | 358 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 359 | | /// notifications that the operation should be cancelled. |
| | 360 | | /// </param> |
| | 361 | | /// <returns> |
| | 362 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | 363 | | /// newly created directory. |
| | 364 | | /// </returns> |
| | 365 | | /// <remarks> |
| | 366 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 367 | | /// a failure occurs. |
| | 368 | | /// </remarks> |
| | 369 | | public virtual async Task<Response<PathInfo>> CreateAsync( |
| | 370 | | PathHttpHeaders httpHeaders = default, |
| | 371 | | Metadata metadata = default, |
| | 372 | | string permissions = default, |
| | 373 | | string umask = default, |
| | 374 | | DataLakeRequestConditions conditions = default, |
| | 375 | | CancellationToken cancellationToken = default) |
| | 376 | | { |
| 834 | 377 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Create)}") |
| | 378 | |
|
| | 379 | | try |
| | 380 | | { |
| 834 | 381 | | scope.Start(); |
| | 382 | |
|
| 834 | 383 | | return await base.CreateAsync( |
| 834 | 384 | | PathResourceType.Directory, |
| 834 | 385 | | httpHeaders, |
| 834 | 386 | | metadata, |
| 834 | 387 | | permissions, |
| 834 | 388 | | umask, |
| 834 | 389 | | conditions, |
| 834 | 390 | | cancellationToken) |
| 834 | 391 | | .ConfigureAwait(false); |
| | 392 | | } |
| 46 | 393 | | catch (Exception ex) |
| | 394 | | { |
| 46 | 395 | | scope.Failed(ex); |
| 46 | 396 | | throw; |
| | 397 | | } |
| | 398 | | finally |
| | 399 | | { |
| 834 | 400 | | scope.Dispose(); |
| | 401 | | } |
| 788 | 402 | | } |
| | 403 | | #endregion Create |
| | 404 | |
|
| | 405 | | #region Create If Not Exists |
| | 406 | | /// <summary> |
| | 407 | | /// The <see cref="Create"/> operation creates a file or directory. |
| | 408 | | /// |
| | 409 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 410 | | /// </summary> |
| | 411 | | /// <param name="httpHeaders"> |
| | 412 | | /// Optional standard HTTP header properties that can be set for the |
| | 413 | | /// new file or directory.. |
| | 414 | | /// </param> |
| | 415 | | /// <param name="metadata"> |
| | 416 | | /// Optional custom metadata to set for this file or directory.. |
| | 417 | | /// </param> |
| | 418 | | /// <param name="permissions"> |
| | 419 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 420 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 421 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 422 | | /// octal notation (e.g. 0766) are supported. |
| | 423 | | /// </param> |
| | 424 | | /// <param name="umask"> |
| | 425 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 426 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 427 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 428 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 429 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 430 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 431 | | /// in 4-digit octal notation (e.g. 0766). |
| | 432 | | /// </param> |
| | 433 | | /// <param name="cancellationToken"> |
| | 434 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 435 | | /// notifications that the operation should be cancelled. |
| | 436 | | /// </param> |
| | 437 | | /// <returns> |
| | 438 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | 439 | | /// newly created directory. |
| | 440 | | /// </returns> |
| | 441 | | /// <remarks> |
| | 442 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 443 | | /// a failure occurs. |
| | 444 | | /// </remarks> |
| | 445 | | public virtual Response<PathInfo> CreateIfNotExists( |
| | 446 | | PathHttpHeaders httpHeaders = default, |
| | 447 | | Metadata metadata = default, |
| | 448 | | string permissions = default, |
| | 449 | | string umask = default, |
| | 450 | | CancellationToken cancellationToken = default) |
| | 451 | | { |
| 6 | 452 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateIfNo |
| | 453 | | try |
| | 454 | | { |
| 6 | 455 | | scope.Start(); |
| | 456 | |
|
| 6 | 457 | | return base.CreateIfNotExists( |
| 6 | 458 | | PathResourceType.Directory, |
| 6 | 459 | | httpHeaders, |
| 6 | 460 | | metadata, |
| 6 | 461 | | permissions, |
| 6 | 462 | | umask, |
| 6 | 463 | | cancellationToken); |
| | 464 | | } |
| 2 | 465 | | catch (Exception ex) |
| | 466 | | { |
| 2 | 467 | | scope.Failed(ex); |
| 2 | 468 | | throw; |
| | 469 | | } |
| | 470 | | finally |
| | 471 | | { |
| 6 | 472 | | scope.Dispose(); |
| 6 | 473 | | } |
| 4 | 474 | | } |
| | 475 | |
|
| | 476 | | /// <summary> |
| | 477 | | /// The <see cref="Create"/> operation creates a file or directory. |
| | 478 | | /// |
| | 479 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 480 | | /// </summary> |
| | 481 | | /// <param name="httpHeaders"> |
| | 482 | | /// Optional standard HTTP header properties that can be set for the |
| | 483 | | /// new file or directory.. |
| | 484 | | /// </param> |
| | 485 | | /// <param name="metadata"> |
| | 486 | | /// Optional custom metadata to set for this file or directory.. |
| | 487 | | /// </param> |
| | 488 | | /// <param name="permissions"> |
| | 489 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 490 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 491 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 492 | | /// octal notation (e.g. 0766) are supported. |
| | 493 | | /// </param> |
| | 494 | | /// <param name="umask"> |
| | 495 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 496 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 497 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 498 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 499 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 500 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 501 | | /// in 4-digit octal notation (e.g. 0766). |
| | 502 | | /// </param> |
| | 503 | | /// <param name="cancellationToken"> |
| | 504 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 505 | | /// notifications that the operation should be cancelled. |
| | 506 | | /// </param> |
| | 507 | | /// <returns> |
| | 508 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | 509 | | /// newly created directory. |
| | 510 | | /// </returns> |
| | 511 | | /// <remarks> |
| | 512 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 513 | | /// a failure occurs. |
| | 514 | | /// </remarks> |
| | 515 | | public virtual async Task<Response<PathInfo>> CreateIfNotExistsAsync( |
| | 516 | | PathHttpHeaders httpHeaders = default, |
| | 517 | | Metadata metadata = default, |
| | 518 | | string permissions = default, |
| | 519 | | string umask = default, |
| | 520 | | CancellationToken cancellationToken = default) |
| | 521 | | { |
| 6 | 522 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateIfNo |
| | 523 | | try |
| | 524 | | { |
| 6 | 525 | | scope.Start(); |
| | 526 | |
|
| 6 | 527 | | return await base.CreateIfNotExistsAsync( |
| 6 | 528 | | PathResourceType.Directory, |
| 6 | 529 | | httpHeaders, |
| 6 | 530 | | metadata, |
| 6 | 531 | | permissions, |
| 6 | 532 | | umask, |
| 6 | 533 | | cancellationToken) |
| 6 | 534 | | .ConfigureAwait(false); |
| | 535 | | } |
| 2 | 536 | | catch (Exception ex) |
| | 537 | | { |
| 2 | 538 | | scope.Failed(ex); |
| 2 | 539 | | throw; |
| | 540 | | } |
| | 541 | | finally |
| | 542 | | { |
| 6 | 543 | | scope.Dispose(); |
| | 544 | | } |
| 4 | 545 | | } |
| | 546 | | #endregion Create If Not Exists |
| | 547 | |
|
| | 548 | | #region Delete |
| | 549 | | /// <summary> |
| | 550 | | /// The <see cref="Delete"/> operation marks the specified path |
| | 551 | | /// deletion. The path is later deleted during |
| | 552 | | /// garbage collection. |
| | 553 | | /// |
| | 554 | | /// For more information, see |
| | 555 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 556 | | /// Delete Path</see>. |
| | 557 | | /// </summary> |
| | 558 | | /// <param name="conditions"> |
| | 559 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 560 | | /// deleting this path. |
| | 561 | | /// </param> |
| | 562 | | /// <param name="cancellationToken"> |
| | 563 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 564 | | /// notifications that the operation should be cancelled. |
| | 565 | | /// </param> |
| | 566 | | /// <returns> |
| | 567 | | /// A <see cref="Response"/> on successfully deleting. |
| | 568 | | /// </returns> |
| | 569 | | /// <remarks> |
| | 570 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 571 | | /// a failure occurs. |
| | 572 | | /// </remarks> |
| | 573 | | public virtual Response Delete( |
| | 574 | | DataLakeRequestConditions conditions = default, |
| | 575 | | CancellationToken cancellationToken = default) |
| | 576 | | { |
| 2 | 577 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Delete)}") |
| | 578 | |
|
| | 579 | | try |
| | 580 | | { |
| 2 | 581 | | scope.Start(); |
| | 582 | |
|
| 2 | 583 | | return base.Delete( |
| 2 | 584 | | recursive: true, |
| 2 | 585 | | conditions, |
| 2 | 586 | | cancellationToken); |
| | 587 | | } |
| 0 | 588 | | catch (Exception ex) |
| | 589 | | { |
| 0 | 590 | | scope.Failed(ex); |
| 0 | 591 | | throw; |
| | 592 | | } |
| | 593 | | finally |
| | 594 | | { |
| 2 | 595 | | scope.Dispose(); |
| 2 | 596 | | } |
| 2 | 597 | | } |
| | 598 | |
|
| | 599 | | /// <summary> |
| | 600 | | /// The <see cref="DeleteAsync"/> operation marks the specified path |
| | 601 | | /// deletion. The path is later deleted during |
| | 602 | | /// garbage collection. |
| | 603 | | /// |
| | 604 | | /// For more information, see |
| | 605 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 606 | | /// Delete Path</see>. |
| | 607 | | /// </summary> |
| | 608 | | /// <param name="conditions"> |
| | 609 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 610 | | /// deleting this path. |
| | 611 | | /// </param> |
| | 612 | | /// <param name="cancellationToken"> |
| | 613 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 614 | | /// notifications that the operation should be cancelled. |
| | 615 | | /// </param> |
| | 616 | | /// <returns> |
| | 617 | | /// A <see cref="Response"/> on successfully deleting. |
| | 618 | | /// </returns> |
| | 619 | | /// <remarks> |
| | 620 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 621 | | /// a failure occurs. |
| | 622 | | /// </remarks> |
| | 623 | | public virtual async Task<Response> DeleteAsync( |
| | 624 | | DataLakeRequestConditions conditions = default, |
| | 625 | | CancellationToken cancellationToken = default) |
| | 626 | | { |
| 90 | 627 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Delete)}") |
| | 628 | |
|
| | 629 | | try |
| | 630 | | { |
| 90 | 631 | | scope.Start(); |
| | 632 | |
|
| 90 | 633 | | return await base.DeleteAsync( |
| 90 | 634 | | recursive: true, |
| 90 | 635 | | conditions, |
| 90 | 636 | | cancellationToken) |
| 90 | 637 | | .ConfigureAwait(false); |
| | 638 | | } |
| 40 | 639 | | catch (Exception ex) |
| | 640 | | { |
| 40 | 641 | | scope.Failed(ex); |
| 40 | 642 | | throw; |
| | 643 | | } |
| | 644 | | finally |
| | 645 | | { |
| 90 | 646 | | scope.Dispose(); |
| | 647 | | } |
| 50 | 648 | | } |
| | 649 | | #endregion Delete |
| | 650 | |
|
| | 651 | | #region Delete If Exists |
| | 652 | | /// <summary> |
| | 653 | | /// The <see cref="DeleteIfExists"/> operation marks the specified directory |
| | 654 | | /// for deletion, if the directory exists. The directory is later deleted during |
| | 655 | | /// garbage collection. |
| | 656 | | /// |
| | 657 | | /// For more information, see |
| | 658 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 659 | | /// Delete Path</see>. |
| | 660 | | /// </summary> |
| | 661 | | /// <param name="conditions"> |
| | 662 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 663 | | /// deleting this path. |
| | 664 | | /// </param> |
| | 665 | | /// <param name="cancellationToken"> |
| | 666 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 667 | | /// notifications that the operation should be cancelled. |
| | 668 | | /// </param> |
| | 669 | | /// <returns> |
| | 670 | | /// A <see cref="Response"/> on successfully deleting. |
| | 671 | | /// </returns> |
| | 672 | | /// <remarks> |
| | 673 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 674 | | /// a failure occurs. |
| | 675 | | /// </remarks> |
| | 676 | | public virtual Response<bool> DeleteIfExists( |
| | 677 | | DataLakeRequestConditions conditions = default, |
| | 678 | | CancellationToken cancellationToken = default) |
| | 679 | | { |
| 8 | 680 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteIfEx |
| | 681 | |
|
| | 682 | | try |
| | 683 | | { |
| 8 | 684 | | scope.Start(); |
| | 685 | |
|
| 8 | 686 | | return base.DeleteIfExists( |
| 8 | 687 | | recursive: true, |
| 8 | 688 | | conditions, |
| 8 | 689 | | cancellationToken); |
| | 690 | | } |
| 0 | 691 | | catch (Exception ex) |
| | 692 | | { |
| 0 | 693 | | scope.Failed(ex); |
| 0 | 694 | | throw; |
| | 695 | | } |
| | 696 | | finally |
| | 697 | | { |
| 8 | 698 | | scope.Dispose(); |
| 8 | 699 | | } |
| 8 | 700 | | } |
| | 701 | |
|
| | 702 | | /// <summary> |
| | 703 | | /// The <see cref="DeleteIfExistsAsync"/> operation marks the specified directory |
| | 704 | | /// for deletion, if the directory exists. The directory is later deleted during |
| | 705 | | /// garbage collection. |
| | 706 | | /// |
| | 707 | | /// For more information, see |
| | 708 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 709 | | /// Delete Path</see>. |
| | 710 | | /// </summary> |
| | 711 | | /// <param name="conditions"> |
| | 712 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 713 | | /// deleting this path. |
| | 714 | | /// </param> |
| | 715 | | /// <param name="cancellationToken"> |
| | 716 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 717 | | /// notifications that the operation should be cancelled. |
| | 718 | | /// </param> |
| | 719 | | /// <returns> |
| | 720 | | /// A <see cref="Response"/> on successfully deleting. |
| | 721 | | /// </returns> |
| | 722 | | /// <remarks> |
| | 723 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 724 | | /// a failure occurs. |
| | 725 | | /// </remarks> |
| | 726 | | public virtual async Task<Response<bool>> DeleteIfExistsAsync( |
| | 727 | | DataLakeRequestConditions conditions = default, |
| | 728 | | CancellationToken cancellationToken = default) |
| | 729 | | { |
| 8 | 730 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteIfEx |
| | 731 | |
|
| | 732 | | try |
| | 733 | | { |
| 8 | 734 | | scope.Start(); |
| | 735 | |
|
| 8 | 736 | | return await base.DeleteIfExistsAsync( |
| 8 | 737 | | recursive: true, |
| 8 | 738 | | conditions, |
| 8 | 739 | | cancellationToken) |
| 8 | 740 | | .ConfigureAwait(false); |
| | 741 | | } |
| 0 | 742 | | catch (Exception ex) |
| | 743 | | { |
| 0 | 744 | | scope.Failed(ex); |
| 0 | 745 | | throw; |
| | 746 | | } |
| | 747 | | finally |
| | 748 | | { |
| 8 | 749 | | scope.Dispose(); |
| | 750 | | } |
| 8 | 751 | | } |
| | 752 | | #endregion Delete If Exists |
| | 753 | |
|
| | 754 | | #region Rename |
| | 755 | | /// <summary> |
| | 756 | | /// The <see cref="Rename"/> operation renames a Directory. |
| | 757 | | /// |
| | 758 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 759 | | /// </summary> |
| | 760 | | /// <param name="destinationPath"> |
| | 761 | | /// The destination path to rename the path to. |
| | 762 | | /// </param> |
| | 763 | | /// <param name="destinationFileSystem"> |
| | 764 | | /// Optional destination file system. If null, path will be renamed within the |
| | 765 | | /// current file system. |
| | 766 | | /// </param> |
| | 767 | | /// <param name="sourceConditions"> |
| | 768 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 769 | | /// conditions on the source on the creation of this file or directory. |
| | 770 | | /// </param> |
| | 771 | | /// <param name="destinationConditions"> |
| | 772 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 773 | | /// conditions on the creation of this file or directory. |
| | 774 | | /// </param> |
| | 775 | | /// <param name="cancellationToken"> |
| | 776 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 777 | | /// notifications that the operation should be cancelled. |
| | 778 | | /// </param> |
| | 779 | | /// <returns> |
| | 780 | | /// A <see cref="Response{DataLakeDirectoryClient}"/> for the |
| | 781 | | /// newly created directory. |
| | 782 | | /// </returns> |
| | 783 | | /// <remarks> |
| | 784 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 785 | | /// a failure occurs. |
| | 786 | | /// </remarks> |
| | 787 | | public new virtual Response<DataLakeDirectoryClient> Rename( |
| | 788 | | string destinationPath, |
| | 789 | | string destinationFileSystem = default, |
| | 790 | | DataLakeRequestConditions sourceConditions = default, |
| | 791 | | DataLakeRequestConditions destinationConditions = default, |
| | 792 | | CancellationToken cancellationToken = default) |
| | 793 | | { |
| 2 | 794 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Rename)}") |
| | 795 | |
|
| | 796 | | try |
| | 797 | | { |
| 2 | 798 | | scope.Start(); |
| | 799 | |
|
| 2 | 800 | | Response<DataLakePathClient> response = base.Rename( |
| 2 | 801 | | destinationFileSystem, |
| 2 | 802 | | destinationPath, |
| 2 | 803 | | sourceConditions, |
| 2 | 804 | | destinationConditions, |
| 2 | 805 | | cancellationToken); |
| | 806 | |
|
| 0 | 807 | | return Response.FromValue( |
| 0 | 808 | | new DataLakeDirectoryClient(response.Value.DfsUri, response.Value.Pipeline, response.Value.Version, |
| 0 | 809 | | response.GetRawResponse()); |
| | 810 | | } |
| 2 | 811 | | catch (Exception ex) |
| | 812 | | { |
| 2 | 813 | | scope.Failed(ex); |
| 2 | 814 | | throw; |
| | 815 | | } |
| | 816 | | finally |
| | 817 | | { |
| 2 | 818 | | scope.Dispose(); |
| 2 | 819 | | } |
| 0 | 820 | | } |
| | 821 | |
|
| | 822 | | /// <summary> |
| | 823 | | /// The <see cref="RenameAsync"/> operation renames a file or directory. |
| | 824 | | /// |
| | 825 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 826 | | /// </summary> |
| | 827 | | /// <param name="destinationPath"> |
| | 828 | | /// The destination path to rename the path to. |
| | 829 | | /// </param> |
| | 830 | | /// <param name="destinationFileSystem"> |
| | 831 | | /// Optional destination file system. If null, path will be renamed within the |
| | 832 | | /// current file system. |
| | 833 | | /// </param> |
| | 834 | | /// <param name="sourceConditions"> |
| | 835 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 836 | | /// conditions on the source on the creation of this file or directory. |
| | 837 | | /// </param> |
| | 838 | | /// <param name="destinationConditions"> |
| | 839 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 840 | | /// conditions on the creation of this file or directory. |
| | 841 | | /// </param> |
| | 842 | | /// <param name="cancellationToken"> |
| | 843 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 844 | | /// notifications that the operation should be cancelled. |
| | 845 | | /// </param> |
| | 846 | | /// <returns> |
| | 847 | | /// A <see cref="Response{DataLakeDirectoryClient}"/> for |
| | 848 | | /// the newly created directory. |
| | 849 | | /// </returns> |
| | 850 | | /// <remarks> |
| | 851 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 852 | | /// a failure occurs. |
| | 853 | | /// </remarks> |
| | 854 | | public new virtual async Task<Response<DataLakeDirectoryClient>> RenameAsync( |
| | 855 | | string destinationPath, |
| | 856 | | string destinationFileSystem = default, |
| | 857 | | DataLakeRequestConditions sourceConditions = default, |
| | 858 | | DataLakeRequestConditions destinationConditions = default, |
| | 859 | | CancellationToken cancellationToken = default) |
| | 860 | | { |
| 102 | 861 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(Rename)}") |
| | 862 | |
|
| | 863 | | try |
| | 864 | | { |
| 102 | 865 | | scope.Start(); |
| | 866 | |
|
| 102 | 867 | | Response<DataLakePathClient> response = await base.RenameAsync( |
| 102 | 868 | | destinationFileSystem, |
| 102 | 869 | | destinationPath, |
| 102 | 870 | | sourceConditions, |
| 102 | 871 | | destinationConditions, |
| 102 | 872 | | cancellationToken) |
| 102 | 873 | | .ConfigureAwait(false); |
| | 874 | |
|
| 60 | 875 | | return Response.FromValue( |
| 60 | 876 | | new DataLakeDirectoryClient(response.Value.DfsUri, response.Value.Pipeline, response.Value.Version, |
| 60 | 877 | | response.GetRawResponse()); |
| | 878 | | } |
| 42 | 879 | | catch (Exception ex) |
| | 880 | | { |
| 42 | 881 | | scope.Failed(ex); |
| 42 | 882 | | throw; |
| | 883 | | } |
| | 884 | | finally |
| | 885 | | { |
| 102 | 886 | | scope.Dispose(); |
| | 887 | | } |
| 60 | 888 | | } |
| | 889 | | #endregion Rename |
| | 890 | |
|
| | 891 | | #region Get Access Control |
| | 892 | | /// <summary> |
| | 893 | | /// The <see cref="GetAccessControl"/> operation returns the |
| | 894 | | /// access control data for a path. |
| | 895 | | /// |
| | 896 | | /// For more information, see |
| | 897 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties" |
| | 898 | | /// Get Properties</see>. |
| | 899 | | /// </summary> |
| | 900 | | /// <param name="userPrincipalName"> |
| | 901 | | /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true", |
| | 902 | | /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response |
| | 903 | | /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names. |
| | 904 | | /// If "false", the values will be returned as Azure Active Directory Object IDs.The default |
| | 905 | | /// value is false. Note that group and application Object IDs are not translated because they |
| | 906 | | /// do not have unique friendly names. |
| | 907 | | /// </param> |
| | 908 | | /// <param name="conditions"> |
| | 909 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 910 | | /// conditions on getting the path's access control. |
| | 911 | | /// </param> |
| | 912 | | /// <param name="cancellationToken"> |
| | 913 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 914 | | /// notifications that the operation should be cancelled. |
| | 915 | | /// </param> |
| | 916 | | /// <returns> |
| | 917 | | /// A <see cref="Response{PathAccessControl}"/> describing the |
| | 918 | | /// path's access control. |
| | 919 | | /// </returns> |
| | 920 | | /// <remarks> |
| | 921 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 922 | | /// a failure occurs. |
| | 923 | | /// </remarks> |
| | 924 | | public override Response<PathAccessControl> GetAccessControl( |
| | 925 | | bool? userPrincipalName = default, |
| | 926 | | DataLakeRequestConditions conditions = default, |
| | 927 | | CancellationToken cancellationToken = default) |
| | 928 | | { |
| 16 | 929 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(GetAccessC |
| | 930 | |
|
| | 931 | | try |
| | 932 | | { |
| 16 | 933 | | scope.Start(); |
| | 934 | |
|
| 16 | 935 | | return base.GetAccessControl( |
| 16 | 936 | | userPrincipalName, |
| 16 | 937 | | conditions, |
| 16 | 938 | | cancellationToken); |
| | 939 | | } |
| 2 | 940 | | catch (Exception ex) |
| | 941 | | { |
| 2 | 942 | | scope.Failed(ex); |
| 2 | 943 | | throw; |
| | 944 | | } |
| | 945 | | finally |
| | 946 | | { |
| 16 | 947 | | scope.Dispose(); |
| 16 | 948 | | } |
| 14 | 949 | | } |
| | 950 | |
|
| | 951 | | /// <summary> |
| | 952 | | /// The <see cref="GetAccessControlAsync"/> operation returns the |
| | 953 | | /// access control data for a path. |
| | 954 | | /// |
| | 955 | | /// For more information, see |
| | 956 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties" |
| | 957 | | /// Get Properties</see>. |
| | 958 | | /// </summary> |
| | 959 | | /// <param name="userPrincipalName"> |
| | 960 | | /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true", |
| | 961 | | /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response |
| | 962 | | /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names. |
| | 963 | | /// If "false", the values will be returned as Azure Active Directory Object IDs.The default |
| | 964 | | /// value is false. Note that group and application Object IDs are not translated because they |
| | 965 | | /// do not have unique friendly names. |
| | 966 | | /// </param> |
| | 967 | | /// <param name="conditions"> |
| | 968 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 969 | | /// conditions on getting the path's access control. |
| | 970 | | /// </param> |
| | 971 | | /// <param name="cancellationToken"> |
| | 972 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 973 | | /// notifications that the operation should be cancelled. |
| | 974 | | /// </param> |
| | 975 | | /// <returns> |
| | 976 | | /// A <see cref="Response{PathAccessControl}"/> describing the |
| | 977 | | /// path's access control. |
| | 978 | | /// </returns> |
| | 979 | | /// <remarks> |
| | 980 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 981 | | /// a failure occurs. |
| | 982 | | /// </remarks> |
| | 983 | | public override async Task<Response<PathAccessControl>> GetAccessControlAsync( |
| | 984 | | bool? userPrincipalName = default, |
| | 985 | | DataLakeRequestConditions conditions = default, |
| | 986 | | CancellationToken cancellationToken = default) |
| | 987 | | { |
| 52 | 988 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(GetAccessC |
| | 989 | |
|
| | 990 | | try |
| | 991 | | { |
| 52 | 992 | | scope.Start(); |
| | 993 | |
|
| 52 | 994 | | return await base.GetAccessControlAsync( |
| 52 | 995 | | userPrincipalName, |
| 52 | 996 | | conditions, |
| 52 | 997 | | cancellationToken) |
| 52 | 998 | | .ConfigureAwait(false); |
| | 999 | | } |
| 2 | 1000 | | catch (Exception ex) |
| | 1001 | | { |
| 2 | 1002 | | scope.Failed(ex); |
| 2 | 1003 | | throw; |
| | 1004 | | } |
| | 1005 | | finally |
| | 1006 | | { |
| 52 | 1007 | | scope.Dispose(); |
| | 1008 | | } |
| 50 | 1009 | | } |
| | 1010 | | #endregion Get Access Control |
| | 1011 | |
|
| | 1012 | | #region Set Access Control |
| | 1013 | | /// <summary> |
| | 1014 | | /// The <see cref="SetAccessControlList"/> operation sets the |
| | 1015 | | /// Access Control on a path |
| | 1016 | | /// |
| | 1017 | | /// For more information, see |
| | 1018 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | 1019 | | /// Update Path</see>. |
| | 1020 | | /// </summary> |
| | 1021 | | /// <param name="accessControlList"> |
| | 1022 | | /// The POSIX access control list for the file or directory. |
| | 1023 | | /// </param> |
| | 1024 | | /// <param name="owner"> |
| | 1025 | | /// The owner of the file or directory. |
| | 1026 | | /// </param> |
| | 1027 | | /// <param name="group"> |
| | 1028 | | /// The owning group of the file or directory. |
| | 1029 | | /// </param> |
| | 1030 | | /// <param name="conditions"> |
| | 1031 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1032 | | /// setting the the path's access control. |
| | 1033 | | /// </param> |
| | 1034 | | /// <param name="cancellationToken"> |
| | 1035 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1036 | | /// notifications that the operation should be cancelled. |
| | 1037 | | /// </param> |
| | 1038 | | /// <returns> |
| | 1039 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1040 | | /// path. |
| | 1041 | | /// </returns> |
| | 1042 | | /// <remarks> |
| | 1043 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1044 | | /// a failure occurs. |
| | 1045 | | /// </remarks> |
| | 1046 | | public override Response<PathInfo> SetAccessControlList( |
| | 1047 | | IList<PathAccessControlItem> accessControlList, |
| | 1048 | | string owner = default, |
| | 1049 | | string group = default, |
| | 1050 | | DataLakeRequestConditions conditions = default, |
| | 1051 | | CancellationToken cancellationToken = default) |
| | 1052 | | { |
| 0 | 1053 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetAccessC |
| | 1054 | |
|
| | 1055 | | try |
| | 1056 | | { |
| 0 | 1057 | | scope.Start(); |
| | 1058 | |
|
| 0 | 1059 | | return base.SetAccessControlList( |
| 0 | 1060 | | accessControlList, |
| 0 | 1061 | | owner, |
| 0 | 1062 | | group, |
| 0 | 1063 | | conditions, |
| 0 | 1064 | | cancellationToken); |
| | 1065 | | } |
| 0 | 1066 | | catch (Exception ex) |
| | 1067 | | { |
| 0 | 1068 | | scope.Failed(ex); |
| 0 | 1069 | | throw; |
| | 1070 | | } |
| | 1071 | | finally |
| | 1072 | | { |
| 0 | 1073 | | scope.Dispose(); |
| 0 | 1074 | | } |
| 0 | 1075 | | } |
| | 1076 | |
|
| | 1077 | | /// <summary> |
| | 1078 | | /// The <see cref="SetAccessControlListAsync"/> operation sets the |
| | 1079 | | /// Access Control on a path |
| | 1080 | | /// |
| | 1081 | | /// For more information, see |
| | 1082 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | 1083 | | /// Update Path</see>. |
| | 1084 | | /// </summary> |
| | 1085 | | /// <param name="accessControlList"> |
| | 1086 | | /// The POSIX access control list for the file or directory. |
| | 1087 | | /// </param> |
| | 1088 | | /// <param name="owner"> |
| | 1089 | | /// The owner of the file or directory. |
| | 1090 | | /// </param> |
| | 1091 | | /// <param name="group"> |
| | 1092 | | /// The owning group of the file or directory. |
| | 1093 | | /// </param> |
| | 1094 | | /// <param name="conditions"> |
| | 1095 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1096 | | /// setting the the path's access control. |
| | 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{PathInfo}"/> describing the updated |
| | 1104 | | /// path. |
| | 1105 | | /// </returns> |
| | 1106 | | /// <remarks> |
| | 1107 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1108 | | /// a failure occurs. |
| | 1109 | | /// </remarks> |
| | 1110 | | public override async Task<Response<PathInfo>> SetAccessControlListAsync( |
| | 1111 | | IList<PathAccessControlItem> accessControlList, |
| | 1112 | | string owner = default, |
| | 1113 | | string group = default, |
| | 1114 | | DataLakeRequestConditions conditions = default, |
| | 1115 | | CancellationToken cancellationToken = default) |
| | 1116 | | { |
| 48 | 1117 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetAccessC |
| | 1118 | |
|
| | 1119 | | try |
| | 1120 | | { |
| 48 | 1121 | | scope.Start(); |
| | 1122 | |
|
| 48 | 1123 | | return await base.SetAccessControlListAsync( |
| 48 | 1124 | | accessControlList, |
| 48 | 1125 | | owner, |
| 48 | 1126 | | group, |
| 48 | 1127 | | conditions, |
| 48 | 1128 | | cancellationToken) |
| 48 | 1129 | | .ConfigureAwait(false); |
| | 1130 | | } |
| 20 | 1131 | | catch (Exception ex) |
| | 1132 | | { |
| 20 | 1133 | | scope.Failed(ex); |
| 20 | 1134 | | throw; |
| | 1135 | | } |
| | 1136 | | finally |
| | 1137 | | { |
| 48 | 1138 | | scope.Dispose(); |
| | 1139 | | } |
| 28 | 1140 | | } |
| | 1141 | | #endregion Set Access Control |
| | 1142 | |
|
| | 1143 | | #region Set Permissions |
| | 1144 | | /// <summary> |
| | 1145 | | /// The <see cref="SetPermissions"/> operation sets the |
| | 1146 | | /// file permissions on a path. |
| | 1147 | | /// |
| | 1148 | | /// For more information, see |
| | 1149 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | 1150 | | /// Update Path</see>. |
| | 1151 | | /// </summary> |
| | 1152 | | /// <param name="permissions"> |
| | 1153 | | /// The POSIX access permissions for the file owner, the file owning group, and others. |
| | 1154 | | /// </param> |
| | 1155 | | /// <param name="owner"> |
| | 1156 | | /// The owner of the file or directory. |
| | 1157 | | /// </param> |
| | 1158 | | /// <param name="group"> |
| | 1159 | | /// The owning group of the file or directory. |
| | 1160 | | /// </param> |
| | 1161 | | /// <param name="conditions"> |
| | 1162 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1163 | | /// setting the the path's access control. |
| | 1164 | | /// </param> |
| | 1165 | | /// <param name="cancellationToken"> |
| | 1166 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1167 | | /// notifications that the operation should be cancelled. |
| | 1168 | | /// </param> |
| | 1169 | | /// <returns> |
| | 1170 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1171 | | /// path. |
| | 1172 | | /// </returns> |
| | 1173 | | /// <remarks> |
| | 1174 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1175 | | /// a failure occurs. |
| | 1176 | | /// </remarks> |
| | 1177 | | public override Response<PathInfo> SetPermissions( |
| | 1178 | | PathPermissions permissions, |
| | 1179 | | string owner = default, |
| | 1180 | | string group = default, |
| | 1181 | | DataLakeRequestConditions conditions = default, |
| | 1182 | | CancellationToken cancellationToken = default) |
| | 1183 | | { |
| 4 | 1184 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetPermiss |
| | 1185 | |
|
| | 1186 | | try |
| | 1187 | | { |
| 4 | 1188 | | scope.Start(); |
| | 1189 | |
|
| 4 | 1190 | | return base.SetPermissions( |
| 4 | 1191 | | permissions, |
| 4 | 1192 | | owner, |
| 4 | 1193 | | group, |
| 4 | 1194 | | conditions, |
| 4 | 1195 | | cancellationToken); |
| | 1196 | | } |
| 0 | 1197 | | catch (Exception ex) |
| | 1198 | | { |
| 0 | 1199 | | scope.Failed(ex); |
| 0 | 1200 | | throw; |
| | 1201 | | } |
| | 1202 | | finally |
| | 1203 | | { |
| 4 | 1204 | | scope.Dispose(); |
| 4 | 1205 | | } |
| | 1206 | |
|
| 4 | 1207 | | } |
| | 1208 | |
|
| | 1209 | | /// <summary> |
| | 1210 | | /// The <see cref="SetPermissionsAsync"/> operation sets the |
| | 1211 | | /// file permissions on a path. |
| | 1212 | | /// |
| | 1213 | | /// For more information, see |
| | 1214 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | 1215 | | /// Update Path</see>. |
| | 1216 | | /// </summary> |
| | 1217 | | /// <param name="permissions"> |
| | 1218 | | /// The POSIX access permissions for the file owner, the file owning group, and others. |
| | 1219 | | /// </param> |
| | 1220 | | /// <param name="owner"> |
| | 1221 | | /// The owner of the file or directory. |
| | 1222 | | /// </param> |
| | 1223 | | /// <param name="group"> |
| | 1224 | | /// The owning group of the file or directory. |
| | 1225 | | /// </param> |
| | 1226 | | /// <param name="conditions"> |
| | 1227 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1228 | | /// setting the the path's access control. |
| | 1229 | | /// </param> |
| | 1230 | | /// <param name="cancellationToken"> |
| | 1231 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1232 | | /// notifications that the operation should be cancelled. |
| | 1233 | | /// </param> |
| | 1234 | | /// <returns> |
| | 1235 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1236 | | /// path. |
| | 1237 | | /// </returns> |
| | 1238 | | /// <remarks> |
| | 1239 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1240 | | /// a failure occurs. |
| | 1241 | | /// </remarks> |
| | 1242 | | public override async Task<Response<PathInfo>> SetPermissionsAsync( |
| | 1243 | | PathPermissions permissions, |
| | 1244 | | string owner = default, |
| | 1245 | | string group = default, |
| | 1246 | | DataLakeRequestConditions conditions = default, |
| | 1247 | | CancellationToken cancellationToken = default) |
| | 1248 | | { |
| 52 | 1249 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetPermiss |
| | 1250 | |
|
| | 1251 | | try |
| | 1252 | | { |
| 52 | 1253 | | scope.Start(); |
| | 1254 | |
|
| 52 | 1255 | | return await base.SetPermissionsAsync( |
| 52 | 1256 | | permissions, |
| 52 | 1257 | | owner, |
| 52 | 1258 | | group, |
| 52 | 1259 | | conditions, |
| 52 | 1260 | | cancellationToken) |
| 52 | 1261 | | .ConfigureAwait(false); |
| | 1262 | | } |
| 20 | 1263 | | catch (Exception ex) |
| | 1264 | | { |
| 20 | 1265 | | scope.Failed(ex); |
| 20 | 1266 | | throw; |
| | 1267 | | } |
| | 1268 | | finally |
| | 1269 | | { |
| 52 | 1270 | | scope.Dispose(); |
| | 1271 | | } |
| 32 | 1272 | | } |
| | 1273 | | #endregion Set Permissions |
| | 1274 | |
|
| | 1275 | | #region Get Properties |
| | 1276 | | /// <summary> |
| | 1277 | | /// The <see cref="GetProperties"/> operation returns all |
| | 1278 | | /// user-defined metadata, standard HTTP properties, and system |
| | 1279 | | /// properties for the path. It does not return the content of the |
| | 1280 | | /// path. |
| | 1281 | | /// |
| | 1282 | | /// For more information, see |
| | 1283 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties"> |
| | 1284 | | /// Get Properties</see>. |
| | 1285 | | /// </summary> |
| | 1286 | | /// <param name="conditions"> |
| | 1287 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 1288 | | /// conditions on getting the path's properties. |
| | 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{PathProperties}"/> describing the |
| | 1296 | | /// path's properties. |
| | 1297 | | /// </returns> |
| | 1298 | | /// <remarks> |
| | 1299 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1300 | | /// a failure occurs. |
| | 1301 | | /// </remarks> |
| | 1302 | | #pragma warning disable CS0114 // Member hides inherited member; missing override keyword |
| | 1303 | | public virtual Response<PathProperties> GetProperties( |
| | 1304 | | #pragma warning restore CS0114 // Member hides inherited member; missing override keyword |
| | 1305 | | DataLakeRequestConditions conditions = default, |
| | 1306 | | CancellationToken cancellationToken = default) |
| | 1307 | | { |
| 22 | 1308 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(GetPropert |
| | 1309 | |
|
| | 1310 | | try |
| | 1311 | | { |
| 22 | 1312 | | scope.Start(); |
| | 1313 | |
|
| 22 | 1314 | | return base.GetProperties( |
| 22 | 1315 | | conditions, |
| 22 | 1316 | | cancellationToken); |
| | 1317 | | } |
| 2 | 1318 | | catch (Exception ex) |
| | 1319 | | { |
| 2 | 1320 | | scope.Failed(ex); |
| 2 | 1321 | | throw; |
| | 1322 | | } |
| | 1323 | | finally |
| | 1324 | | { |
| 22 | 1325 | | scope.Dispose(); |
| 22 | 1326 | | } |
| 20 | 1327 | | } |
| | 1328 | |
|
| | 1329 | |
|
| | 1330 | | /// <summary> |
| | 1331 | | /// The <see cref="GetPropertiesAsync"/> operation returns all |
| | 1332 | | /// user-defined metadata, standard HTTP properties, and system |
| | 1333 | | /// properties for the path. It does not return the content of the |
| | 1334 | | /// path. |
| | 1335 | | /// |
| | 1336 | | /// For more information, see |
| | 1337 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties"> |
| | 1338 | | /// Get Properties</see>. |
| | 1339 | | /// </summary> |
| | 1340 | | /// <param name="conditions"> |
| | 1341 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 1342 | | /// conditions on getting the path's properties. |
| | 1343 | | /// </param> |
| | 1344 | | /// <param name="cancellationToken"> |
| | 1345 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1346 | | /// notifications that the operation should be cancelled. |
| | 1347 | | /// </param> |
| | 1348 | | /// <returns> |
| | 1349 | | /// A <see cref="Response{PathProperties}"/> describing the |
| | 1350 | | /// paths's properties. |
| | 1351 | | /// </returns> |
| | 1352 | | /// <remarks> |
| | 1353 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1354 | | /// a failure occurs. |
| | 1355 | | /// </remarks> |
| | 1356 | | public override async Task<Response<PathProperties>> GetPropertiesAsync( |
| | 1357 | | DataLakeRequestConditions conditions = default, |
| | 1358 | | CancellationToken cancellationToken = default) |
| | 1359 | | { |
| 294 | 1360 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(GetPropert |
| | 1361 | |
|
| | 1362 | | try |
| | 1363 | | { |
| 294 | 1364 | | scope.Start(); |
| | 1365 | |
|
| 294 | 1366 | | return await base.GetPropertiesAsync( |
| 294 | 1367 | | conditions, |
| 294 | 1368 | | cancellationToken) |
| 294 | 1369 | | .ConfigureAwait(false); |
| | 1370 | | } |
| 22 | 1371 | | catch (Exception ex) |
| | 1372 | | { |
| 22 | 1373 | | scope.Failed(ex); |
| 22 | 1374 | | throw; |
| | 1375 | | } |
| | 1376 | | finally |
| | 1377 | | { |
| 294 | 1378 | | scope.Dispose(); |
| | 1379 | | } |
| 272 | 1380 | | } |
| | 1381 | | #endregion Get Properties |
| | 1382 | |
|
| | 1383 | | #region Set Http Headers |
| | 1384 | | /// <summary> |
| | 1385 | | /// The <see cref="SetHttpHeaders"/> operation sets system |
| | 1386 | | /// properties on the path. |
| | 1387 | | /// |
| | 1388 | | /// For more information, see |
| | 1389 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties"> |
| | 1390 | | /// Set Blob Properties</see>. |
| | 1391 | | /// </summary> |
| | 1392 | | /// <param name="httpHeaders"> |
| | 1393 | | /// Optional. The standard HTTP header system properties to set. |
| | 1394 | | /// If not specified, existing values will be cleared. |
| | 1395 | | /// </param> |
| | 1396 | | /// <param name="conditions"> |
| | 1397 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1398 | | /// setting the paths's HTTP headers. |
| | 1399 | | /// </param> |
| | 1400 | | /// <param name="cancellationToken"> |
| | 1401 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1402 | | /// notifications that the operation should be cancelled. |
| | 1403 | | /// </param> |
| | 1404 | | /// <returns> |
| | 1405 | | /// A <see cref="Response{httpHeaders}"/> describing the updated |
| | 1406 | | /// path. |
| | 1407 | | /// </returns> |
| | 1408 | | /// <remarks> |
| | 1409 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1410 | | /// a failure occurs. |
| | 1411 | | /// </remarks> |
| | 1412 | | public override Response<PathInfo> SetHttpHeaders( |
| | 1413 | | PathHttpHeaders httpHeaders = default, |
| | 1414 | | DataLakeRequestConditions conditions = default, |
| | 1415 | | CancellationToken cancellationToken = default) |
| | 1416 | | { |
| 2 | 1417 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetHttpHea |
| | 1418 | |
|
| | 1419 | | try |
| | 1420 | | { |
| 2 | 1421 | | scope.Start(); |
| | 1422 | |
|
| 2 | 1423 | | return base.SetHttpHeaders( |
| 2 | 1424 | | httpHeaders, |
| 2 | 1425 | | conditions, |
| 2 | 1426 | | cancellationToken); |
| | 1427 | | } |
| 2 | 1428 | | catch (Exception ex) |
| | 1429 | | { |
| 2 | 1430 | | scope.Failed(ex); |
| 2 | 1431 | | throw; |
| | 1432 | | } |
| | 1433 | | finally |
| | 1434 | | { |
| 2 | 1435 | | scope.Dispose(); |
| 2 | 1436 | | } |
| 0 | 1437 | | } |
| | 1438 | |
|
| | 1439 | | /// <summary> |
| | 1440 | | /// The <see cref="SetHttpHeadersAsync"/> operation sets system |
| | 1441 | | /// properties on the PATH. |
| | 1442 | | /// |
| | 1443 | | /// For more information, see |
| | 1444 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties"> |
| | 1445 | | /// Set Blob Properties</see>. |
| | 1446 | | /// </summary> |
| | 1447 | | /// <param name="httpHeaders"> |
| | 1448 | | /// Optional. The standard HTTP header system properties to set. |
| | 1449 | | /// If not specified, existing values will be cleared. |
| | 1450 | | /// </param> |
| | 1451 | | /// <param name="conditions"> |
| | 1452 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1453 | | /// setting the path's HTTP headers. |
| | 1454 | | /// </param> |
| | 1455 | | /// <param name="cancellationToken"> |
| | 1456 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1457 | | /// notifications that the operation should be cancelled. |
| | 1458 | | /// </param> |
| | 1459 | | /// <returns> |
| | 1460 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1461 | | /// path. |
| | 1462 | | /// </returns> |
| | 1463 | | /// <remarks> |
| | 1464 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1465 | | /// a failure occurs. |
| | 1466 | | /// </remarks> |
| | 1467 | | public override async Task<Response<PathInfo>> SetHttpHeadersAsync( |
| | 1468 | | PathHttpHeaders httpHeaders = default, |
| | 1469 | | DataLakeRequestConditions conditions = default, |
| | 1470 | | CancellationToken cancellationToken = default) |
| | 1471 | | { |
| 50 | 1472 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetHttpHea |
| | 1473 | |
|
| | 1474 | | try |
| | 1475 | | { |
| 50 | 1476 | | scope.Start(); |
| | 1477 | |
|
| 50 | 1478 | | return await base.SetHttpHeadersAsync( |
| 50 | 1479 | | httpHeaders, |
| 50 | 1480 | | conditions, |
| 50 | 1481 | | cancellationToken) |
| 50 | 1482 | | .ConfigureAwait(false); |
| | 1483 | | } |
| 22 | 1484 | | catch (Exception ex) |
| | 1485 | | { |
| 22 | 1486 | | scope.Failed(ex); |
| 22 | 1487 | | throw; |
| | 1488 | | } |
| | 1489 | | finally |
| | 1490 | | { |
| 50 | 1491 | | scope.Dispose(); |
| | 1492 | | } |
| 28 | 1493 | | } |
| | 1494 | | #endregion Set Http Headers |
| | 1495 | |
|
| | 1496 | | #region Set Metadata |
| | 1497 | | /// <summary> |
| | 1498 | | /// The <see cref="SetMetadata"/> operation sets user-defined |
| | 1499 | | /// metadata for the specified path as one or more name-value pairs. |
| | 1500 | | /// |
| | 1501 | | /// For more information, see |
| | 1502 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata"> |
| | 1503 | | /// Set Metadata</see>. |
| | 1504 | | /// </summary> |
| | 1505 | | /// <param name="metadata"> |
| | 1506 | | /// Custom metadata to set for this path. |
| | 1507 | | /// </param> |
| | 1508 | | /// <param name="conditions"> |
| | 1509 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1510 | | /// setting the path's metadata. |
| | 1511 | | /// </param> |
| | 1512 | | /// <param name="cancellationToken"> |
| | 1513 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1514 | | /// notifications that the operation should be cancelled. |
| | 1515 | | /// </param> |
| | 1516 | | /// <returns> |
| | 1517 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1518 | | /// path. |
| | 1519 | | /// </returns> |
| | 1520 | | /// <remarks> |
| | 1521 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1522 | | /// a failure occurs. |
| | 1523 | | /// </remarks> |
| | 1524 | | public override Response<PathInfo> SetMetadata( |
| | 1525 | | Metadata metadata, |
| | 1526 | | DataLakeRequestConditions conditions = default, |
| | 1527 | | CancellationToken cancellationToken = default) |
| | 1528 | | { |
| 2 | 1529 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetMetadat |
| | 1530 | |
|
| | 1531 | | try |
| | 1532 | | { |
| 2 | 1533 | | scope.Start(); |
| | 1534 | |
|
| 2 | 1535 | | return base.SetMetadata( |
| 2 | 1536 | | metadata, |
| 2 | 1537 | | conditions, |
| 2 | 1538 | | cancellationToken); |
| | 1539 | | } |
| 2 | 1540 | | catch (Exception ex) |
| | 1541 | | { |
| 2 | 1542 | | scope.Failed(ex); |
| 2 | 1543 | | throw; |
| | 1544 | | } |
| | 1545 | | finally |
| | 1546 | | { |
| 2 | 1547 | | scope.Dispose(); |
| 2 | 1548 | | } |
| 0 | 1549 | | } |
| | 1550 | |
|
| | 1551 | | /// <summary> |
| | 1552 | | /// The <see cref="SetMetadataAsync"/> operation sets user-defined |
| | 1553 | | /// metadata for the specified path as one or more name-value pairs. |
| | 1554 | | /// |
| | 1555 | | /// For more information, see |
| | 1556 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata"> |
| | 1557 | | /// Set Metadata</see>. |
| | 1558 | | /// </summary> |
| | 1559 | | /// <param name="metadata"> |
| | 1560 | | /// Custom metadata to set for this path. |
| | 1561 | | /// </param> |
| | 1562 | | /// <param name="conditions"> |
| | 1563 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1564 | | /// setting the path's metadata. |
| | 1565 | | /// </param> |
| | 1566 | | /// <param name="cancellationToken"> |
| | 1567 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1568 | | /// notifications that the operation should be cancelled. |
| | 1569 | | /// </param> |
| | 1570 | | /// <returns> |
| | 1571 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | 1572 | | /// path. |
| | 1573 | | /// </returns> |
| | 1574 | | /// <remarks> |
| | 1575 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1576 | | /// a failure occurs. |
| | 1577 | | /// </remarks> |
| | 1578 | | public override async Task<Response<PathInfo>> SetMetadataAsync( |
| | 1579 | | Metadata metadata, |
| | 1580 | | DataLakeRequestConditions conditions = default, |
| | 1581 | | CancellationToken cancellationToken = default) |
| | 1582 | | { |
| 50 | 1583 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(SetMetadat |
| | 1584 | |
|
| | 1585 | | try |
| | 1586 | | { |
| 50 | 1587 | | scope.Start(); |
| | 1588 | |
|
| 50 | 1589 | | return await base.SetMetadataAsync( |
| 50 | 1590 | | metadata, |
| 50 | 1591 | | conditions, |
| 50 | 1592 | | cancellationToken) |
| 50 | 1593 | | .ConfigureAwait(false); |
| | 1594 | | } |
| 22 | 1595 | | catch (Exception ex) |
| | 1596 | | { |
| 22 | 1597 | | scope.Failed(ex); |
| 22 | 1598 | | throw; |
| | 1599 | | } |
| | 1600 | | finally |
| | 1601 | | { |
| 50 | 1602 | | scope.Dispose(); |
| | 1603 | | } |
| 28 | 1604 | | } |
| | 1605 | | #endregion Set Metadata |
| | 1606 | |
|
| | 1607 | | #region Create File |
| | 1608 | | /// <summary> |
| | 1609 | | /// The <see cref="CreateFile"/> operation creates a file in this directory. |
| | 1610 | | /// If the file already exists, it will be overwritten. If you don't intent to overwrite |
| | 1611 | | /// an existing file, consider using the <see cref="DataLakeFileClient.CreateIfNotExists"/> API. |
| | 1612 | | /// |
| | 1613 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 1614 | | /// </summary> |
| | 1615 | | /// <param name="fileName"> |
| | 1616 | | /// The name of the file to create. |
| | 1617 | | /// </param> |
| | 1618 | | /// <param name="httpHeaders"> |
| | 1619 | | /// Optional standard HTTP header properties that can be set for the |
| | 1620 | | /// new file or directory.. |
| | 1621 | | /// </param> |
| | 1622 | | /// <param name="metadata"> |
| | 1623 | | /// Optional custom metadata to set for this file or directory. |
| | 1624 | | /// </param> |
| | 1625 | | /// <param name="permissions"> |
| | 1626 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 1627 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 1628 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 1629 | | /// octal notation (e.g. 0766) are supported. |
| | 1630 | | /// </param> |
| | 1631 | | /// <param name="umask"> |
| | 1632 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 1633 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 1634 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 1635 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 1636 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 1637 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 1638 | | /// in 4-digit octal notation (e.g. 0766). |
| | 1639 | | /// </param> |
| | 1640 | | /// <param name="conditions"> |
| | 1641 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 1642 | | /// conditions on the creation of this file or directory. |
| | 1643 | | /// </param> |
| | 1644 | | /// <param name="cancellationToken"> |
| | 1645 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1646 | | /// notifications that the operation should be cancelled. |
| | 1647 | | /// </param> |
| | 1648 | | /// <returns> |
| | 1649 | | /// A <see cref="Response{DataLakeFileClient}"/> for the |
| | 1650 | | /// newly created file. |
| | 1651 | | /// </returns> |
| | 1652 | | /// <remarks> |
| | 1653 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1654 | | /// a failure occurs. |
| | 1655 | | /// </remarks> |
| | 1656 | | public virtual Response<DataLakeFileClient> CreateFile( |
| | 1657 | | string fileName, |
| | 1658 | | PathHttpHeaders httpHeaders = default, |
| | 1659 | | Metadata metadata = default, |
| | 1660 | | string permissions = default, |
| | 1661 | | string umask = default, |
| | 1662 | | DataLakeRequestConditions conditions = default, |
| | 1663 | | CancellationToken cancellationToken = default) |
| | 1664 | | { |
| 2 | 1665 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateFile |
| | 1666 | |
|
| | 1667 | | try |
| | 1668 | | { |
| 2 | 1669 | | scope.Start(); |
| | 1670 | |
|
| 2 | 1671 | | DataLakeFileClient fileClient = GetFileClient(fileName); |
| | 1672 | |
|
| 2 | 1673 | | Response<PathInfo> response = fileClient.Create( |
| 2 | 1674 | | httpHeaders, |
| 2 | 1675 | | metadata, |
| 2 | 1676 | | permissions, |
| 2 | 1677 | | umask, |
| 2 | 1678 | | conditions, |
| 2 | 1679 | | cancellationToken); |
| | 1680 | |
|
| 0 | 1681 | | return Response.FromValue( |
| 0 | 1682 | | fileClient, |
| 0 | 1683 | | response.GetRawResponse()); |
| | 1684 | | } |
| 2 | 1685 | | catch (Exception ex) |
| | 1686 | | { |
| 2 | 1687 | | scope.Failed(ex); |
| 2 | 1688 | | throw; |
| | 1689 | | } |
| | 1690 | | finally |
| | 1691 | | { |
| 2 | 1692 | | scope.Dispose(); |
| 2 | 1693 | | } |
| 0 | 1694 | | } |
| | 1695 | |
|
| | 1696 | | /// <summary> |
| | 1697 | | /// The <see cref="CreateFileAsync"/> operation creates a new file in this directory. |
| | 1698 | | /// If the file already exists, it will be overwritten. If you don't intent to overwrite |
| | 1699 | | /// an existing file, consider using the <see cref="DataLakeFileClient.CreateIfNotExistsAsync"/> API. |
| | 1700 | | /// |
| | 1701 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 1702 | | /// </summary> |
| | 1703 | | /// <param name="fileName"> |
| | 1704 | | /// Name of the file to create. |
| | 1705 | | /// </param> |
| | 1706 | | /// <param name="httpHeaders"> |
| | 1707 | | /// Optional standard HTTP header properties that can be set for the |
| | 1708 | | /// new file or directory.. |
| | 1709 | | /// </param> |
| | 1710 | | /// <param name="metadata"> |
| | 1711 | | /// Optional custom metadata to set for this file or directory. |
| | 1712 | | /// </param> |
| | 1713 | | /// <param name="permissions"> |
| | 1714 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 1715 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 1716 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 1717 | | /// octal notation (e.g. 0766) are supported. |
| | 1718 | | /// </param> |
| | 1719 | | /// <param name="umask"> |
| | 1720 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 1721 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 1722 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 1723 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 1724 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 1725 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 1726 | | /// in 4-digit octal notation (e.g. 0766). |
| | 1727 | | /// </param> |
| | 1728 | | /// <param name="conditions"> |
| | 1729 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 1730 | | /// conditions on the creation of this file or directory. |
| | 1731 | | /// </param> |
| | 1732 | | /// <param name="cancellationToken"> |
| | 1733 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1734 | | /// notifications that the operation should be cancelled. |
| | 1735 | | /// </param> |
| | 1736 | | /// <returns> |
| | 1737 | | /// A <see cref="Response{DataLakeFileClient}"/> for the |
| | 1738 | | /// newly created file. |
| | 1739 | | /// </returns> |
| | 1740 | | /// <remarks> |
| | 1741 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1742 | | /// a failure occurs. |
| | 1743 | | /// </remarks> |
| | 1744 | | public virtual async Task<Response<DataLakeFileClient>> CreateFileAsync( |
| | 1745 | | string fileName, |
| | 1746 | | PathHttpHeaders httpHeaders = default, |
| | 1747 | | Metadata metadata = default, |
| | 1748 | | string permissions = default, |
| | 1749 | | string umask = default, |
| | 1750 | | DataLakeRequestConditions conditions = default, |
| | 1751 | | CancellationToken cancellationToken = default) |
| | 1752 | | { |
| 122 | 1753 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateFile |
| | 1754 | |
|
| | 1755 | | try |
| | 1756 | | { |
| 122 | 1757 | | scope.Start(); |
| | 1758 | |
|
| 122 | 1759 | | DataLakeFileClient fileClient = GetFileClient(fileName); |
| | 1760 | |
|
| 122 | 1761 | | Response<PathInfo> response = await fileClient.CreateAsync( |
| 122 | 1762 | | httpHeaders, |
| 122 | 1763 | | metadata, |
| 122 | 1764 | | permissions, |
| 122 | 1765 | | umask, |
| 122 | 1766 | | conditions, |
| 122 | 1767 | | cancellationToken) |
| 122 | 1768 | | .ConfigureAwait(false); |
| | 1769 | |
|
| 120 | 1770 | | return Response.FromValue( |
| 120 | 1771 | | fileClient, |
| 120 | 1772 | | response.GetRawResponse()); |
| | 1773 | | } |
| 2 | 1774 | | catch (Exception ex) |
| | 1775 | | { |
| 2 | 1776 | | scope.Failed(ex); |
| 2 | 1777 | | throw; |
| | 1778 | | } |
| | 1779 | | finally |
| | 1780 | | { |
| 122 | 1781 | | scope.Dispose(); |
| | 1782 | | } |
| 120 | 1783 | | } |
| | 1784 | | #endregion Create File |
| | 1785 | |
|
| | 1786 | | #region Delete File |
| | 1787 | | /// <summary> |
| | 1788 | | /// The <see cref="DeleteFile"/> operation deletes a file |
| | 1789 | | /// in this directory. |
| | 1790 | | /// |
| | 1791 | | /// For more information, see |
| | 1792 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 1793 | | /// Delete Path</see>. |
| | 1794 | | /// </summary> |
| | 1795 | | /// <param name="fileName"> |
| | 1796 | | /// The name of the file to delete. |
| | 1797 | | /// </param> |
| | 1798 | | /// <param name="conditions"> |
| | 1799 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1800 | | /// deleting this path. |
| | 1801 | | /// </param> |
| | 1802 | | /// <param name="cancellationToken"> |
| | 1803 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1804 | | /// notifications that the operation should be cancelled. |
| | 1805 | | /// </param> |
| | 1806 | | /// <returns> |
| | 1807 | | /// A <see cref="Response"/> on successfully deleting. |
| | 1808 | | /// </returns> |
| | 1809 | | /// <remarks> |
| | 1810 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1811 | | /// a failure occurs. |
| | 1812 | | /// </remarks> |
| | 1813 | | public virtual Response DeleteFile( |
| | 1814 | | string fileName, |
| | 1815 | | DataLakeRequestConditions conditions = default, |
| | 1816 | | CancellationToken cancellationToken = default) |
| | 1817 | | { |
| 2 | 1818 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteFile |
| | 1819 | |
|
| | 1820 | | try |
| | 1821 | | { |
| 2 | 1822 | | scope.Start(); |
| | 1823 | |
|
| 2 | 1824 | | return GetFileClient(fileName).Delete( |
| 2 | 1825 | | conditions, |
| 2 | 1826 | | cancellationToken); |
| | 1827 | | } |
| 2 | 1828 | | catch (Exception ex) |
| | 1829 | | { |
| 2 | 1830 | | scope.Failed(ex); |
| 2 | 1831 | | throw; |
| | 1832 | | } |
| | 1833 | | finally |
| | 1834 | | { |
| 2 | 1835 | | scope.Dispose(); |
| 2 | 1836 | | } |
| 0 | 1837 | | } |
| | 1838 | |
|
| | 1839 | | /// <summary> |
| | 1840 | | /// The <see cref="DeleteFileAsync"/> operation deletes a file |
| | 1841 | | /// in this directory. |
| | 1842 | | /// |
| | 1843 | | /// For more information, see |
| | 1844 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 1845 | | /// Delete Path</see>. |
| | 1846 | | /// </summary> |
| | 1847 | | /// <param name="fileName"> |
| | 1848 | | /// The name of the file to delete. |
| | 1849 | | /// </param> |
| | 1850 | | /// <param name="conditions"> |
| | 1851 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 1852 | | /// deleting this path. |
| | 1853 | | /// </param> |
| | 1854 | | /// <param name="cancellationToken"> |
| | 1855 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1856 | | /// notifications that the operation should be cancelled. |
| | 1857 | | /// </param> |
| | 1858 | | /// <returns> |
| | 1859 | | /// A <see cref="Response"/> on successfully deleting. |
| | 1860 | | /// </returns> |
| | 1861 | | /// <remarks> |
| | 1862 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1863 | | /// a failure occurs. |
| | 1864 | | /// </remarks> |
| | 1865 | | public virtual async Task<Response> DeleteFileAsync( |
| | 1866 | | string fileName, |
| | 1867 | | DataLakeRequestConditions conditions = default, |
| | 1868 | | CancellationToken cancellationToken = default) |
| | 1869 | | { |
| 6 | 1870 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteFile |
| | 1871 | |
|
| | 1872 | | try |
| | 1873 | | { |
| 6 | 1874 | | scope.Start(); |
| | 1875 | |
|
| 6 | 1876 | | return await GetFileClient(fileName).DeleteAsync( |
| 6 | 1877 | | conditions, |
| 6 | 1878 | | cancellationToken) |
| 6 | 1879 | | .ConfigureAwait(false); |
| | 1880 | | } |
| 2 | 1881 | | catch (Exception ex) |
| | 1882 | | { |
| 2 | 1883 | | scope.Failed(ex); |
| 2 | 1884 | | throw; |
| | 1885 | | } |
| | 1886 | | finally |
| | 1887 | | { |
| 6 | 1888 | | scope.Dispose(); |
| | 1889 | | } |
| 4 | 1890 | | } |
| | 1891 | | #endregion Delete File |
| | 1892 | |
|
| | 1893 | | #region Create Sub Directory |
| | 1894 | | /// <summary> |
| | 1895 | | /// The <see cref="CreateSubDirectory"/> operation creates a sub directory in this directory. |
| | 1896 | | /// |
| | 1897 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 1898 | | /// </summary> |
| | 1899 | | /// <param name="path"> |
| | 1900 | | /// The path to the directory to create. |
| | 1901 | | /// </param> |
| | 1902 | | /// <param name="httpHeaders"> |
| | 1903 | | /// Optional standard HTTP header properties that can be set for the |
| | 1904 | | /// new file or directory.. |
| | 1905 | | /// </param> |
| | 1906 | | /// <param name="metadata"> |
| | 1907 | | /// Optional custom metadata to set for this file or directory.. |
| | 1908 | | /// </param> |
| | 1909 | | /// <param name="permissions"> |
| | 1910 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 1911 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 1912 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 1913 | | /// octal notation (e.g. 0766) are supported. |
| | 1914 | | /// </param> |
| | 1915 | | /// <param name="umask"> |
| | 1916 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 1917 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 1918 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 1919 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 1920 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 1921 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 1922 | | /// in 4-digit octal notation (e.g. 0766). |
| | 1923 | | /// </param> |
| | 1924 | | /// <param name="conditions"> |
| | 1925 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 1926 | | /// conditions on the creation of this file or directory.. |
| | 1927 | | /// </param> |
| | 1928 | | /// <param name="cancellationToken"> |
| | 1929 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 1930 | | /// notifications that the operation should be cancelled. |
| | 1931 | | /// </param> |
| | 1932 | | /// <returns> |
| | 1933 | | /// A <see cref="Response{DataLakeDirectoryClient}"/> for the |
| | 1934 | | /// newly created directory. |
| | 1935 | | /// </returns> |
| | 1936 | | /// <remarks> |
| | 1937 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 1938 | | /// a failure occurs. |
| | 1939 | | /// </remarks> |
| | 1940 | | public virtual Response<DataLakeDirectoryClient> CreateSubDirectory( |
| | 1941 | | string path, |
| | 1942 | | PathHttpHeaders httpHeaders = default, |
| | 1943 | | Metadata metadata = default, |
| | 1944 | | string permissions = default, |
| | 1945 | | string umask = default, |
| | 1946 | | DataLakeRequestConditions conditions = default, |
| | 1947 | | CancellationToken cancellationToken = default) |
| | 1948 | | { |
| 2 | 1949 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateSubD |
| | 1950 | |
|
| | 1951 | | try |
| | 1952 | | { |
| 2 | 1953 | | scope.Start(); |
| | 1954 | |
|
| 2 | 1955 | | DataLakeDirectoryClient directoryClient = GetSubDirectoryClient(path); |
| | 1956 | |
|
| 2 | 1957 | | Response<PathInfo> response = directoryClient.Create( |
| 2 | 1958 | | PathResourceType.Directory, |
| 2 | 1959 | | httpHeaders, |
| 2 | 1960 | | metadata, |
| 2 | 1961 | | permissions, |
| 2 | 1962 | | umask, |
| 2 | 1963 | | conditions, |
| 2 | 1964 | | cancellationToken); |
| | 1965 | |
|
| 0 | 1966 | | return Response.FromValue( |
| 0 | 1967 | | directoryClient, |
| 0 | 1968 | | response.GetRawResponse()); |
| | 1969 | | } |
| 2 | 1970 | | catch (Exception ex) |
| | 1971 | | { |
| 2 | 1972 | | scope.Failed(ex); |
| 2 | 1973 | | throw; |
| | 1974 | | } |
| | 1975 | | finally |
| | 1976 | | { |
| 2 | 1977 | | scope.Dispose(); |
| 2 | 1978 | | } |
| 0 | 1979 | | } |
| | 1980 | |
|
| | 1981 | | /// <summary> |
| | 1982 | | /// The <see cref="CreateSubDirectoryAsync"/> operation creates a sub directory in this directory. |
| | 1983 | | /// |
| | 1984 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | 1985 | | /// </summary> |
| | 1986 | | /// <param name="path"> |
| | 1987 | | /// The path to the directory to create. |
| | 1988 | | /// </param> |
| | 1989 | | /// <param name="httpHeaders"> |
| | 1990 | | /// Optional standard HTTP header properties that can be set for the |
| | 1991 | | /// new file or directory.. |
| | 1992 | | /// </param> |
| | 1993 | | /// <param name="metadata"> |
| | 1994 | | /// Optional custom metadata to set for this file or directory.. |
| | 1995 | | /// </param> |
| | 1996 | | /// <param name="permissions"> |
| | 1997 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | 1998 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | 1999 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | 2000 | | /// octal notation (e.g. 0766) are supported. |
| | 2001 | | /// </param> |
| | 2002 | | /// <param name="umask"> |
| | 2003 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | 2004 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | 2005 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | 2006 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | 2007 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | 2008 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | 2009 | | /// in 4-digit octal notation (e.g. 0766). |
| | 2010 | | /// </param> |
| | 2011 | | /// <param name="conditions"> |
| | 2012 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | 2013 | | /// conditions on the creation of this file or directory.. |
| | 2014 | | /// </param> |
| | 2015 | | /// <param name="cancellationToken"> |
| | 2016 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 2017 | | /// notifications that the operation should be cancelled. |
| | 2018 | | /// </param> |
| | 2019 | | /// <returns> |
| | 2020 | | /// A <see cref="Response{DataLakeDirectoryClient}"/> for the |
| | 2021 | | /// newly created directory. |
| | 2022 | | /// </returns> |
| | 2023 | | /// <remarks> |
| | 2024 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 2025 | | /// a failure occurs. |
| | 2026 | | /// </remarks> |
| | 2027 | | public virtual async Task<Response<DataLakeDirectoryClient>> CreateSubDirectoryAsync( |
| | 2028 | | string path, |
| | 2029 | | PathHttpHeaders httpHeaders = default, |
| | 2030 | | Metadata metadata = default, |
| | 2031 | | string permissions = default, |
| | 2032 | | string umask = default, |
| | 2033 | | DataLakeRequestConditions conditions = default, |
| | 2034 | | CancellationToken cancellationToken = default) |
| | 2035 | | { |
| 130 | 2036 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(CreateSubD |
| | 2037 | |
|
| | 2038 | | try |
| | 2039 | | { |
| 130 | 2040 | | scope.Start(); |
| | 2041 | |
|
| 130 | 2042 | | DataLakeDirectoryClient directoryClient = GetSubDirectoryClient(path); |
| | 2043 | |
|
| 130 | 2044 | | Response<PathInfo> response = await directoryClient.CreateAsync( |
| 130 | 2045 | | PathResourceType.Directory, |
| 130 | 2046 | | httpHeaders, |
| 130 | 2047 | | metadata, |
| 130 | 2048 | | permissions, |
| 130 | 2049 | | umask, |
| 130 | 2050 | | conditions, |
| 130 | 2051 | | cancellationToken) |
| 130 | 2052 | | .ConfigureAwait(false); |
| | 2053 | |
|
| 128 | 2054 | | return Response.FromValue( |
| 128 | 2055 | | directoryClient, |
| 128 | 2056 | | response.GetRawResponse()); |
| | 2057 | | } |
| 2 | 2058 | | catch (Exception ex) |
| | 2059 | | { |
| 2 | 2060 | | scope.Failed(ex); |
| 2 | 2061 | | throw; |
| | 2062 | | } |
| | 2063 | | finally |
| | 2064 | | { |
| 130 | 2065 | | scope.Dispose(); |
| | 2066 | | } |
| 128 | 2067 | | } |
| | 2068 | | #endregion Create Sub Directory |
| | 2069 | |
|
| | 2070 | | #region Delete Sub Directory |
| | 2071 | | /// <summary> |
| | 2072 | | /// The <see cref="DeleteSubDirectory"/> deletes a sub directory in this directory. |
| | 2073 | | /// |
| | 2074 | | /// For more information, see |
| | 2075 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 2076 | | /// Delete Path</see>. |
| | 2077 | | /// </summary> |
| | 2078 | | /// <param name="path"> |
| | 2079 | | /// The path to the directory to delete. |
| | 2080 | | /// </param> |
| | 2081 | | /// <param name="continuation"> |
| | 2082 | | /// Optional. When deleting a directory, the number of paths that are deleted with each invocation is limited. |
| | 2083 | | /// If the number of paths to be deleted exceeds this limit, a continuation token is returned in this response h |
| | 2084 | | /// When a continuation token is returned in the response, it must be specified in a subsequent invocation of th |
| | 2085 | | /// operation to continue deleting the directory. |
| | 2086 | | /// </param> |
| | 2087 | | /// <param name="conditions"> |
| | 2088 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 2089 | | /// deleting this path. |
| | 2090 | | /// </param> |
| | 2091 | | /// <param name="cancellationToken"> |
| | 2092 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 2093 | | /// notifications that the operation should be cancelled. |
| | 2094 | | /// </param> |
| | 2095 | | /// <returns> |
| | 2096 | | /// A <see cref="Response"/> on successfully deleting. |
| | 2097 | | /// </returns> |
| | 2098 | | /// <remarks> |
| | 2099 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 2100 | | /// a failure occurs. |
| | 2101 | | /// </remarks> |
| | 2102 | | public virtual Response DeleteSubDirectory( |
| | 2103 | | string path, |
| | 2104 | | string continuation = default, |
| | 2105 | | DataLakeRequestConditions conditions = default, |
| | 2106 | | CancellationToken cancellationToken = default) |
| | 2107 | | { |
| 0 | 2108 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteSubD |
| | 2109 | |
|
| | 2110 | | try |
| | 2111 | | { |
| 0 | 2112 | | scope.Start(); |
| | 2113 | |
|
| 0 | 2114 | | return GetSubDirectoryClient(path).Delete( |
| 0 | 2115 | | recursive: true, |
| 0 | 2116 | | conditions, |
| 0 | 2117 | | cancellationToken); |
| | 2118 | | } |
| 0 | 2119 | | catch (Exception ex) |
| | 2120 | | { |
| 0 | 2121 | | scope.Failed(ex); |
| 0 | 2122 | | throw; |
| | 2123 | | } |
| | 2124 | | finally |
| | 2125 | | { |
| 0 | 2126 | | scope.Dispose(); |
| 0 | 2127 | | } |
| 0 | 2128 | | } |
| | 2129 | |
|
| | 2130 | | /// <summary> |
| | 2131 | | /// The <see cref="DeleteSubDirectoryAsync"/> deletes a sub directory in this directory. |
| | 2132 | | /// |
| | 2133 | | /// For more information, see |
| | 2134 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | 2135 | | /// Delete Path</see>. |
| | 2136 | | /// </summary> |
| | 2137 | | /// <param name="path"> |
| | 2138 | | /// The path to the directory to delete. |
| | 2139 | | /// </param> |
| | 2140 | | /// <param name="continuation"> |
| | 2141 | | /// Optional. When deleting a directory, the number of paths that are deleted with each invocation is limited. |
| | 2142 | | /// If the number of paths to be deleted exceeds this limit, a continuation token is returned in this response h |
| | 2143 | | /// When a continuation token is returned in the response, it must be specified in a subsequent invocation of th |
| | 2144 | | /// operation to continue deleting the directory. |
| | 2145 | | /// </param> |
| | 2146 | | /// <param name="conditions"> |
| | 2147 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | 2148 | | /// deleting this path. |
| | 2149 | | /// </param> |
| | 2150 | | /// <param name="cancellationToken"> |
| | 2151 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | 2152 | | /// notifications that the operation should be cancelled. |
| | 2153 | | /// </param> |
| | 2154 | | /// <returns> |
| | 2155 | | /// A <see cref="Response"/> on successfully deleting. |
| | 2156 | | /// </returns> |
| | 2157 | | /// <remarks> |
| | 2158 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | 2159 | | /// a failure occurs. |
| | 2160 | | /// </remarks> |
| | 2161 | | public virtual async Task<Response> DeleteSubDirectoryAsync( |
| | 2162 | | string path, |
| | 2163 | | string continuation = default, |
| | 2164 | | DataLakeRequestConditions conditions = default, |
| | 2165 | | CancellationToken cancellationToken = default) |
| | 2166 | | { |
| 0 | 2167 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeDirectoryClient)}.{nameof(DeleteSubD |
| | 2168 | |
|
| | 2169 | | try |
| | 2170 | | { |
| 0 | 2171 | | scope.Start(); |
| | 2172 | |
|
| 0 | 2173 | | return await GetSubDirectoryClient(path).DeleteAsync( |
| 0 | 2174 | | recursive: true, |
| 0 | 2175 | | conditions, |
| 0 | 2176 | | cancellationToken) |
| 0 | 2177 | | .ConfigureAwait(false); |
| | 2178 | | } |
| 0 | 2179 | | catch (Exception ex) |
| | 2180 | | { |
| 0 | 2181 | | scope.Failed(ex); |
| 0 | 2182 | | throw; |
| | 2183 | | } |
| | 2184 | | finally |
| | 2185 | | { |
| 0 | 2186 | | scope.Dispose(); |
| | 2187 | | } |
| 0 | 2188 | | } |
| | 2189 | | #endregion Delete Sub Directory |
| | 2190 | | } |
| | 2191 | | } |