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