| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Buffers; |
| | | 6 | | using System.Collections.Generic; |
| | | 7 | | using System.ComponentModel; |
| | | 8 | | using System.Diagnostics; |
| | | 9 | | using System.Globalization; |
| | | 10 | | using System.IO; |
| | | 11 | | using System.Linq; |
| | | 12 | | using System.Threading; |
| | | 13 | | using System.Threading.Tasks; |
| | | 14 | | using Azure.Core; |
| | | 15 | | using Azure.Core.Pipeline; |
| | | 16 | | using Azure.Storage.Blobs.Models; |
| | | 17 | | using Azure.Storage.Files.DataLake.Models; |
| | | 18 | | using Metadata = System.Collections.Generic.IDictionary<string, string>; |
| | | 19 | | |
| | | 20 | | namespace Azure.Storage.Files.DataLake |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// The <see cref="DataLakeFileClient"/> allows you to manipulate Azure Data Lake files. |
| | | 24 | | /// </summary> |
| | | 25 | | public class DataLakeFileClient : DataLakePathClient |
| | | 26 | | { |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the maximum number of bytes that can be sent in a call |
| | | 29 | | /// to <see cref="UploadAsync(Stream, PathHttpHeaders, DataLakeRequestConditions, IProgress{long}, StorageTransf |
| | | 30 | | /// </summary> |
| | 0 | 31 | | public virtual int MaxUploadBytes => Constants.DataLake.MaxAppendBytes; |
| | | 32 | | |
| | | 33 | | #region ctors |
| | | 34 | | /// <summary> |
| | | 35 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> |
| | | 36 | | /// class for mocking. |
| | | 37 | | /// </summary> |
| | 504 | 38 | | protected DataLakeFileClient() |
| | | 39 | | { |
| | 504 | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 44 | | /// </summary> |
| | | 45 | | /// <param name="fileUri"> |
| | | 46 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 47 | | /// name of the account, the name of the file system, and the path of the |
| | | 48 | | /// file. |
| | | 49 | | /// </param> |
| | | 50 | | public DataLakeFileClient(Uri fileUri) |
| | 4 | 51 | | : this(fileUri, (HttpPipelinePolicy)null, null) |
| | | 52 | | { |
| | 4 | 53 | | } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <param name="fileUri"> |
| | | 59 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 60 | | /// name of the account, the name of the file system, and the path of the |
| | | 61 | | /// file. |
| | | 62 | | /// </param> |
| | | 63 | | /// <param name="options"> |
| | | 64 | | /// Optional <see cref="DataLakeClientOptions"/> that define the transport |
| | | 65 | | /// pipeline policies for authentication, retries, etc., that are |
| | | 66 | | /// applied to every request. |
| | | 67 | | /// </param> |
| | | 68 | | public DataLakeFileClient(Uri fileUri, DataLakeClientOptions options) |
| | 44 | 69 | | : this(fileUri, (HttpPipelinePolicy)null, options) |
| | | 70 | | { |
| | 44 | 71 | | } |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 75 | | /// </summary> |
| | | 76 | | /// <param name="fileUri"> |
| | | 77 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 78 | | /// name of the account, the name of the file system, and the path of the |
| | | 79 | | /// file. |
| | | 80 | | /// </param> |
| | | 81 | | /// <param name="credential"> |
| | | 82 | | /// The shared key credential used to sign requests. |
| | | 83 | | /// </param> |
| | | 84 | | public DataLakeFileClient(Uri fileUri, StorageSharedKeyCredential credential) |
| | 0 | 85 | | : this(fileUri, credential.AsPolicy(), null) |
| | | 86 | | { |
| | 0 | 87 | | } |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 91 | | /// </summary> |
| | | 92 | | /// <param name="fileUri"> |
| | | 93 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 94 | | /// name of the account, the name of the file system, and the path of the |
| | | 95 | | /// file. |
| | | 96 | | /// </param> |
| | | 97 | | /// <param name="credential"> |
| | | 98 | | /// The shared key credential used to sign requests. |
| | | 99 | | /// </param> |
| | | 100 | | /// <param name="options"> |
| | | 101 | | /// Optional <see cref="DataLakeClientOptions"/> that define the transport |
| | | 102 | | /// pipeline policies for authentication, retries, etc., that are |
| | | 103 | | /// applied to every request. |
| | | 104 | | /// </param> |
| | | 105 | | public DataLakeFileClient(Uri fileUri, StorageSharedKeyCredential credential, DataLakeClientOptions options) |
| | 4 | 106 | | : this(fileUri, credential.AsPolicy(), options) |
| | | 107 | | { |
| | 4 | 108 | | } |
| | | 109 | | |
| | | 110 | | /// <summary> |
| | | 111 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 112 | | /// </summary> |
| | | 113 | | /// <param name="fileUri"> |
| | | 114 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 115 | | /// name of the account, the name of the file system, and the path of the |
| | | 116 | | /// file. |
| | | 117 | | /// </param> |
| | | 118 | | /// <param name="credential"> |
| | | 119 | | /// The token credential used to sign requests. |
| | | 120 | | /// </param> |
| | | 121 | | public DataLakeFileClient(Uri fileUri, TokenCredential credential) |
| | 4 | 122 | | : this(fileUri, credential.AsPolicy(), null) |
| | | 123 | | { |
| | 4 | 124 | | Errors.VerifyHttpsTokenAuth(fileUri); |
| | 0 | 125 | | } |
| | | 126 | | |
| | | 127 | | /// <summary> |
| | | 128 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 129 | | /// </summary> |
| | | 130 | | /// <param name="fileUri"> |
| | | 131 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 132 | | /// name of the account, the name of the file system, and the path of the |
| | | 133 | | /// file. |
| | | 134 | | /// </param> |
| | | 135 | | /// <param name="credential"> |
| | | 136 | | /// The token credential used to sign requests. |
| | | 137 | | /// </param> |
| | | 138 | | /// <param name="options"> |
| | | 139 | | /// Optional <see cref="DataLakeClientOptions"/> that define the transport |
| | | 140 | | /// pipeline policies for authentication, retries, etc., that are |
| | | 141 | | /// applied to every request. |
| | | 142 | | /// </param> |
| | | 143 | | public DataLakeFileClient(Uri fileUri, TokenCredential credential, DataLakeClientOptions options) |
| | 8 | 144 | | : this(fileUri, credential.AsPolicy(), options) |
| | | 145 | | { |
| | 8 | 146 | | Errors.VerifyHttpsTokenAuth(fileUri); |
| | 4 | 147 | | } |
| | | 148 | | |
| | | 149 | | /// <summary> |
| | | 150 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> |
| | | 151 | | /// class. |
| | | 152 | | /// </summary> |
| | | 153 | | /// <param name="fileUri"> |
| | | 154 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 155 | | /// name of the account, the name of the file system, and the path of the |
| | | 156 | | /// file. |
| | | 157 | | /// </param> |
| | | 158 | | /// <param name="authentication"> |
| | | 159 | | /// An optional authentication policy used to sign requests. |
| | | 160 | | /// </param> |
| | | 161 | | /// <param name="options"> |
| | | 162 | | /// Optional client options that define the transport pipeline |
| | | 163 | | /// policies for authentication, retries, etc., that are applied to |
| | | 164 | | /// every request. |
| | | 165 | | /// </param> |
| | | 166 | | internal DataLakeFileClient(Uri fileUri, HttpPipelinePolicy authentication, DataLakeClientOptions options) |
| | 64 | 167 | | : base(fileUri, authentication, options) |
| | | 168 | | { |
| | 64 | 169 | | } |
| | | 170 | | |
| | | 171 | | /// <summary> |
| | | 172 | | /// Initializes a new instance of the <see cref="DataLakeFileClient"/> class. |
| | | 173 | | /// </summary> |
| | | 174 | | /// <param name="fileUri"> |
| | | 175 | | /// A <see cref="Uri"/> referencing the file that includes the |
| | | 176 | | /// name of the account, the name of the file system, and the path of the file. |
| | | 177 | | /// </param> |
| | | 178 | | /// <param name="pipeline"> |
| | | 179 | | /// The transport pipeline used to send every request. |
| | | 180 | | /// </param> |
| | | 181 | | /// <param name="version"> |
| | | 182 | | /// The version of the service to use when sending requests. |
| | | 183 | | /// </param> |
| | | 184 | | /// <param name="clientDiagnostics"> |
| | | 185 | | /// The <see cref="ClientDiagnostics"/> instance used to create |
| | | 186 | | /// diagnostic scopes every request. |
| | | 187 | | /// </param> |
| | | 188 | | internal DataLakeFileClient( |
| | | 189 | | Uri fileUri, |
| | | 190 | | HttpPipeline pipeline, |
| | | 191 | | DataLakeClientOptions.ServiceVersion version, |
| | | 192 | | ClientDiagnostics clientDiagnostics) |
| | 224 | 193 | | : base( |
| | 224 | 194 | | fileUri, |
| | 224 | 195 | | pipeline, |
| | 224 | 196 | | version, |
| | 224 | 197 | | clientDiagnostics) |
| | | 198 | | { |
| | 224 | 199 | | } |
| | | 200 | | |
| | | 201 | | internal DataLakeFileClient( |
| | | 202 | | Uri fileSystemUri, |
| | | 203 | | string filePath, |
| | | 204 | | HttpPipeline pipeline, |
| | | 205 | | DataLakeClientOptions.ServiceVersion version, |
| | | 206 | | ClientDiagnostics clientDiagnostics) |
| | 1444 | 207 | | : base( |
| | 1444 | 208 | | fileSystemUri, |
| | 1444 | 209 | | filePath, |
| | 1444 | 210 | | pipeline, |
| | 1444 | 211 | | version, |
| | 1444 | 212 | | clientDiagnostics) |
| | | 213 | | { |
| | 1444 | 214 | | } |
| | | 215 | | #endregion ctors |
| | | 216 | | |
| | | 217 | | #region Create |
| | | 218 | | /// <summary> |
| | | 219 | | /// The <see cref="Create"/> operation creates a file. |
| | | 220 | | /// If the file already exists, it will be overwritten. If you don't intent to overwrite |
| | | 221 | | /// an existing file, consider using the <see cref="CreateIfNotExists"/> API. |
| | | 222 | | /// |
| | | 223 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 224 | | /// </summary> |
| | | 225 | | /// <param name="httpHeaders"> |
| | | 226 | | /// Optional standard HTTP header properties that can be set for the |
| | | 227 | | /// new file or directory.. |
| | | 228 | | /// </param> |
| | | 229 | | /// <param name="metadata"> |
| | | 230 | | /// Optional custom metadata to set for this file or directory. |
| | | 231 | | /// </param> |
| | | 232 | | /// <param name="permissions"> |
| | | 233 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | | 234 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | | 235 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | | 236 | | /// octal notation (e.g. 0766) are supported. |
| | | 237 | | /// </param> |
| | | 238 | | /// <param name="umask"> |
| | | 239 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | | 240 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | | 241 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | | 242 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | | 243 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | | 244 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | | 245 | | /// in 4-digit octal notation (e.g. 0766). |
| | | 246 | | /// </param> |
| | | 247 | | /// <param name="conditions"> |
| | | 248 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 249 | | /// conditions on the creation of this file or directory. |
| | | 250 | | /// </param> |
| | | 251 | | /// <param name="cancellationToken"> |
| | | 252 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 253 | | /// notifications that the operation should be cancelled. |
| | | 254 | | /// </param> |
| | | 255 | | /// <returns> |
| | | 256 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 257 | | /// newly created file. |
| | | 258 | | /// </returns> |
| | | 259 | | /// <remarks> |
| | | 260 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 261 | | /// a failure occurs. |
| | | 262 | | /// </remarks> |
| | | 263 | | public virtual Response<PathInfo> Create( |
| | | 264 | | PathHttpHeaders httpHeaders = default, |
| | | 265 | | Metadata metadata = default, |
| | | 266 | | string permissions = default, |
| | | 267 | | string umask = default, |
| | | 268 | | DataLakeRequestConditions conditions = default, |
| | | 269 | | CancellationToken cancellationToken = default) |
| | | 270 | | { |
| | 498 | 271 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Create)}"); |
| | | 272 | | |
| | | 273 | | try |
| | | 274 | | { |
| | 498 | 275 | | scope.Start(); |
| | | 276 | | |
| | 498 | 277 | | return base.Create( |
| | 498 | 278 | | PathResourceType.File, |
| | 498 | 279 | | httpHeaders, |
| | 498 | 280 | | metadata, |
| | 498 | 281 | | permissions, |
| | 498 | 282 | | umask, |
| | 498 | 283 | | conditions, |
| | 498 | 284 | | cancellationToken); |
| | | 285 | | } |
| | 4 | 286 | | catch (Exception ex) |
| | | 287 | | { |
| | 4 | 288 | | scope.Failed(ex); |
| | 4 | 289 | | throw; |
| | | 290 | | } |
| | | 291 | | finally |
| | | 292 | | { |
| | 498 | 293 | | scope.Dispose(); |
| | 498 | 294 | | } |
| | 494 | 295 | | } |
| | | 296 | | |
| | | 297 | | /// <summary> |
| | | 298 | | /// The <see cref="Create"/> operation creates a file. |
| | | 299 | | /// If the file already exists, it will be overwritten. If you don't intent to overwrite |
| | | 300 | | /// an existing file, consider using the <see cref="CreateIfNotExistsAsync"/> API. |
| | | 301 | | /// |
| | | 302 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 303 | | /// </summary> |
| | | 304 | | /// <param name="httpHeaders"> |
| | | 305 | | /// Optional standard HTTP header properties that can be set for the |
| | | 306 | | /// new file or directory.. |
| | | 307 | | /// </param> |
| | | 308 | | /// <param name="metadata"> |
| | | 309 | | /// Optional custom metadata to set for this file or directory. |
| | | 310 | | /// </param> |
| | | 311 | | /// <param name="permissions"> |
| | | 312 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | | 313 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | | 314 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | | 315 | | /// octal notation (e.g. 0766) are supported. |
| | | 316 | | /// </param> |
| | | 317 | | /// <param name="umask"> |
| | | 318 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | | 319 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | | 320 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | | 321 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | | 322 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | | 323 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | | 324 | | /// in 4-digit octal notation (e.g. 0766). |
| | | 325 | | /// </param> |
| | | 326 | | /// <param name="conditions"> |
| | | 327 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 328 | | /// conditions on the creation of this file or directory. |
| | | 329 | | /// </param> |
| | | 330 | | /// <param name="cancellationToken"> |
| | | 331 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 332 | | /// notifications that the operation should be cancelled. |
| | | 333 | | /// </param> |
| | | 334 | | /// <returns> |
| | | 335 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 336 | | /// newly created file. |
| | | 337 | | /// </returns> |
| | | 338 | | /// <remarks> |
| | | 339 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 340 | | /// a failure occurs. |
| | | 341 | | /// </remarks> |
| | | 342 | | public virtual async Task<Response<PathInfo>> CreateAsync( |
| | | 343 | | PathHttpHeaders httpHeaders = default, |
| | | 344 | | Metadata metadata = default, |
| | | 345 | | string permissions = default, |
| | | 346 | | string umask = default, |
| | | 347 | | DataLakeRequestConditions conditions = default, |
| | | 348 | | CancellationToken cancellationToken = default) |
| | | 349 | | { |
| | 674 | 350 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Create)}"); |
| | | 351 | | |
| | | 352 | | try |
| | | 353 | | { |
| | 674 | 354 | | scope.Start(); |
| | | 355 | | |
| | 674 | 356 | | return await base.CreateAsync( |
| | 674 | 357 | | PathResourceType.File, |
| | 674 | 358 | | httpHeaders, |
| | 674 | 359 | | metadata, |
| | 674 | 360 | | permissions, |
| | 674 | 361 | | umask, |
| | 674 | 362 | | conditions, |
| | 674 | 363 | | cancellationToken) |
| | 674 | 364 | | .ConfigureAwait(false); |
| | | 365 | | } |
| | 24 | 366 | | catch (Exception ex) |
| | | 367 | | { |
| | 24 | 368 | | scope.Failed(ex); |
| | 24 | 369 | | throw; |
| | | 370 | | } |
| | | 371 | | finally |
| | | 372 | | { |
| | 674 | 373 | | scope.Dispose(); |
| | | 374 | | } |
| | 650 | 375 | | } |
| | | 376 | | #endregion Create |
| | | 377 | | |
| | | 378 | | #region Create If Not Exists |
| | | 379 | | /// <summary> |
| | | 380 | | /// The <see cref="CreateIfNotExists"/> operation creates a file. |
| | | 381 | | /// If the file already exists, it is not changed. |
| | | 382 | | /// |
| | | 383 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 384 | | /// </summary> |
| | | 385 | | /// <param name="httpHeaders"> |
| | | 386 | | /// Optional standard HTTP header properties that can be set for the |
| | | 387 | | /// new file or directory.. |
| | | 388 | | /// </param> |
| | | 389 | | /// <param name="metadata"> |
| | | 390 | | /// Optional custom metadata to set for this file or directory.. |
| | | 391 | | /// </param> |
| | | 392 | | /// <param name="permissions"> |
| | | 393 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | | 394 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | | 395 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | | 396 | | /// octal notation (e.g. 0766) are supported. |
| | | 397 | | /// </param> |
| | | 398 | | /// <param name="umask"> |
| | | 399 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | | 400 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | | 401 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | | 402 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | | 403 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | | 404 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | | 405 | | /// in 4-digit octal notation (e.g. 0766). |
| | | 406 | | /// </param> |
| | | 407 | | /// <param name="cancellationToken"> |
| | | 408 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 409 | | /// notifications that the operation should be cancelled. |
| | | 410 | | /// </param> |
| | | 411 | | /// <returns> |
| | | 412 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 413 | | /// newly created file. |
| | | 414 | | /// </returns> |
| | | 415 | | /// <remarks> |
| | | 416 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 417 | | /// a failure occurs. |
| | | 418 | | /// </remarks> |
| | | 419 | | public virtual Response<PathInfo> CreateIfNotExists( |
| | | 420 | | PathHttpHeaders httpHeaders = default, |
| | | 421 | | Metadata metadata = default, |
| | | 422 | | string permissions = default, |
| | | 423 | | string umask = default, |
| | | 424 | | CancellationToken cancellationToken = default) |
| | | 425 | | { |
| | 6 | 426 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(CreateIfNotExis |
| | | 427 | | |
| | | 428 | | try |
| | | 429 | | { |
| | 6 | 430 | | scope.Start(); |
| | | 431 | | |
| | 6 | 432 | | return base.CreateIfNotExists( |
| | 6 | 433 | | PathResourceType.File, |
| | 6 | 434 | | httpHeaders, |
| | 6 | 435 | | metadata, |
| | 6 | 436 | | permissions, |
| | 6 | 437 | | umask, |
| | 6 | 438 | | cancellationToken); |
| | | 439 | | } |
| | 2 | 440 | | catch (Exception ex) |
| | | 441 | | { |
| | 2 | 442 | | scope.Failed(ex); |
| | 2 | 443 | | throw; |
| | | 444 | | } |
| | | 445 | | finally |
| | | 446 | | { |
| | 6 | 447 | | scope.Dispose(); |
| | 6 | 448 | | } |
| | 4 | 449 | | } |
| | | 450 | | |
| | | 451 | | /// <summary> |
| | | 452 | | /// The <see cref="CreateIfNotExistsAsync"/> operation creates a file. |
| | | 453 | | /// If the file already exists, it is not changed. |
| | | 454 | | /// |
| | | 455 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 456 | | /// </summary> |
| | | 457 | | /// <param name="httpHeaders"> |
| | | 458 | | /// Optional standard HTTP header properties that can be set for the |
| | | 459 | | /// new file or directory.. |
| | | 460 | | /// </param> |
| | | 461 | | /// <param name="metadata"> |
| | | 462 | | /// Optional custom metadata to set for this file or directory.. |
| | | 463 | | /// </param> |
| | | 464 | | /// <param name="permissions"> |
| | | 465 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access |
| | | 466 | | /// permissions for the file owner, the file owning group, and others. Each class may be granted read, |
| | | 467 | | /// write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit |
| | | 468 | | /// octal notation (e.g. 0766) are supported. |
| | | 469 | | /// </param> |
| | | 470 | | /// <param name="umask"> |
| | | 471 | | /// Optional and only valid if Hierarchical Namespace is enabled for the account. |
| | | 472 | | /// When creating a file or directory and the parent folder does not have a default ACL, |
| | | 473 | | /// the umask restricts the permissions of the file or directory to be created. The resulting |
| | | 474 | | /// permission is given by p bitwise-and ^u, where p is the permission and u is the umask. For example, |
| | | 475 | | /// if p is 0777 and u is 0057, then the resulting permission is 0720. The default permission is |
| | | 476 | | /// 0777 for a directory and 0666 for a file. The default umask is 0027. The umask must be specified |
| | | 477 | | /// in 4-digit octal notation (e.g. 0766). |
| | | 478 | | /// </param> |
| | | 479 | | /// <param name="cancellationToken"> |
| | | 480 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 481 | | /// notifications that the operation should be cancelled. |
| | | 482 | | /// </param> |
| | | 483 | | /// <returns> |
| | | 484 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 485 | | /// newly created file. |
| | | 486 | | /// </returns> |
| | | 487 | | /// <remarks> |
| | | 488 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 489 | | /// a failure occurs. |
| | | 490 | | /// </remarks> |
| | | 491 | | public virtual async Task<Response<PathInfo>> CreateIfNotExistsAsync( |
| | | 492 | | PathHttpHeaders httpHeaders = default, |
| | | 493 | | Metadata metadata = default, |
| | | 494 | | string permissions = default, |
| | | 495 | | string umask = default, |
| | | 496 | | CancellationToken cancellationToken = default) |
| | | 497 | | { |
| | 6 | 498 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(CreateIfNotExis |
| | | 499 | | |
| | | 500 | | try |
| | | 501 | | { |
| | 6 | 502 | | scope.Start(); |
| | | 503 | | |
| | 6 | 504 | | return await base.CreateIfNotExistsAsync( |
| | 6 | 505 | | PathResourceType.File, |
| | 6 | 506 | | httpHeaders, |
| | 6 | 507 | | metadata, |
| | 6 | 508 | | permissions, |
| | 6 | 509 | | umask, |
| | 6 | 510 | | cancellationToken) |
| | 6 | 511 | | .ConfigureAwait(false); |
| | | 512 | | } |
| | 2 | 513 | | catch (Exception ex) |
| | | 514 | | { |
| | 2 | 515 | | scope.Failed(ex); |
| | 2 | 516 | | throw; |
| | | 517 | | } |
| | | 518 | | finally |
| | | 519 | | { |
| | 6 | 520 | | scope.Dispose(); |
| | | 521 | | } |
| | 4 | 522 | | } |
| | | 523 | | #endregion Create If Not Exists |
| | | 524 | | |
| | | 525 | | #region Delete |
| | | 526 | | /// <summary> |
| | | 527 | | /// The <see cref="Delete"/> operation marks the specified path |
| | | 528 | | /// deletion. The path is later deleted during |
| | | 529 | | /// garbage collection. |
| | | 530 | | /// |
| | | 531 | | /// For more information, see |
| | | 532 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | | 533 | | /// Delete Path</see>. |
| | | 534 | | /// </summary> |
| | | 535 | | /// <param name="conditions"> |
| | | 536 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 537 | | /// deleting this path. |
| | | 538 | | /// </param> |
| | | 539 | | /// <param name="cancellationToken"> |
| | | 540 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 541 | | /// notifications that the operation should be cancelled. |
| | | 542 | | /// </param> |
| | | 543 | | /// <returns> |
| | | 544 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 545 | | /// </returns> |
| | | 546 | | /// <remarks> |
| | | 547 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 548 | | /// a failure occurs. |
| | | 549 | | /// </remarks> |
| | | 550 | | public virtual Response Delete( |
| | | 551 | | DataLakeRequestConditions conditions = default, |
| | | 552 | | CancellationToken cancellationToken = default) |
| | | 553 | | { |
| | 6 | 554 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Delete)}"); |
| | | 555 | | |
| | | 556 | | try |
| | | 557 | | { |
| | 6 | 558 | | scope.Start(); |
| | | 559 | | |
| | 6 | 560 | | return base.Delete( |
| | 6 | 561 | | recursive: null, |
| | 6 | 562 | | conditions, |
| | 6 | 563 | | cancellationToken); |
| | | 564 | | } |
| | 4 | 565 | | catch (Exception ex) |
| | | 566 | | { |
| | 4 | 567 | | scope.Failed(ex); |
| | 4 | 568 | | throw; |
| | | 569 | | } |
| | | 570 | | finally |
| | | 571 | | { |
| | 6 | 572 | | scope.Dispose(); |
| | 6 | 573 | | } |
| | 2 | 574 | | } |
| | | 575 | | |
| | | 576 | | /// <summary> |
| | | 577 | | /// The <see cref="DeleteAsync"/> operation marks the specified path |
| | | 578 | | /// deletion. The path is later deleted during |
| | | 579 | | /// garbage collection. |
| | | 580 | | /// |
| | | 581 | | /// For more information, see |
| | | 582 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | | 583 | | /// Delete Path</see>. |
| | | 584 | | /// </summary> |
| | | 585 | | /// <param name="conditions"> |
| | | 586 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 587 | | /// deleting this path. |
| | | 588 | | /// </param> |
| | | 589 | | /// <param name="cancellationToken"> |
| | | 590 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 591 | | /// notifications that the operation should be cancelled. |
| | | 592 | | /// </param> |
| | | 593 | | /// <returns> |
| | | 594 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 595 | | /// </returns> |
| | | 596 | | /// <remarks> |
| | | 597 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 598 | | /// a failure occurs. |
| | | 599 | | /// </remarks> |
| | | 600 | | public virtual async Task<Response> DeleteAsync( |
| | | 601 | | DataLakeRequestConditions conditions = default, |
| | | 602 | | CancellationToken cancellationToken = default) |
| | | 603 | | { |
| | 62 | 604 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Delete)}"); |
| | | 605 | | |
| | | 606 | | try |
| | | 607 | | { |
| | 62 | 608 | | scope.Start(); |
| | | 609 | | |
| | 62 | 610 | | return await base.DeleteAsync( |
| | 62 | 611 | | recursive: null, |
| | 62 | 612 | | conditions, |
| | 62 | 613 | | cancellationToken) |
| | 62 | 614 | | .ConfigureAwait(false); |
| | | 615 | | } |
| | 28 | 616 | | catch (Exception ex) |
| | | 617 | | { |
| | 28 | 618 | | scope.Failed(ex); |
| | 28 | 619 | | throw; |
| | | 620 | | } |
| | | 621 | | finally |
| | | 622 | | { |
| | 62 | 623 | | scope.Dispose(); |
| | | 624 | | } |
| | 34 | 625 | | } |
| | | 626 | | #endregion Delete |
| | | 627 | | |
| | | 628 | | #region Delete If Exists |
| | | 629 | | /// <summary> |
| | | 630 | | /// The <see cref="DeleteIfExists"/> operation marks the specified file |
| | | 631 | | /// for deletion, if the file exists. The file is later deleted during |
| | | 632 | | /// garbage collection. |
| | | 633 | | /// |
| | | 634 | | /// For more information, see |
| | | 635 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | | 636 | | /// Delete Path</see>. |
| | | 637 | | /// </summary> |
| | | 638 | | /// <param name="conditions"> |
| | | 639 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 640 | | /// deleting this path. |
| | | 641 | | /// </param> |
| | | 642 | | /// <param name="cancellationToken"> |
| | | 643 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 644 | | /// notifications that the operation should be cancelled. |
| | | 645 | | /// </param> |
| | | 646 | | /// <returns> |
| | | 647 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 648 | | /// </returns> |
| | | 649 | | /// <remarks> |
| | | 650 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 651 | | /// a failure occurs. |
| | | 652 | | /// </remarks> |
| | | 653 | | public virtual Response<bool> DeleteIfExists( |
| | | 654 | | DataLakeRequestConditions conditions = default, |
| | | 655 | | CancellationToken cancellationToken = default) |
| | | 656 | | { |
| | 10 | 657 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(DeleteIfExists) |
| | | 658 | | |
| | | 659 | | try |
| | | 660 | | { |
| | 10 | 661 | | scope.Start(); |
| | | 662 | | |
| | 10 | 663 | | return base.DeleteIfExists( |
| | 10 | 664 | | recursive: null, |
| | 10 | 665 | | conditions, |
| | 10 | 666 | | cancellationToken); |
| | | 667 | | } |
| | 4 | 668 | | catch (Exception ex) |
| | | 669 | | { |
| | 4 | 670 | | scope.Failed(ex); |
| | 4 | 671 | | throw; |
| | | 672 | | } |
| | | 673 | | finally |
| | | 674 | | { |
| | 10 | 675 | | scope.Dispose(); |
| | 10 | 676 | | } |
| | 6 | 677 | | } |
| | | 678 | | |
| | | 679 | | /// <summary> |
| | | 680 | | /// The <see cref="DeleteIfExistsAsync"/> operation marks the specified file |
| | | 681 | | /// for deletion, if the file exists. The file is later deleted during |
| | | 682 | | /// garbage collection. |
| | | 683 | | /// |
| | | 684 | | /// For more information, see |
| | | 685 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete"> |
| | | 686 | | /// Delete Path</see>. |
| | | 687 | | /// </summary> |
| | | 688 | | /// <param name="conditions"> |
| | | 689 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 690 | | /// deleting this path. |
| | | 691 | | /// </param> |
| | | 692 | | /// <param name="cancellationToken"> |
| | | 693 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 694 | | /// notifications that the operation should be cancelled. |
| | | 695 | | /// </param> |
| | | 696 | | /// <returns> |
| | | 697 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 698 | | /// </returns> |
| | | 699 | | /// <remarks> |
| | | 700 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 701 | | /// a failure occurs. |
| | | 702 | | /// </remarks> |
| | | 703 | | public virtual async Task<Response<bool>> DeleteIfExistsAsync( |
| | | 704 | | DataLakeRequestConditions conditions = default, |
| | | 705 | | CancellationToken cancellationToken = default) |
| | | 706 | | { |
| | 10 | 707 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(DeleteIfExists) |
| | | 708 | | |
| | | 709 | | try |
| | | 710 | | { |
| | 10 | 711 | | scope.Start(); |
| | | 712 | | |
| | 10 | 713 | | return await base.DeleteIfExistsAsync( |
| | 10 | 714 | | recursive: null, |
| | 10 | 715 | | conditions, |
| | 10 | 716 | | cancellationToken) |
| | 10 | 717 | | .ConfigureAwait(false); |
| | | 718 | | } |
| | 4 | 719 | | catch (Exception ex) |
| | | 720 | | { |
| | 4 | 721 | | scope.Failed(ex); |
| | 4 | 722 | | throw; |
| | | 723 | | } |
| | | 724 | | finally |
| | | 725 | | { |
| | 10 | 726 | | scope.Dispose(); |
| | | 727 | | } |
| | 6 | 728 | | } |
| | | 729 | | #endregion Delete If Not Exists |
| | | 730 | | |
| | | 731 | | #region Rename |
| | | 732 | | /// <summary> |
| | | 733 | | /// The <see cref="Rename"/> operation renames a Directory. |
| | | 734 | | /// |
| | | 735 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 736 | | /// </summary> |
| | | 737 | | /// <param name="destinationPath"> |
| | | 738 | | /// The destination path to rename the path to. |
| | | 739 | | /// </param> |
| | | 740 | | /// <param name="destinationFileSystem"> |
| | | 741 | | /// Optional destination file system. If null, path will be renamed within the |
| | | 742 | | /// current file system. |
| | | 743 | | /// </param> |
| | | 744 | | /// <param name="sourceConditions"> |
| | | 745 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 746 | | /// conditions on the source on the creation of this file or directory. |
| | | 747 | | /// </param> |
| | | 748 | | /// <param name="destinationConditions"> |
| | | 749 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 750 | | /// conditions on the creation of this file or directory. |
| | | 751 | | /// </param> |
| | | 752 | | /// <param name="cancellationToken"> |
| | | 753 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 754 | | /// notifications that the operation should be cancelled. |
| | | 755 | | /// </param> |
| | | 756 | | /// <returns> |
| | | 757 | | /// A <see cref="Response{DataLakeFileClient}"/> describing the |
| | | 758 | | /// newly created file. |
| | | 759 | | /// </returns> |
| | | 760 | | /// <remarks> |
| | | 761 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 762 | | /// a failure occurs. |
| | | 763 | | /// </remarks> |
| | | 764 | | public new virtual Response<DataLakeFileClient> Rename( |
| | | 765 | | string destinationPath, |
| | | 766 | | string destinationFileSystem = default, |
| | | 767 | | DataLakeRequestConditions sourceConditions = default, |
| | | 768 | | DataLakeRequestConditions destinationConditions = default, |
| | | 769 | | CancellationToken cancellationToken = default) |
| | | 770 | | { |
| | 2 | 771 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Rename)}"); |
| | | 772 | | |
| | | 773 | | try |
| | | 774 | | { |
| | 2 | 775 | | scope.Start(); |
| | | 776 | | |
| | 2 | 777 | | Response<DataLakePathClient> response = base.Rename( |
| | 2 | 778 | | destinationFileSystem, |
| | 2 | 779 | | destinationPath, |
| | 2 | 780 | | sourceConditions, |
| | 2 | 781 | | destinationConditions, |
| | 2 | 782 | | cancellationToken); |
| | | 783 | | |
| | 0 | 784 | | return Response.FromValue( |
| | 0 | 785 | | new DataLakeFileClient(response.Value.DfsUri, response.Value.Pipeline, response.Value.Version, respo |
| | 0 | 786 | | response.GetRawResponse()); |
| | | 787 | | } |
| | 2 | 788 | | catch (Exception ex) |
| | | 789 | | { |
| | 2 | 790 | | scope.Failed(ex); |
| | 2 | 791 | | throw; |
| | | 792 | | } |
| | | 793 | | finally |
| | | 794 | | { |
| | 2 | 795 | | scope.Dispose(); |
| | 2 | 796 | | } |
| | 0 | 797 | | } |
| | | 798 | | |
| | | 799 | | /// <summary> |
| | | 800 | | /// The <see cref="RenameAsync"/> operation renames a file or directory. |
| | | 801 | | /// |
| | | 802 | | /// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path |
| | | 803 | | /// </summary> |
| | | 804 | | /// <param name="destinationPath"> |
| | | 805 | | /// The destination path to rename the path to. |
| | | 806 | | /// </param> |
| | | 807 | | /// <param name="destinationFileSystem"> |
| | | 808 | | /// Optional destination file system. If null, path will be renamed within the |
| | | 809 | | /// current file system. |
| | | 810 | | /// </param> |
| | | 811 | | /// <param name="destinationConditions"> |
| | | 812 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 813 | | /// conditions on the creation of this file or directory. |
| | | 814 | | /// </param> |
| | | 815 | | /// <param name="sourceConditions"> |
| | | 816 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 817 | | /// conditions on the source on the creation of this file or directory. |
| | | 818 | | /// </param> |
| | | 819 | | /// <param name="cancellationToken"> |
| | | 820 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 821 | | /// notifications that the operation should be cancelled. |
| | | 822 | | /// </param> |
| | | 823 | | /// <returns> |
| | | 824 | | /// A <see cref="Response{DataLakeFileClient}"/> describing the |
| | | 825 | | /// newly created file. |
| | | 826 | | /// </returns> |
| | | 827 | | /// <remarks> |
| | | 828 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 829 | | /// a failure occurs. |
| | | 830 | | /// </remarks> |
| | | 831 | | public new virtual async Task<Response<DataLakeFileClient>> RenameAsync( |
| | | 832 | | string destinationPath, |
| | | 833 | | string destinationFileSystem = default, |
| | | 834 | | DataLakeRequestConditions sourceConditions = default, |
| | | 835 | | DataLakeRequestConditions destinationConditions = default, |
| | | 836 | | CancellationToken cancellationToken = default) |
| | | 837 | | { |
| | 98 | 838 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Rename)}"); |
| | | 839 | | |
| | | 840 | | try |
| | | 841 | | { |
| | 98 | 842 | | scope.Start(); |
| | | 843 | | |
| | 98 | 844 | | Response<DataLakePathClient> response = await base.RenameAsync( |
| | 98 | 845 | | destinationFileSystem, |
| | 98 | 846 | | destinationPath, |
| | 98 | 847 | | sourceConditions, |
| | 98 | 848 | | destinationConditions, |
| | 98 | 849 | | cancellationToken) |
| | 98 | 850 | | .ConfigureAwait(false); |
| | | 851 | | |
| | 56 | 852 | | return Response.FromValue( |
| | 56 | 853 | | new DataLakeFileClient(response.Value.DfsUri, response.Value.Pipeline, response.Value.Version, respo |
| | 56 | 854 | | response.GetRawResponse()); |
| | | 855 | | } |
| | 42 | 856 | | catch (Exception ex) |
| | | 857 | | { |
| | 42 | 858 | | scope.Failed(ex); |
| | 42 | 859 | | throw; |
| | | 860 | | } |
| | | 861 | | finally |
| | | 862 | | { |
| | 98 | 863 | | scope.Dispose(); |
| | | 864 | | } |
| | 56 | 865 | | } |
| | | 866 | | #endregion Rename |
| | | 867 | | |
| | | 868 | | #region Get Access Control |
| | | 869 | | /// <summary> |
| | | 870 | | /// The <see cref="GetAccessControl"/> operation returns the |
| | | 871 | | /// access control data for a path. |
| | | 872 | | /// |
| | | 873 | | /// For more information, see |
| | | 874 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties" |
| | | 875 | | /// Get Properties</see>. |
| | | 876 | | /// </summary> |
| | | 877 | | /// <param name="userPrincipalName"> |
| | | 878 | | /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true", |
| | | 879 | | /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response |
| | | 880 | | /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names. |
| | | 881 | | /// If "false", the values will be returned as Azure Active Directory Object IDs.The default |
| | | 882 | | /// value is false. Note that group and application Object IDs are not translated because they |
| | | 883 | | /// do not have unique friendly names. |
| | | 884 | | /// </param> |
| | | 885 | | /// <param name="conditions"> |
| | | 886 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 887 | | /// conditions on getting the path's access control. |
| | | 888 | | /// </param> |
| | | 889 | | /// <param name="cancellationToken"> |
| | | 890 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 891 | | /// notifications that the operation should be cancelled. |
| | | 892 | | /// </param> |
| | | 893 | | /// <returns> |
| | | 894 | | /// A <see cref="Response{PathAccessControl}"/> describing the |
| | | 895 | | /// path's access control. |
| | | 896 | | /// </returns> |
| | | 897 | | /// <remarks> |
| | | 898 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 899 | | /// a failure occurs. |
| | | 900 | | /// </remarks> |
| | | 901 | | public override Response<PathAccessControl> GetAccessControl( |
| | | 902 | | bool? userPrincipalName = default, |
| | | 903 | | DataLakeRequestConditions conditions = default, |
| | | 904 | | CancellationToken cancellationToken = default) |
| | | 905 | | { |
| | 18 | 906 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(GetAccessContro |
| | | 907 | | |
| | | 908 | | try |
| | | 909 | | { |
| | 18 | 910 | | scope.Start(); |
| | | 911 | | |
| | 18 | 912 | | return base.GetAccessControl( |
| | 18 | 913 | | userPrincipalName, |
| | 18 | 914 | | conditions, |
| | 18 | 915 | | cancellationToken); |
| | | 916 | | } |
| | 2 | 917 | | catch (Exception ex) |
| | | 918 | | { |
| | 2 | 919 | | scope.Failed(ex); |
| | 2 | 920 | | throw; |
| | | 921 | | } |
| | | 922 | | finally |
| | | 923 | | { |
| | 18 | 924 | | scope.Dispose(); |
| | 18 | 925 | | } |
| | 16 | 926 | | } |
| | | 927 | | |
| | | 928 | | /// <summary> |
| | | 929 | | /// The <see cref="GetAccessControlAsync"/> operation returns the |
| | | 930 | | /// access control data for a path. |
| | | 931 | | /// |
| | | 932 | | /// For more information, see |
| | | 933 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/getproperties" |
| | | 934 | | /// Get Properties</see>. |
| | | 935 | | /// </summary> |
| | | 936 | | /// <param name="userPrincipalName"> |
| | | 937 | | /// Optional.Valid only when Hierarchical Namespace is enabled for the account.If "true", |
| | | 938 | | /// the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response |
| | | 939 | | /// headers will be transformed from Azure Active Directory Object IDs to User Principal Names. |
| | | 940 | | /// If "false", the values will be returned as Azure Active Directory Object IDs.The default |
| | | 941 | | /// value is false. Note that group and application Object IDs are not translated because they |
| | | 942 | | /// do not have unique friendly names. |
| | | 943 | | /// </param> |
| | | 944 | | /// <param name="conditions"> |
| | | 945 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 946 | | /// conditions on getting the path's access control. |
| | | 947 | | /// </param> |
| | | 948 | | /// <param name="cancellationToken"> |
| | | 949 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 950 | | /// notifications that the operation should be cancelled. |
| | | 951 | | /// </param> |
| | | 952 | | /// <returns> |
| | | 953 | | /// A <see cref="Response{PathAccessControl}"/> describing the |
| | | 954 | | /// path's access control. |
| | | 955 | | /// </returns> |
| | | 956 | | /// <remarks> |
| | | 957 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 958 | | /// a failure occurs. |
| | | 959 | | /// </remarks> |
| | | 960 | | public override async Task<Response<PathAccessControl>> GetAccessControlAsync( |
| | | 961 | | bool? userPrincipalName = default, |
| | | 962 | | DataLakeRequestConditions conditions = default, |
| | | 963 | | CancellationToken cancellationToken = default) |
| | | 964 | | { |
| | 54 | 965 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(GetAccessContro |
| | | 966 | | |
| | | 967 | | try |
| | | 968 | | { |
| | 54 | 969 | | scope.Start(); |
| | | 970 | | |
| | 54 | 971 | | return await base.GetAccessControlAsync( |
| | 54 | 972 | | userPrincipalName, |
| | 54 | 973 | | conditions, |
| | 54 | 974 | | cancellationToken) |
| | 54 | 975 | | .ConfigureAwait(false); |
| | | 976 | | } |
| | 2 | 977 | | catch (Exception ex) |
| | | 978 | | { |
| | 2 | 979 | | scope.Failed(ex); |
| | 2 | 980 | | throw; |
| | | 981 | | } |
| | | 982 | | finally |
| | | 983 | | { |
| | 54 | 984 | | scope.Dispose(); |
| | | 985 | | } |
| | 52 | 986 | | } |
| | | 987 | | #endregion Get Access Control |
| | | 988 | | |
| | | 989 | | #region Set Access Control |
| | | 990 | | /// <summary> |
| | | 991 | | /// The <see cref="SetAccessControlList"/> operation sets the |
| | | 992 | | /// Access Control on a path |
| | | 993 | | /// |
| | | 994 | | /// For more information, see |
| | | 995 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 996 | | /// Update Path</see>. |
| | | 997 | | /// </summary> |
| | | 998 | | /// <param name="accessControlList"> |
| | | 999 | | /// The POSIX access control list for the file or directory. |
| | | 1000 | | /// </param> |
| | | 1001 | | /// <param name="owner"> |
| | | 1002 | | /// The owner of the file or directory. |
| | | 1003 | | /// </param> |
| | | 1004 | | /// <param name="group"> |
| | | 1005 | | /// The owning group of the file or directory. |
| | | 1006 | | /// </param> |
| | | 1007 | | /// <param name="conditions"> |
| | | 1008 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1009 | | /// setting the the path's access control. |
| | | 1010 | | /// </param> |
| | | 1011 | | /// <param name="cancellationToken"> |
| | | 1012 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1013 | | /// notifications that the operation should be cancelled. |
| | | 1014 | | /// </param> |
| | | 1015 | | /// <returns> |
| | | 1016 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1017 | | /// path. |
| | | 1018 | | /// </returns> |
| | | 1019 | | /// <remarks> |
| | | 1020 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1021 | | /// a failure occurs. |
| | | 1022 | | /// </remarks> |
| | | 1023 | | public override Response<PathInfo> SetAccessControlList( |
| | | 1024 | | IList<PathAccessControlItem> accessControlList, |
| | | 1025 | | string owner = default, |
| | | 1026 | | string group = default, |
| | | 1027 | | DataLakeRequestConditions conditions = default, |
| | | 1028 | | CancellationToken cancellationToken = default) |
| | | 1029 | | { |
| | 0 | 1030 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetAccessContro |
| | | 1031 | | |
| | | 1032 | | try |
| | | 1033 | | { |
| | 0 | 1034 | | scope.Start(); |
| | | 1035 | | |
| | 0 | 1036 | | return base.SetAccessControlList( |
| | 0 | 1037 | | accessControlList, |
| | 0 | 1038 | | owner, |
| | 0 | 1039 | | group, |
| | 0 | 1040 | | conditions, |
| | 0 | 1041 | | cancellationToken); |
| | | 1042 | | } |
| | 0 | 1043 | | catch (Exception ex) |
| | | 1044 | | { |
| | 0 | 1045 | | scope.Failed(ex); |
| | 0 | 1046 | | throw; |
| | | 1047 | | } |
| | | 1048 | | finally |
| | | 1049 | | { |
| | 0 | 1050 | | scope.Dispose(); |
| | 0 | 1051 | | } |
| | 0 | 1052 | | } |
| | | 1053 | | |
| | | 1054 | | /// <summary> |
| | | 1055 | | /// The <see cref="SetAccessControlListAsync"/> operation sets the |
| | | 1056 | | /// Access Control on a path |
| | | 1057 | | /// |
| | | 1058 | | /// For more information, see |
| | | 1059 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1060 | | /// Update Path</see>. |
| | | 1061 | | /// </summary> |
| | | 1062 | | /// <param name="accessControlList"> |
| | | 1063 | | /// The POSIX access control list for the file or directory. |
| | | 1064 | | /// </param> |
| | | 1065 | | /// <param name="owner"> |
| | | 1066 | | /// The owner of the file or directory. |
| | | 1067 | | /// </param> |
| | | 1068 | | /// <param name="group"> |
| | | 1069 | | /// The owning group of the file or directory. |
| | | 1070 | | /// </param> |
| | | 1071 | | /// <param name="conditions"> |
| | | 1072 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1073 | | /// setting the the path's access control. |
| | | 1074 | | /// </param> |
| | | 1075 | | /// <param name="cancellationToken"> |
| | | 1076 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1077 | | /// notifications that the operation should be cancelled. |
| | | 1078 | | /// </param> |
| | | 1079 | | /// <returns> |
| | | 1080 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1081 | | /// path. |
| | | 1082 | | /// </returns> |
| | | 1083 | | /// <remarks> |
| | | 1084 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1085 | | /// a failure occurs. |
| | | 1086 | | /// </remarks> |
| | | 1087 | | public override async Task<Response<PathInfo>> SetAccessControlListAsync( |
| | | 1088 | | IList<PathAccessControlItem> accessControlList, |
| | | 1089 | | string owner = default, |
| | | 1090 | | string group = default, |
| | | 1091 | | DataLakeRequestConditions conditions = default, |
| | | 1092 | | CancellationToken cancellationToken = default) |
| | | 1093 | | { |
| | 48 | 1094 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetAccessContro |
| | | 1095 | | |
| | | 1096 | | try |
| | | 1097 | | { |
| | 48 | 1098 | | scope.Start(); |
| | | 1099 | | |
| | 48 | 1100 | | return await base.SetAccessControlListAsync( |
| | 48 | 1101 | | accessControlList, |
| | 48 | 1102 | | owner, |
| | 48 | 1103 | | group, |
| | 48 | 1104 | | conditions, |
| | 48 | 1105 | | cancellationToken) |
| | 48 | 1106 | | .ConfigureAwait(false); |
| | | 1107 | | } |
| | 20 | 1108 | | catch (Exception ex) |
| | | 1109 | | { |
| | 20 | 1110 | | scope.Failed(ex); |
| | 20 | 1111 | | throw; |
| | | 1112 | | } |
| | | 1113 | | finally |
| | | 1114 | | { |
| | 48 | 1115 | | scope.Dispose(); |
| | | 1116 | | } |
| | 28 | 1117 | | } |
| | | 1118 | | #endregion Set Access Control |
| | | 1119 | | |
| | | 1120 | | #region Set Permissions |
| | | 1121 | | /// <summary> |
| | | 1122 | | /// The <see cref="SetPermissions"/> operation sets the |
| | | 1123 | | /// file permissions on a path. |
| | | 1124 | | /// |
| | | 1125 | | /// For more information, see |
| | | 1126 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1127 | | /// Update Path</see>. |
| | | 1128 | | /// </summary> |
| | | 1129 | | /// <param name="permissions"> |
| | | 1130 | | /// The POSIX access permissions for the file owner, the file owning group, and others. |
| | | 1131 | | /// </param> |
| | | 1132 | | /// <param name="owner"> |
| | | 1133 | | /// The owner of the file or directory. |
| | | 1134 | | /// </param> |
| | | 1135 | | /// <param name="group"> |
| | | 1136 | | /// The owning group of the file or directory. |
| | | 1137 | | /// </param> |
| | | 1138 | | /// <param name="conditions"> |
| | | 1139 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1140 | | /// setting the the path's access control. |
| | | 1141 | | /// </param> |
| | | 1142 | | /// <param name="cancellationToken"> |
| | | 1143 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1144 | | /// notifications that the operation should be cancelled. |
| | | 1145 | | /// </param> |
| | | 1146 | | /// <returns> |
| | | 1147 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1148 | | /// path. |
| | | 1149 | | /// </returns> |
| | | 1150 | | /// <remarks> |
| | | 1151 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1152 | | /// a failure occurs. |
| | | 1153 | | /// </remarks> |
| | | 1154 | | public override Response<PathInfo> SetPermissions( |
| | | 1155 | | PathPermissions permissions, |
| | | 1156 | | string owner = default, |
| | | 1157 | | string group = default, |
| | | 1158 | | DataLakeRequestConditions conditions = default, |
| | | 1159 | | CancellationToken cancellationToken = default) |
| | | 1160 | | { |
| | 0 | 1161 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetPermissions) |
| | | 1162 | | |
| | | 1163 | | try |
| | | 1164 | | { |
| | 0 | 1165 | | scope.Start(); |
| | | 1166 | | |
| | 0 | 1167 | | return base.SetPermissions( |
| | 0 | 1168 | | permissions, |
| | 0 | 1169 | | owner, |
| | 0 | 1170 | | group, |
| | 0 | 1171 | | conditions, |
| | 0 | 1172 | | cancellationToken); |
| | | 1173 | | } |
| | 0 | 1174 | | catch (Exception ex) |
| | | 1175 | | { |
| | 0 | 1176 | | scope.Failed(ex); |
| | 0 | 1177 | | throw; |
| | | 1178 | | } |
| | | 1179 | | finally |
| | | 1180 | | { |
| | 0 | 1181 | | scope.Dispose(); |
| | 0 | 1182 | | } |
| | | 1183 | | |
| | 0 | 1184 | | } |
| | | 1185 | | |
| | | 1186 | | /// <summary> |
| | | 1187 | | /// The <see cref="SetPermissionsAsync"/> operation sets the |
| | | 1188 | | /// file permissions on a path. |
| | | 1189 | | /// |
| | | 1190 | | /// For more information, see |
| | | 1191 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1192 | | /// Update Path</see>. |
| | | 1193 | | /// </summary> |
| | | 1194 | | /// <param name="permissions"> |
| | | 1195 | | /// The POSIX access permissions for the file owner, the file owning group, and others. |
| | | 1196 | | /// </param> |
| | | 1197 | | /// <param name="owner"> |
| | | 1198 | | /// The owner of the file or directory. |
| | | 1199 | | /// </param> |
| | | 1200 | | /// <param name="group"> |
| | | 1201 | | /// The owning group of the file or directory. |
| | | 1202 | | /// </param> |
| | | 1203 | | /// <param name="conditions"> |
| | | 1204 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1205 | | /// setting the the path's access control. |
| | | 1206 | | /// </param> |
| | | 1207 | | /// <param name="cancellationToken"> |
| | | 1208 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1209 | | /// notifications that the operation should be cancelled. |
| | | 1210 | | /// </param> |
| | | 1211 | | /// <returns> |
| | | 1212 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1213 | | /// path. |
| | | 1214 | | /// </returns> |
| | | 1215 | | /// <remarks> |
| | | 1216 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1217 | | /// a failure occurs. |
| | | 1218 | | /// </remarks> |
| | | 1219 | | public override async Task<Response<PathInfo>> SetPermissionsAsync( |
| | | 1220 | | PathPermissions permissions, |
| | | 1221 | | string owner = default, |
| | | 1222 | | string group = default, |
| | | 1223 | | DataLakeRequestConditions conditions = default, |
| | | 1224 | | CancellationToken cancellationToken = default) |
| | | 1225 | | { |
| | 48 | 1226 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetPermissions) |
| | | 1227 | | |
| | | 1228 | | try |
| | | 1229 | | { |
| | 48 | 1230 | | scope.Start(); |
| | | 1231 | | |
| | 48 | 1232 | | return await base.SetPermissionsAsync( |
| | 48 | 1233 | | permissions, |
| | 48 | 1234 | | owner, |
| | 48 | 1235 | | group, |
| | 48 | 1236 | | conditions, |
| | 48 | 1237 | | cancellationToken) |
| | 48 | 1238 | | .ConfigureAwait(false); |
| | | 1239 | | } |
| | 20 | 1240 | | catch (Exception ex) |
| | | 1241 | | { |
| | 20 | 1242 | | scope.Failed(ex); |
| | 20 | 1243 | | throw; |
| | | 1244 | | } |
| | | 1245 | | finally |
| | | 1246 | | { |
| | 48 | 1247 | | scope.Dispose(); |
| | | 1248 | | } |
| | 28 | 1249 | | } |
| | | 1250 | | #endregion Set Permissions |
| | | 1251 | | |
| | | 1252 | | #region Get Properties |
| | | 1253 | | /// <summary> |
| | | 1254 | | /// The <see cref="GetProperties"/> operation returns all |
| | | 1255 | | /// user-defined metadata, standard HTTP properties, and system |
| | | 1256 | | /// properties for the path. It does not return the content of the |
| | | 1257 | | /// path. |
| | | 1258 | | /// |
| | | 1259 | | /// For more information, see |
| | | 1260 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties"> |
| | | 1261 | | /// Get Properties</see>. |
| | | 1262 | | /// </summary> |
| | | 1263 | | /// <param name="conditions"> |
| | | 1264 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 1265 | | /// conditions on getting the path's properties. |
| | | 1266 | | /// </param> |
| | | 1267 | | /// <param name="cancellationToken"> |
| | | 1268 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1269 | | /// notifications that the operation should be cancelled. |
| | | 1270 | | /// </param> |
| | | 1271 | | /// <returns> |
| | | 1272 | | /// A <see cref="Response{PathProperties}"/> describing the |
| | | 1273 | | /// path's properties. |
| | | 1274 | | /// </returns> |
| | | 1275 | | /// <remarks> |
| | | 1276 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1277 | | /// a failure occurs. |
| | | 1278 | | /// </remarks> |
| | | 1279 | | #pragma warning disable CS0114 // Member hides inherited member; missing override keyword |
| | | 1280 | | public virtual Response<PathProperties> GetProperties( |
| | | 1281 | | #pragma warning restore CS0114 // Member hides inherited member; missing override keyword |
| | | 1282 | | DataLakeRequestConditions conditions = default, |
| | | 1283 | | CancellationToken cancellationToken = default) |
| | | 1284 | | { |
| | 40 | 1285 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(GetProperties)} |
| | | 1286 | | |
| | | 1287 | | try |
| | | 1288 | | { |
| | 40 | 1289 | | scope.Start(); |
| | | 1290 | | |
| | 40 | 1291 | | return base.GetProperties( |
| | 40 | 1292 | | conditions, |
| | 40 | 1293 | | cancellationToken); |
| | | 1294 | | } |
| | 2 | 1295 | | catch (Exception ex) |
| | | 1296 | | { |
| | 2 | 1297 | | scope.Failed(ex); |
| | 2 | 1298 | | throw; |
| | | 1299 | | } |
| | | 1300 | | finally |
| | | 1301 | | { |
| | 40 | 1302 | | scope.Dispose(); |
| | 40 | 1303 | | } |
| | 38 | 1304 | | } |
| | | 1305 | | |
| | | 1306 | | |
| | | 1307 | | /// <summary> |
| | | 1308 | | /// The <see cref="GetPropertiesAsync"/> operation returns all |
| | | 1309 | | /// user-defined metadata, standard HTTP properties, and system |
| | | 1310 | | /// properties for the path. It does not return the content of the |
| | | 1311 | | /// path. |
| | | 1312 | | /// |
| | | 1313 | | /// For more information, see |
| | | 1314 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob-properties"> |
| | | 1315 | | /// Get Properties</see>. |
| | | 1316 | | /// </summary> |
| | | 1317 | | /// <param name="conditions"> |
| | | 1318 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 1319 | | /// conditions on getting the path's properties. |
| | | 1320 | | /// </param> |
| | | 1321 | | /// <param name="cancellationToken"> |
| | | 1322 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1323 | | /// notifications that the operation should be cancelled. |
| | | 1324 | | /// </param> |
| | | 1325 | | /// <returns> |
| | | 1326 | | /// A <see cref="Response{PathProperties}"/> describing the |
| | | 1327 | | /// paths's properties. |
| | | 1328 | | /// </returns> |
| | | 1329 | | /// <remarks> |
| | | 1330 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1331 | | /// a failure occurs. |
| | | 1332 | | /// </remarks> |
| | | 1333 | | public override async Task<Response<PathProperties>> GetPropertiesAsync( |
| | | 1334 | | DataLakeRequestConditions conditions = default, |
| | | 1335 | | CancellationToken cancellationToken = default) |
| | | 1336 | | { |
| | 312 | 1337 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(GetProperties)} |
| | | 1338 | | |
| | | 1339 | | try |
| | | 1340 | | { |
| | 312 | 1341 | | scope.Start(); |
| | | 1342 | | |
| | 312 | 1343 | | return await base.GetPropertiesAsync( |
| | 312 | 1344 | | conditions, |
| | 312 | 1345 | | cancellationToken) |
| | 312 | 1346 | | .ConfigureAwait(false); |
| | | 1347 | | } |
| | 22 | 1348 | | catch (Exception ex) |
| | | 1349 | | { |
| | 22 | 1350 | | scope.Failed(ex); |
| | 22 | 1351 | | throw; |
| | | 1352 | | } |
| | | 1353 | | finally |
| | | 1354 | | { |
| | 312 | 1355 | | scope.Dispose(); |
| | | 1356 | | } |
| | 290 | 1357 | | } |
| | | 1358 | | #endregion Get Properties |
| | | 1359 | | |
| | | 1360 | | #region Set Http Headers |
| | | 1361 | | /// <summary> |
| | | 1362 | | /// The <see cref="SetHttpHeaders"/> operation sets system |
| | | 1363 | | /// properties on the path. |
| | | 1364 | | /// |
| | | 1365 | | /// For more information, see |
| | | 1366 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties"> |
| | | 1367 | | /// Set Blob Properties</see>. |
| | | 1368 | | /// </summary> |
| | | 1369 | | /// <param name="httpHeaders"> |
| | | 1370 | | /// Optional. The standard HTTP header system properties to set. |
| | | 1371 | | /// If not specified, existing values will be cleared. |
| | | 1372 | | /// </param> |
| | | 1373 | | /// <param name="conditions"> |
| | | 1374 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1375 | | /// setting the paths's HTTP headers. |
| | | 1376 | | /// </param> |
| | | 1377 | | /// <param name="cancellationToken"> |
| | | 1378 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1379 | | /// notifications that the operation should be cancelled. |
| | | 1380 | | /// </param> |
| | | 1381 | | /// <returns> |
| | | 1382 | | /// A <see cref="Response{httpHeaders}"/> describing the updated |
| | | 1383 | | /// path. |
| | | 1384 | | /// </returns> |
| | | 1385 | | /// <remarks> |
| | | 1386 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1387 | | /// a failure occurs. |
| | | 1388 | | /// </remarks> |
| | | 1389 | | public override Response<PathInfo> SetHttpHeaders( |
| | | 1390 | | PathHttpHeaders httpHeaders = default, |
| | | 1391 | | DataLakeRequestConditions conditions = default, |
| | | 1392 | | CancellationToken cancellationToken = default) |
| | | 1393 | | { |
| | 2 | 1394 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetHttpHeaders) |
| | | 1395 | | |
| | | 1396 | | try |
| | | 1397 | | { |
| | 2 | 1398 | | scope.Start(); |
| | | 1399 | | |
| | 2 | 1400 | | return base.SetHttpHeaders( |
| | 2 | 1401 | | httpHeaders, |
| | 2 | 1402 | | conditions, |
| | 2 | 1403 | | cancellationToken); |
| | | 1404 | | } |
| | 2 | 1405 | | catch (Exception ex) |
| | | 1406 | | { |
| | 2 | 1407 | | scope.Failed(ex); |
| | 2 | 1408 | | throw; |
| | | 1409 | | } |
| | | 1410 | | finally |
| | | 1411 | | { |
| | 2 | 1412 | | scope.Dispose(); |
| | 2 | 1413 | | } |
| | 0 | 1414 | | } |
| | | 1415 | | |
| | | 1416 | | /// <summary> |
| | | 1417 | | /// The <see cref="SetHttpHeadersAsync"/> operation sets system |
| | | 1418 | | /// properties on the PATH. |
| | | 1419 | | /// |
| | | 1420 | | /// For more information, see |
| | | 1421 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-properties"> |
| | | 1422 | | /// Set Blob Properties</see>. |
| | | 1423 | | /// </summary> |
| | | 1424 | | /// <param name="httpHeaders"> |
| | | 1425 | | /// Optional. The standard HTTP header system properties to set. |
| | | 1426 | | /// If not specified, existing values will be cleared. |
| | | 1427 | | /// </param> |
| | | 1428 | | /// <param name="conditions"> |
| | | 1429 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1430 | | /// setting the path's HTTP headers. |
| | | 1431 | | /// </param> |
| | | 1432 | | /// <param name="cancellationToken"> |
| | | 1433 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1434 | | /// notifications that the operation should be cancelled. |
| | | 1435 | | /// </param> |
| | | 1436 | | /// <returns> |
| | | 1437 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1438 | | /// path. |
| | | 1439 | | /// </returns> |
| | | 1440 | | /// <remarks> |
| | | 1441 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1442 | | /// a failure occurs. |
| | | 1443 | | /// </remarks> |
| | | 1444 | | public override async Task<Response<PathInfo>> SetHttpHeadersAsync( |
| | | 1445 | | PathHttpHeaders httpHeaders = default, |
| | | 1446 | | DataLakeRequestConditions conditions = default, |
| | | 1447 | | CancellationToken cancellationToken = default) |
| | | 1448 | | { |
| | 50 | 1449 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetHttpHeaders) |
| | | 1450 | | |
| | | 1451 | | try |
| | | 1452 | | { |
| | 50 | 1453 | | scope.Start(); |
| | | 1454 | | |
| | 50 | 1455 | | return await base.SetHttpHeadersAsync( |
| | 50 | 1456 | | httpHeaders, |
| | 50 | 1457 | | conditions, |
| | 50 | 1458 | | cancellationToken) |
| | 50 | 1459 | | .ConfigureAwait(false); |
| | | 1460 | | } |
| | 22 | 1461 | | catch (Exception ex) |
| | | 1462 | | { |
| | 22 | 1463 | | scope.Failed(ex); |
| | 22 | 1464 | | throw; |
| | | 1465 | | } |
| | | 1466 | | finally |
| | | 1467 | | { |
| | 50 | 1468 | | scope.Dispose(); |
| | | 1469 | | } |
| | 28 | 1470 | | } |
| | | 1471 | | #endregion Set Http Headers |
| | | 1472 | | |
| | | 1473 | | #region Set Metadata |
| | | 1474 | | /// <summary> |
| | | 1475 | | /// The <see cref="SetMetadata"/> operation sets user-defined |
| | | 1476 | | /// metadata for the specified path as one or more name-value pairs. |
| | | 1477 | | /// |
| | | 1478 | | /// For more information, see |
| | | 1479 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata"> |
| | | 1480 | | /// Set Metadata</see>. |
| | | 1481 | | /// </summary> |
| | | 1482 | | /// <param name="metadata"> |
| | | 1483 | | /// Custom metadata to set for this path. |
| | | 1484 | | /// </param> |
| | | 1485 | | /// <param name="conditions"> |
| | | 1486 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1487 | | /// setting the path's metadata. |
| | | 1488 | | /// </param> |
| | | 1489 | | /// <param name="cancellationToken"> |
| | | 1490 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1491 | | /// notifications that the operation should be cancelled. |
| | | 1492 | | /// </param> |
| | | 1493 | | /// <returns> |
| | | 1494 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1495 | | /// path. |
| | | 1496 | | /// </returns> |
| | | 1497 | | /// <remarks> |
| | | 1498 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1499 | | /// a failure occurs. |
| | | 1500 | | /// </remarks> |
| | | 1501 | | public override Response<PathInfo> SetMetadata( |
| | | 1502 | | Metadata metadata, |
| | | 1503 | | DataLakeRequestConditions conditions = default, |
| | | 1504 | | CancellationToken cancellationToken = default) |
| | | 1505 | | { |
| | 2 | 1506 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetMetadata)}") |
| | | 1507 | | |
| | | 1508 | | try |
| | | 1509 | | { |
| | 2 | 1510 | | scope.Start(); |
| | | 1511 | | |
| | 2 | 1512 | | return base.SetMetadata( |
| | 2 | 1513 | | metadata, |
| | 2 | 1514 | | conditions, |
| | 2 | 1515 | | cancellationToken); |
| | | 1516 | | } |
| | 2 | 1517 | | catch (Exception ex) |
| | | 1518 | | { |
| | 2 | 1519 | | scope.Failed(ex); |
| | 2 | 1520 | | throw; |
| | | 1521 | | } |
| | | 1522 | | finally |
| | | 1523 | | { |
| | 2 | 1524 | | scope.Dispose(); |
| | 2 | 1525 | | } |
| | 0 | 1526 | | } |
| | | 1527 | | |
| | | 1528 | | /// <summary> |
| | | 1529 | | /// The <see cref="SetMetadataAsync"/> operation sets user-defined |
| | | 1530 | | /// metadata for the specified path as one or more name-value pairs. |
| | | 1531 | | /// |
| | | 1532 | | /// For more information, see |
| | | 1533 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata"> |
| | | 1534 | | /// Set Metadata</see>. |
| | | 1535 | | /// </summary> |
| | | 1536 | | /// <param name="metadata"> |
| | | 1537 | | /// Custom metadata to set for this path. |
| | | 1538 | | /// </param> |
| | | 1539 | | /// <param name="conditions"> |
| | | 1540 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 1541 | | /// setting the path's metadata. |
| | | 1542 | | /// </param> |
| | | 1543 | | /// <param name="cancellationToken"> |
| | | 1544 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1545 | | /// notifications that the operation should be cancelled. |
| | | 1546 | | /// </param> |
| | | 1547 | | /// <returns> |
| | | 1548 | | /// A <see cref="Response{PathInfo}"/> describing the updated |
| | | 1549 | | /// path. |
| | | 1550 | | /// </returns> |
| | | 1551 | | /// <remarks> |
| | | 1552 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1553 | | /// a failure occurs. |
| | | 1554 | | /// </remarks> |
| | | 1555 | | public override async Task<Response<PathInfo>> SetMetadataAsync( |
| | | 1556 | | Metadata metadata, |
| | | 1557 | | DataLakeRequestConditions conditions = default, |
| | | 1558 | | CancellationToken cancellationToken = default) |
| | | 1559 | | { |
| | 50 | 1560 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(SetMetadata)}") |
| | | 1561 | | |
| | | 1562 | | try |
| | | 1563 | | { |
| | 50 | 1564 | | scope.Start(); |
| | | 1565 | | |
| | 50 | 1566 | | return await base.SetMetadataAsync( |
| | 50 | 1567 | | metadata, |
| | 50 | 1568 | | conditions, |
| | 50 | 1569 | | cancellationToken) |
| | 50 | 1570 | | .ConfigureAwait(false); |
| | | 1571 | | } |
| | 22 | 1572 | | catch (Exception ex) |
| | | 1573 | | { |
| | 22 | 1574 | | scope.Failed(ex); |
| | 22 | 1575 | | throw; |
| | | 1576 | | } |
| | | 1577 | | finally |
| | | 1578 | | { |
| | 50 | 1579 | | scope.Dispose(); |
| | | 1580 | | } |
| | 28 | 1581 | | } |
| | | 1582 | | #endregion Set Metadata |
| | | 1583 | | |
| | | 1584 | | #region Append Data |
| | | 1585 | | /// <summary> |
| | | 1586 | | /// The <see cref="Append"/> operation uploads data to be appended to a file. |
| | | 1587 | | /// Data can only be appended to a file. |
| | | 1588 | | /// To apply perviously uploaded data to a file, call Flush Data. |
| | | 1589 | | /// Append is currently limited to 4000 MB per request. To upload large files all at once, consider using <see |
| | | 1590 | | /// |
| | | 1591 | | /// For more information, see |
| | | 1592 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1593 | | /// Update Path</see>. |
| | | 1594 | | /// </summary> |
| | | 1595 | | /// <param name="content"> |
| | | 1596 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 1597 | | /// </param> |
| | | 1598 | | /// <param name="offset"> |
| | | 1599 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 1600 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 1601 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 1602 | | /// To flush, the previously uploaded data must be contiguous, the position parameter must be specified and equa |
| | | 1603 | | /// of the file after all data has been written, and there must not be a request entity body included with the r |
| | | 1604 | | /// </param> |
| | | 1605 | | /// <param name="contentHash"> |
| | | 1606 | | /// This hash is used to verify the integrity of the request content during transport. When this header is speci |
| | | 1607 | | /// the storage service compares the hash of the content that has arrived with this header value. If the two has |
| | | 1608 | | /// the operation will fail with error code 400 (Bad Request). Note that this MD5 hash is not stored with the fi |
| | | 1609 | | /// associated with the request content, and not with the stored content of the file itself. |
| | | 1610 | | /// </param> |
| | | 1611 | | /// <param name="leaseId"> |
| | | 1612 | | /// Optional lease id. |
| | | 1613 | | /// </param> |
| | | 1614 | | /// <param name="progressHandler"> |
| | | 1615 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 1616 | | /// progress updates about data transfers. |
| | | 1617 | | /// </param> |
| | | 1618 | | /// <param name="cancellationToken"> |
| | | 1619 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1620 | | /// notifications that the operation should be cancelled. |
| | | 1621 | | /// </param> |
| | | 1622 | | /// <returns> |
| | | 1623 | | /// A <see cref="Response"/> describing the state |
| | | 1624 | | /// of the updated file. |
| | | 1625 | | /// </returns> |
| | | 1626 | | /// <remarks> |
| | | 1627 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1628 | | /// a failure occurs. |
| | | 1629 | | /// </remarks> |
| | | 1630 | | public virtual Response Append( |
| | | 1631 | | Stream content, |
| | | 1632 | | long offset, |
| | | 1633 | | byte[] contentHash = default, |
| | | 1634 | | string leaseId = default, |
| | | 1635 | | IProgress<long> progressHandler = default, |
| | | 1636 | | CancellationToken cancellationToken = default) |
| | | 1637 | | { |
| | 56 | 1638 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Append)}"); |
| | | 1639 | | |
| | | 1640 | | try |
| | | 1641 | | { |
| | 56 | 1642 | | scope.Start(); |
| | | 1643 | | |
| | 56 | 1644 | | return AppendInternal( |
| | 56 | 1645 | | content, |
| | 56 | 1646 | | offset, |
| | 56 | 1647 | | contentHash, |
| | 56 | 1648 | | leaseId, |
| | 56 | 1649 | | progressHandler, |
| | 56 | 1650 | | async: false, |
| | 56 | 1651 | | cancellationToken) |
| | 56 | 1652 | | .EnsureCompleted(); |
| | | 1653 | | } |
| | 8 | 1654 | | catch (Exception ex) |
| | | 1655 | | { |
| | 8 | 1656 | | scope.Failed(ex); |
| | 8 | 1657 | | throw; |
| | | 1658 | | } |
| | | 1659 | | finally |
| | | 1660 | | { |
| | 56 | 1661 | | scope.Dispose(); |
| | 56 | 1662 | | } |
| | 48 | 1663 | | } |
| | | 1664 | | |
| | | 1665 | | /// <summary> |
| | | 1666 | | /// The <see cref="AppendAsync"/> operation uploads data to be appended to a file. Data can only be appended to |
| | | 1667 | | /// To apply perviously uploaded data to a file, call Flush Data. |
| | | 1668 | | /// Append is currently limited to 4000 MB per request. To upload large files all at once, consider using <see |
| | | 1669 | | /// |
| | | 1670 | | /// For more information, see |
| | | 1671 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1672 | | /// Update Path</see>. |
| | | 1673 | | /// </summary> |
| | | 1674 | | /// <param name="content"> |
| | | 1675 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 1676 | | /// </param> |
| | | 1677 | | /// <param name="offset"> |
| | | 1678 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 1679 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 1680 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 1681 | | /// To flush, the previously uploaded data must be contiguous, the position parameter must be specified and equa |
| | | 1682 | | /// of the file after all data has been written, and there must not be a request entity body included with the r |
| | | 1683 | | /// </param> |
| | | 1684 | | /// <param name="contentHash"> |
| | | 1685 | | /// This hash is used to verify the integrity of the request content during transport. When this header is speci |
| | | 1686 | | /// the storage service compares the hash of the content that has arrived with this header value. If the two has |
| | | 1687 | | /// the operation will fail with error code 400 (Bad Request). Note that this MD5 hash is not stored with the fi |
| | | 1688 | | /// associated with the request content, and not with the stored content of the file itself. |
| | | 1689 | | /// </param> |
| | | 1690 | | /// <param name="leaseId"> |
| | | 1691 | | /// Optional lease id. |
| | | 1692 | | /// </param> |
| | | 1693 | | /// <param name="progressHandler"> |
| | | 1694 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 1695 | | /// progress updates about data transfers. |
| | | 1696 | | /// </param> |
| | | 1697 | | /// <param name="cancellationToken"> |
| | | 1698 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1699 | | /// notifications that the operation should be cancelled. |
| | | 1700 | | /// </param> |
| | | 1701 | | /// <returns> |
| | | 1702 | | /// A <see cref="Response"/> describing the state |
| | | 1703 | | /// of the updated file. |
| | | 1704 | | /// </returns> |
| | | 1705 | | /// <remarks> |
| | | 1706 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1707 | | /// a failure occurs. |
| | | 1708 | | /// </remarks> |
| | | 1709 | | public virtual async Task<Response> AppendAsync( |
| | | 1710 | | Stream content, |
| | | 1711 | | long offset, |
| | | 1712 | | byte[] contentHash = default, |
| | | 1713 | | string leaseId = default, |
| | | 1714 | | IProgress<long> progressHandler = default, |
| | | 1715 | | CancellationToken cancellationToken = default) |
| | | 1716 | | { |
| | 120 | 1717 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Append)}"); |
| | | 1718 | | |
| | | 1719 | | try |
| | | 1720 | | { |
| | 120 | 1721 | | scope.Start(); |
| | | 1722 | | |
| | 120 | 1723 | | return await AppendInternal( |
| | 120 | 1724 | | content, |
| | 120 | 1725 | | offset, |
| | 120 | 1726 | | contentHash, |
| | 120 | 1727 | | leaseId, |
| | 120 | 1728 | | progressHandler, |
| | 120 | 1729 | | async: true, |
| | 120 | 1730 | | cancellationToken) |
| | 120 | 1731 | | .ConfigureAwait(false); |
| | | 1732 | | } |
| | 8 | 1733 | | catch (Exception ex) |
| | | 1734 | | { |
| | 8 | 1735 | | scope.Failed(ex); |
| | 8 | 1736 | | throw; |
| | | 1737 | | } |
| | | 1738 | | finally |
| | | 1739 | | { |
| | 120 | 1740 | | scope.Dispose(); |
| | | 1741 | | } |
| | 112 | 1742 | | } |
| | | 1743 | | |
| | | 1744 | | /// <summary> |
| | | 1745 | | /// The <see cref="AppendInternal"/> operation uploads data to be appended to a file. Data can only be appended |
| | | 1746 | | /// To apply perviously uploaded data to a file, call Flush Data. |
| | | 1747 | | /// |
| | | 1748 | | /// For more information, see |
| | | 1749 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update"> |
| | | 1750 | | /// Update Path</see>. |
| | | 1751 | | /// </summary> |
| | | 1752 | | /// <param name="content"> |
| | | 1753 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 1754 | | /// </param> |
| | | 1755 | | /// <param name="offset"> |
| | | 1756 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 1757 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 1758 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 1759 | | /// To flush, the previously uploaded data must be contiguous, the position parameter must be specified and equa |
| | | 1760 | | /// of the file after all data has been written, and there must not be a request entity body included with the r |
| | | 1761 | | /// </param> |
| | | 1762 | | /// <param name="contentHash"> |
| | | 1763 | | /// This hash is used to verify the integrity of the request content during transport. When this header is speci |
| | | 1764 | | /// the storage service compares the hash of the content that has arrived with this header value. If the two has |
| | | 1765 | | /// the operation will fail with error code 400 (Bad Request). Note that this MD5 hash is not stored with the fi |
| | | 1766 | | /// associated with the request content, and not with the stored content of the file itself. |
| | | 1767 | | /// </param> |
| | | 1768 | | /// <param name="leaseId"> |
| | | 1769 | | /// Optional lease id. |
| | | 1770 | | /// </param> |
| | | 1771 | | /// <param name="progressHandler"> |
| | | 1772 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 1773 | | /// progress updates about data transfers. |
| | | 1774 | | /// </param> |
| | | 1775 | | /// <param name="async"> |
| | | 1776 | | /// Whether to invoke the operation asynchronously. |
| | | 1777 | | /// </param> |
| | | 1778 | | /// <param name="cancellationToken"> |
| | | 1779 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1780 | | /// notifications that the operation should be cancelled. |
| | | 1781 | | /// </param> |
| | | 1782 | | /// <returns> |
| | | 1783 | | /// A <see cref="Response"/> describing the state |
| | | 1784 | | /// of the updated file. |
| | | 1785 | | /// </returns> |
| | | 1786 | | /// <remarks> |
| | | 1787 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1788 | | /// a failure occurs. |
| | | 1789 | | /// </remarks> |
| | | 1790 | | internal virtual async Task<Response> AppendInternal( |
| | | 1791 | | Stream content, |
| | | 1792 | | long? offset, |
| | | 1793 | | byte[] contentHash, |
| | | 1794 | | string leaseId, |
| | | 1795 | | IProgress<long> progressHandler, |
| | | 1796 | | bool async, |
| | | 1797 | | CancellationToken cancellationToken) |
| | | 1798 | | { |
| | 336 | 1799 | | using (Pipeline.BeginLoggingScope(nameof(DataLakeFileClient))) |
| | | 1800 | | { |
| | 336 | 1801 | | content = content?.WithNoDispose().WithProgress(progressHandler); |
| | | 1802 | | Pipeline.LogMethodEnter( |
| | | 1803 | | nameof(DataLakeFileClient), |
| | | 1804 | | message: |
| | | 1805 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 1806 | | $"{nameof(offset)}: {offset}\n" + |
| | | 1807 | | $"{nameof(leaseId)}: {leaseId}\n"); |
| | | 1808 | | try |
| | | 1809 | | { |
| | 336 | 1810 | | Response<PathAppendDataResult> response = await DataLakeRestClient.Path.AppendDataAsync( |
| | 336 | 1811 | | clientDiagnostics: ClientDiagnostics, |
| | 336 | 1812 | | pipeline: Pipeline, |
| | 336 | 1813 | | resourceUri: DfsUri, |
| | 336 | 1814 | | body: content, |
| | 336 | 1815 | | version: Version.ToVersionString(), |
| | 336 | 1816 | | position: offset, |
| | 336 | 1817 | | contentLength: content?.Length ?? 0, |
| | 336 | 1818 | | transactionalContentHash: contentHash, |
| | 336 | 1819 | | leaseId: leaseId, |
| | 336 | 1820 | | async: async, |
| | 336 | 1821 | | cancellationToken: cancellationToken) |
| | 336 | 1822 | | .ConfigureAwait(false); |
| | | 1823 | | |
| | 320 | 1824 | | return response.GetRawResponse(); |
| | | 1825 | | } |
| | 16 | 1826 | | catch (Exception ex) |
| | | 1827 | | { |
| | | 1828 | | Pipeline.LogException(ex); |
| | 16 | 1829 | | throw; |
| | | 1830 | | } |
| | | 1831 | | finally |
| | | 1832 | | { |
| | | 1833 | | Pipeline.LogMethodExit(nameof(DataLakeFileClient)); |
| | | 1834 | | } |
| | | 1835 | | } |
| | 320 | 1836 | | } |
| | | 1837 | | #endregion Append Data |
| | | 1838 | | |
| | | 1839 | | #region Flush Data |
| | | 1840 | | /// <summary> |
| | | 1841 | | /// The <see cref="Flush"/> operation flushes (writes) previously |
| | | 1842 | | /// appended data to a file. |
| | | 1843 | | /// </summary> |
| | | 1844 | | /// <param name="position"> |
| | | 1845 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 1846 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 1847 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 1848 | | /// to the file. To flush, the previously uploaded data must be contiguous, the position parameter must be speci |
| | | 1849 | | /// equal to the length of the file after all data has been written, and there must not be a request entity body |
| | | 1850 | | /// with the request. |
| | | 1851 | | /// </param> |
| | | 1852 | | /// <param name="retainUncommittedData"> |
| | | 1853 | | /// If "true", uncommitted data is retained after the flush operation completes; otherwise, the uncommitted data |
| | | 1854 | | /// after the flush operation. The default is false. Data at offsets less than the specified position are writte |
| | | 1855 | | /// file when flush succeeds, but this optional parameter allows data after the flush position to be retained fo |
| | | 1856 | | /// flush operation. |
| | | 1857 | | /// </param> |
| | | 1858 | | /// <param name="close"> |
| | | 1859 | | /// Azure Storage Events allow applications to receive notifications when files change. When Azure Storage Event |
| | | 1860 | | /// a file changed event is raised. This event has a property indicating whether this is the final change to dis |
| | | 1861 | | /// difference between an intermediate flush to a file stream and the final close of a file stream. The close qu |
| | | 1862 | | /// is valid only when the action is "flush" and change notifications are enabled. If the value of close is "tru |
| | | 1863 | | /// flush operation completes successfully, the service raises a file change notification with a property indica |
| | | 1864 | | /// this is the final update (the file stream has been closed). If "false" a change notification is raised indic |
| | | 1865 | | /// file has changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to ind |
| | | 1866 | | /// the file stream has been closed." |
| | | 1867 | | /// </param> |
| | | 1868 | | /// <param name="httpHeaders"> |
| | | 1869 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 1870 | | ///</param> |
| | | 1871 | | /// <param name="conditions"> |
| | | 1872 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 1873 | | /// conditions on the flush of this file. |
| | | 1874 | | /// </param> |
| | | 1875 | | /// <param name="cancellationToken"> |
| | | 1876 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1877 | | /// notifications that the operation should be cancelled. |
| | | 1878 | | /// </param> |
| | | 1879 | | /// <returns> |
| | | 1880 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 1881 | | /// path. |
| | | 1882 | | /// </returns> |
| | | 1883 | | /// <remarks> |
| | | 1884 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1885 | | /// a failure occurs. |
| | | 1886 | | /// </remarks> |
| | | 1887 | | public virtual Response<PathInfo> Flush( |
| | | 1888 | | long position, |
| | | 1889 | | bool? retainUncommittedData = default, |
| | | 1890 | | bool? close = default, |
| | | 1891 | | PathHttpHeaders httpHeaders = default, |
| | | 1892 | | DataLakeRequestConditions conditions = default, |
| | | 1893 | | CancellationToken cancellationToken = default) |
| | | 1894 | | { |
| | 40 | 1895 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Flush)}"); |
| | | 1896 | | |
| | | 1897 | | try |
| | | 1898 | | { |
| | 40 | 1899 | | scope.Start(); |
| | | 1900 | | |
| | 40 | 1901 | | return FlushInternal( |
| | 40 | 1902 | | position, |
| | 40 | 1903 | | retainUncommittedData, |
| | 40 | 1904 | | close, |
| | 40 | 1905 | | httpHeaders, |
| | 40 | 1906 | | conditions, |
| | 40 | 1907 | | async: false, |
| | 40 | 1908 | | cancellationToken) |
| | 40 | 1909 | | .EnsureCompleted(); |
| | | 1910 | | } |
| | 12 | 1911 | | catch (Exception ex) |
| | | 1912 | | { |
| | 12 | 1913 | | scope.Failed(ex); |
| | 12 | 1914 | | throw; |
| | | 1915 | | } |
| | | 1916 | | finally |
| | | 1917 | | { |
| | 40 | 1918 | | scope.Dispose(); |
| | 40 | 1919 | | } |
| | 28 | 1920 | | } |
| | | 1921 | | |
| | | 1922 | | /// <summary> |
| | | 1923 | | /// The <see cref="FlushAsync"/> operation flushes (writes) previously |
| | | 1924 | | /// appended data to a file. |
| | | 1925 | | /// </summary> |
| | | 1926 | | /// <param name="position"> |
| | | 1927 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 1928 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 1929 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 1930 | | /// to the file. To flush, the previously uploaded data must be contiguous, the position parameter must be speci |
| | | 1931 | | /// equal to the length of the file after all data has been written, and there must not be a request entity body |
| | | 1932 | | /// with the request. |
| | | 1933 | | /// </param> |
| | | 1934 | | /// <param name="retainUncommittedData"> |
| | | 1935 | | /// If "true", uncommitted data is retained after the flush operation completes; otherwise, the uncommitted data |
| | | 1936 | | /// after the flush operation. The default is false. Data at offsets less than the specified position are writte |
| | | 1937 | | /// file when flush succeeds, but this optional parameter allows data after the flush position to be retained fo |
| | | 1938 | | /// flush operation. |
| | | 1939 | | /// </param> |
| | | 1940 | | /// <param name="close"> |
| | | 1941 | | /// Azure Storage Events allow applications to receive notifications when files change. When Azure Storage Event |
| | | 1942 | | /// a file changed event is raised. This event has a property indicating whether this is the final change to dis |
| | | 1943 | | /// difference between an intermediate flush to a file stream and the final close of a file stream. The close qu |
| | | 1944 | | /// is valid only when the action is "flush" and change notifications are enabled. If the value of close is "tru |
| | | 1945 | | /// flush operation completes successfully, the service raises a file change notification with a property indica |
| | | 1946 | | /// this is the final update (the file stream has been closed). If "false" a change notification is raised indic |
| | | 1947 | | /// file has changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to ind |
| | | 1948 | | /// the file stream has been closed." |
| | | 1949 | | /// </param> |
| | | 1950 | | /// <param name="httpHeaders"> |
| | | 1951 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 1952 | | ///</param> |
| | | 1953 | | /// <param name="conditions"> |
| | | 1954 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 1955 | | /// conditions on the flush of this file. |
| | | 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{PathInfo}"/> describing the |
| | | 1963 | | /// path. |
| | | 1964 | | /// </returns> |
| | | 1965 | | /// <remarks> |
| | | 1966 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1967 | | /// a failure occurs. |
| | | 1968 | | /// </remarks> |
| | | 1969 | | public virtual async Task<Response<PathInfo>> FlushAsync( |
| | | 1970 | | long position, |
| | | 1971 | | bool? retainUncommittedData = default, |
| | | 1972 | | bool? close = default, |
| | | 1973 | | PathHttpHeaders httpHeaders = default, |
| | | 1974 | | DataLakeRequestConditions conditions = default, |
| | | 1975 | | CancellationToken cancellationToken = default) |
| | | 1976 | | { |
| | 104 | 1977 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Flush)}"); |
| | | 1978 | | |
| | | 1979 | | try |
| | | 1980 | | { |
| | 104 | 1981 | | scope.Start(); |
| | | 1982 | | |
| | 104 | 1983 | | return await FlushInternal( |
| | 104 | 1984 | | position, |
| | 104 | 1985 | | retainUncommittedData, |
| | 104 | 1986 | | close, |
| | 104 | 1987 | | httpHeaders, |
| | 104 | 1988 | | conditions, |
| | 104 | 1989 | | async: true, |
| | 104 | 1990 | | cancellationToken) |
| | 104 | 1991 | | .ConfigureAwait(false); |
| | | 1992 | | } |
| | 12 | 1993 | | catch (Exception ex) |
| | | 1994 | | { |
| | 12 | 1995 | | scope.Failed(ex); |
| | 12 | 1996 | | throw; |
| | | 1997 | | } |
| | | 1998 | | finally |
| | | 1999 | | { |
| | 104 | 2000 | | scope.Dispose(); |
| | | 2001 | | } |
| | 92 | 2002 | | } |
| | | 2003 | | |
| | | 2004 | | /// <summary> |
| | | 2005 | | /// The <see cref="FlushInternal"/> operation flushes (writes) previously |
| | | 2006 | | /// appended data to a file. |
| | | 2007 | | /// </summary> |
| | | 2008 | | /// <param name="position"> |
| | | 2009 | | /// This parameter allows the caller to upload data in parallel and control the order in which it is appended to |
| | | 2010 | | /// It is required when uploading data to be appended to the file and when flushing previously uploaded data to |
| | | 2011 | | /// The value must be the position where the data is to be appended. Uploaded data is not immediately flushed, o |
| | | 2012 | | /// to the file. To flush, the previously uploaded data must be contiguous, the position parameter must be speci |
| | | 2013 | | /// equal to the length of the file after all data has been written, and there must not be a request entity body |
| | | 2014 | | /// with the request. |
| | | 2015 | | /// </param> |
| | | 2016 | | /// <param name="retainUncommittedData"> |
| | | 2017 | | /// If "true", uncommitted data is retained after the flush operation completes; otherwise, the uncommitted data |
| | | 2018 | | /// after the flush operation. The default is false. Data at offsets less than the specified position are writte |
| | | 2019 | | /// file when flush succeeds, but this optional parameter allows data after the flush position to be retained fo |
| | | 2020 | | /// flush operation. |
| | | 2021 | | /// </param> |
| | | 2022 | | /// <param name="close"> |
| | | 2023 | | /// Azure Storage Events allow applications to receive notifications when files change. When Azure Storage Event |
| | | 2024 | | /// a file changed event is raised. This event has a property indicating whether this is the final change to dis |
| | | 2025 | | /// difference between an intermediate flush to a file stream and the final close of a file stream. The close qu |
| | | 2026 | | /// is valid only when the action is "flush" and change notifications are enabled. If the value of close is "tru |
| | | 2027 | | /// flush operation completes successfully, the service raises a file change notification with a property indica |
| | | 2028 | | /// this is the final update (the file stream has been closed). If "false" a change notification is raised indic |
| | | 2029 | | /// file has changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to ind |
| | | 2030 | | /// the file stream has been closed." |
| | | 2031 | | /// </param> |
| | | 2032 | | /// <param name="httpHeaders"> |
| | | 2033 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2034 | | ///</param> |
| | | 2035 | | /// <param name="conditions"> |
| | | 2036 | | /// Optional <see cref="DataLakeRequestConditions"/> to add |
| | | 2037 | | /// conditions on the flush of this file. |
| | | 2038 | | /// </param> |
| | | 2039 | | /// <param name="async"> |
| | | 2040 | | /// Whether to invoke the operation asynchronously. |
| | | 2041 | | /// </param> |
| | | 2042 | | /// <param name="cancellationToken"> |
| | | 2043 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2044 | | /// notifications that the operation should be cancelled. |
| | | 2045 | | /// </param> |
| | | 2046 | | /// <returns> |
| | | 2047 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 2048 | | /// path. |
| | | 2049 | | /// </returns> |
| | | 2050 | | /// <remarks> |
| | | 2051 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2052 | | /// a failure occurs. |
| | | 2053 | | /// </remarks> |
| | | 2054 | | internal virtual async Task<Response<PathInfo>> FlushInternal( |
| | | 2055 | | long position, |
| | | 2056 | | bool? retainUncommittedData, |
| | | 2057 | | bool? close, |
| | | 2058 | | PathHttpHeaders httpHeaders, |
| | | 2059 | | DataLakeRequestConditions conditions, |
| | | 2060 | | bool async, |
| | | 2061 | | CancellationToken cancellationToken) |
| | | 2062 | | { |
| | 304 | 2063 | | using (Pipeline.BeginLoggingScope(nameof(DataLakeFileClient))) |
| | | 2064 | | { |
| | | 2065 | | Pipeline.LogMethodEnter( |
| | | 2066 | | nameof(DataLakeFileClient), |
| | | 2067 | | message: |
| | | 2068 | | $"{nameof(Uri)}: {Uri}"); |
| | | 2069 | | |
| | | 2070 | | try |
| | | 2071 | | { |
| | 304 | 2072 | | Response<PathFlushDataResult> response = await DataLakeRestClient.Path.FlushDataAsync( |
| | 304 | 2073 | | clientDiagnostics: ClientDiagnostics, |
| | 304 | 2074 | | pipeline: Pipeline, |
| | 304 | 2075 | | resourceUri: DfsUri, |
| | 304 | 2076 | | version: Version.ToVersionString(), |
| | 304 | 2077 | | position: position, |
| | 304 | 2078 | | retainUncommittedData: retainUncommittedData, |
| | 304 | 2079 | | close: close, |
| | 304 | 2080 | | contentLength: 0, |
| | 304 | 2081 | | contentHash: httpHeaders?.ContentHash, |
| | 304 | 2082 | | leaseId: conditions?.LeaseId, |
| | 304 | 2083 | | cacheControl: httpHeaders?.CacheControl, |
| | 304 | 2084 | | contentType: httpHeaders?.ContentType, |
| | 304 | 2085 | | contentDisposition: httpHeaders?.ContentDisposition, |
| | 304 | 2086 | | contentEncoding: httpHeaders?.ContentEncoding, |
| | 304 | 2087 | | contentLanguage: httpHeaders?.ContentLanguage, |
| | 304 | 2088 | | ifMatch: conditions?.IfMatch, |
| | 304 | 2089 | | ifNoneMatch: conditions?.IfNoneMatch, |
| | 304 | 2090 | | ifModifiedSince: conditions?.IfModifiedSince, |
| | 304 | 2091 | | ifUnmodifiedSince: conditions?.IfUnmodifiedSince, |
| | 304 | 2092 | | async: async, |
| | 304 | 2093 | | cancellationToken: cancellationToken) |
| | 304 | 2094 | | .ConfigureAwait(false); |
| | | 2095 | | |
| | 280 | 2096 | | return Response.FromValue( |
| | 280 | 2097 | | new PathInfo() |
| | 280 | 2098 | | { |
| | 280 | 2099 | | ETag = response.Value.ETag, |
| | 280 | 2100 | | LastModified = response.Value.LastModified |
| | 280 | 2101 | | }, |
| | 280 | 2102 | | response.GetRawResponse()); |
| | | 2103 | | } |
| | 24 | 2104 | | catch (Exception ex) |
| | | 2105 | | { |
| | | 2106 | | Pipeline.LogException(ex); |
| | 24 | 2107 | | throw; |
| | | 2108 | | } |
| | | 2109 | | finally |
| | | 2110 | | { |
| | | 2111 | | Pipeline.LogMethodExit(nameof(DataLakeFileClient)); |
| | | 2112 | | } |
| | | 2113 | | } |
| | 280 | 2114 | | } |
| | | 2115 | | #endregion |
| | | 2116 | | |
| | | 2117 | | #region Read Data |
| | | 2118 | | /// <summary> |
| | | 2119 | | /// The <see cref="Read()"/> operation downloads a file from |
| | | 2120 | | /// the service, including its metadata and properties. |
| | | 2121 | | /// |
| | | 2122 | | /// For more information, see |
| | | 2123 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2124 | | /// Get Blob</see>. |
| | | 2125 | | /// </summary> |
| | | 2126 | | /// <returns> |
| | | 2127 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2128 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2129 | | /// the blob's data. |
| | | 2130 | | /// </returns> |
| | | 2131 | | /// <remarks> |
| | | 2132 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2133 | | /// a failure occurs. |
| | | 2134 | | /// </remarks> |
| | | 2135 | | public virtual Response<FileDownloadInfo> Read() |
| | | 2136 | | { |
| | 2 | 2137 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2138 | | |
| | | 2139 | | try |
| | | 2140 | | { |
| | 2 | 2141 | | scope.Start(); |
| | | 2142 | | |
| | 2 | 2143 | | Response<Blobs.Models.BlobDownloadInfo> response = _blockBlobClient.Download(); |
| | | 2144 | | |
| | 0 | 2145 | | return Response.FromValue( |
| | 0 | 2146 | | response.Value.ToFileDownloadInfo(), |
| | 0 | 2147 | | response.GetRawResponse()); |
| | | 2148 | | } |
| | 2 | 2149 | | catch (Exception ex) |
| | | 2150 | | { |
| | 2 | 2151 | | scope.Failed(ex); |
| | 2 | 2152 | | throw; |
| | | 2153 | | } |
| | | 2154 | | finally |
| | | 2155 | | { |
| | 2 | 2156 | | scope.Dispose(); |
| | 2 | 2157 | | } |
| | 0 | 2158 | | } |
| | | 2159 | | |
| | | 2160 | | /// <summary> |
| | | 2161 | | /// The <see cref="ReadAsync()"/> operation downloads a file from |
| | | 2162 | | /// the service, including its metadata and properties. |
| | | 2163 | | /// |
| | | 2164 | | /// For more information, see |
| | | 2165 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2166 | | /// Get Blob</see>. |
| | | 2167 | | /// </summary> |
| | | 2168 | | /// <returns> |
| | | 2169 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2170 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2171 | | /// the file's data. |
| | | 2172 | | /// </returns> |
| | | 2173 | | /// <remarks> |
| | | 2174 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2175 | | /// a failure occurs. |
| | | 2176 | | /// </remarks> |
| | | 2177 | | public virtual async Task<Response<FileDownloadInfo>> ReadAsync() |
| | | 2178 | | { |
| | 6 | 2179 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2180 | | |
| | | 2181 | | try |
| | | 2182 | | { |
| | 6 | 2183 | | scope.Start(); |
| | | 2184 | | |
| | 6 | 2185 | | Response<Blobs.Models.BlobDownloadInfo> response |
| | 6 | 2186 | | = await _blockBlobClient.DownloadAsync(CancellationToken.None).ConfigureAwait(false); |
| | | 2187 | | |
| | 4 | 2188 | | return Response.FromValue( |
| | 4 | 2189 | | response.Value.ToFileDownloadInfo(), |
| | 4 | 2190 | | response.GetRawResponse()); |
| | | 2191 | | } |
| | 2 | 2192 | | catch (Exception ex) |
| | | 2193 | | { |
| | 2 | 2194 | | scope.Failed(ex); |
| | 2 | 2195 | | throw; |
| | | 2196 | | } |
| | | 2197 | | finally |
| | | 2198 | | { |
| | 6 | 2199 | | scope.Dispose(); |
| | | 2200 | | } |
| | 4 | 2201 | | } |
| | | 2202 | | |
| | | 2203 | | /// <summary> |
| | | 2204 | | /// The <see cref="Read(CancellationToken)"/> operation downloads a file from |
| | | 2205 | | /// the service, including its metadata and properties. |
| | | 2206 | | /// |
| | | 2207 | | /// For more information, see |
| | | 2208 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2209 | | /// Get Blob</see>. |
| | | 2210 | | /// </summary> |
| | | 2211 | | /// <param name="cancellationToken"> |
| | | 2212 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2213 | | /// notifications that the operation should be cancelled. |
| | | 2214 | | /// </param> |
| | | 2215 | | /// <returns> |
| | | 2216 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2217 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2218 | | /// the blob's data. |
| | | 2219 | | /// </returns> |
| | | 2220 | | /// <remarks> |
| | | 2221 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2222 | | /// a failure occurs. |
| | | 2223 | | /// </remarks> |
| | | 2224 | | public virtual Response<FileDownloadInfo> Read( |
| | | 2225 | | CancellationToken cancellationToken = default) |
| | | 2226 | | { |
| | 0 | 2227 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2228 | | |
| | | 2229 | | try |
| | | 2230 | | { |
| | 0 | 2231 | | scope.Start(); |
| | | 2232 | | |
| | 0 | 2233 | | Response<Blobs.Models.BlobDownloadInfo> response = _blockBlobClient.Download(cancellationToken); |
| | | 2234 | | |
| | 0 | 2235 | | return Response.FromValue( |
| | 0 | 2236 | | response.Value.ToFileDownloadInfo(), |
| | 0 | 2237 | | response.GetRawResponse()); |
| | | 2238 | | } |
| | 0 | 2239 | | catch (Exception ex) |
| | | 2240 | | { |
| | 0 | 2241 | | scope.Failed(ex); |
| | 0 | 2242 | | throw; |
| | | 2243 | | } |
| | | 2244 | | finally |
| | | 2245 | | { |
| | 0 | 2246 | | scope.Dispose(); |
| | 0 | 2247 | | } |
| | 0 | 2248 | | } |
| | | 2249 | | |
| | | 2250 | | /// <summary> |
| | | 2251 | | /// The <see cref="ReadAsync(CancellationToken)"/> operation downloads a file from |
| | | 2252 | | /// the service, including its metadata and properties. |
| | | 2253 | | /// |
| | | 2254 | | /// For more information, see |
| | | 2255 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2256 | | /// Get Blob</see>. |
| | | 2257 | | /// </summary> |
| | | 2258 | | /// <param name="cancellationToken"> |
| | | 2259 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2260 | | /// notifications that the operation should be cancelled. |
| | | 2261 | | /// </param> |
| | | 2262 | | /// <returns> |
| | | 2263 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2264 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2265 | | /// the file's data. |
| | | 2266 | | /// </returns> |
| | | 2267 | | /// <remarks> |
| | | 2268 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2269 | | /// a failure occurs. |
| | | 2270 | | /// </remarks> |
| | | 2271 | | public virtual async Task<Response<FileDownloadInfo>> ReadAsync( |
| | | 2272 | | CancellationToken cancellationToken = default) |
| | | 2273 | | { |
| | 0 | 2274 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2275 | | |
| | | 2276 | | try |
| | | 2277 | | { |
| | 0 | 2278 | | scope.Start(); |
| | | 2279 | | |
| | 0 | 2280 | | Response<Blobs.Models.BlobDownloadInfo> response |
| | 0 | 2281 | | = await _blockBlobClient.DownloadAsync(cancellationToken).ConfigureAwait(false); |
| | | 2282 | | |
| | 0 | 2283 | | return Response.FromValue( |
| | 0 | 2284 | | response.Value.ToFileDownloadInfo(), |
| | 0 | 2285 | | response.GetRawResponse()); |
| | | 2286 | | } |
| | 0 | 2287 | | catch (Exception ex) |
| | | 2288 | | { |
| | 0 | 2289 | | scope.Failed(ex); |
| | 0 | 2290 | | throw; |
| | | 2291 | | } |
| | | 2292 | | finally |
| | | 2293 | | { |
| | 0 | 2294 | | scope.Dispose(); |
| | | 2295 | | } |
| | 0 | 2296 | | } |
| | | 2297 | | |
| | | 2298 | | /// <summary> |
| | | 2299 | | /// The <see cref="Read(HttpRange, DataLakeRequestConditions?, Boolean, CancellationToken)"/> |
| | | 2300 | | /// operation downloads a file from the service, including its metadata |
| | | 2301 | | /// and properties. |
| | | 2302 | | /// |
| | | 2303 | | /// For more information, see |
| | | 2304 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2305 | | /// Get Blob</see>. |
| | | 2306 | | /// </summary> |
| | | 2307 | | /// <param name="range"> |
| | | 2308 | | /// If provided, only donwload the bytes of the file in the specified |
| | | 2309 | | /// range. If not provided, download the entire file. |
| | | 2310 | | /// </param> |
| | | 2311 | | /// <param name="conditions"> |
| | | 2312 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2313 | | /// donwloading this file. |
| | | 2314 | | /// </param> |
| | | 2315 | | /// <param name="rangeGetContentHash"> |
| | | 2316 | | /// When set to true and specified together with the <paramref name="range"/>, |
| | | 2317 | | /// the service returns the MD5 hash for the range, as long as the |
| | | 2318 | | /// range is less than or equal to 4 MB in size. If this value is |
| | | 2319 | | /// specified without <paramref name="range"/> or set to true when the |
| | | 2320 | | /// range exceeds 4 MB in size, a <see cref="RequestFailedException"/> |
| | | 2321 | | /// is thrown. |
| | | 2322 | | /// </param> |
| | | 2323 | | /// <param name="cancellationToken"> |
| | | 2324 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2325 | | /// notifications that the operation should be cancelled. |
| | | 2326 | | /// </param> |
| | | 2327 | | /// <returns> |
| | | 2328 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2329 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2330 | | /// the file's data. |
| | | 2331 | | /// </returns> |
| | | 2332 | | /// <remarks> |
| | | 2333 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2334 | | /// a failure occurs. |
| | | 2335 | | /// </remarks> |
| | | 2336 | | public virtual Response<FileDownloadInfo> Read( |
| | | 2337 | | HttpRange range = default, |
| | | 2338 | | DataLakeRequestConditions conditions = default, |
| | | 2339 | | bool rangeGetContentHash = default, |
| | | 2340 | | CancellationToken cancellationToken = default) |
| | | 2341 | | { |
| | 2 | 2342 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2343 | | |
| | | 2344 | | try |
| | | 2345 | | { |
| | 2 | 2346 | | scope.Start(); |
| | | 2347 | | |
| | 2 | 2348 | | Response<Blobs.Models.BlobDownloadInfo> response = _blockBlobClient.Download( |
| | 2 | 2349 | | range: range, |
| | 2 | 2350 | | conditions: conditions.ToBlobRequestConditions(), |
| | 2 | 2351 | | rangeGetContentHash: rangeGetContentHash, |
| | 2 | 2352 | | cancellationToken: cancellationToken); |
| | | 2353 | | |
| | 2 | 2354 | | return Response.FromValue( |
| | 2 | 2355 | | response.Value.ToFileDownloadInfo(), |
| | 2 | 2356 | | response.GetRawResponse()); |
| | | 2357 | | } |
| | 0 | 2358 | | catch (Exception ex) |
| | | 2359 | | { |
| | 0 | 2360 | | scope.Failed(ex); |
| | 0 | 2361 | | throw; |
| | | 2362 | | } |
| | | 2363 | | finally |
| | | 2364 | | { |
| | 2 | 2365 | | scope.Dispose(); |
| | 2 | 2366 | | } |
| | 2 | 2367 | | } |
| | | 2368 | | |
| | | 2369 | | /// <summary> |
| | | 2370 | | /// The <see cref="ReadAsync(HttpRange, DataLakeRequestConditions?, Boolean, CancellationToken)"/> |
| | | 2371 | | /// operation downloads a file from the service, including its metadata |
| | | 2372 | | /// and properties. |
| | | 2373 | | /// |
| | | 2374 | | /// For more information, see |
| | | 2375 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-blob"> |
| | | 2376 | | /// Get Blob</see>. |
| | | 2377 | | /// </summary> |
| | | 2378 | | /// <param name="range"> |
| | | 2379 | | /// If provided, only donwload the bytes of the file in the specified |
| | | 2380 | | /// range. If not provided, download the entire file. |
| | | 2381 | | /// </param> |
| | | 2382 | | /// <param name="conditions"> |
| | | 2383 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2384 | | /// donwloading this file. |
| | | 2385 | | /// </param> |
| | | 2386 | | /// <param name="rangeGetContentHash"> |
| | | 2387 | | /// When set to true and specified together with the <paramref name="range"/>, |
| | | 2388 | | /// the service returns the MD5 hash for the range, as long as the |
| | | 2389 | | /// range is less than or equal to 4 MB in size. If this value is |
| | | 2390 | | /// specified without <paramref name="range"/> or set to true when the |
| | | 2391 | | /// range exceeds 4 MB in size, a <see cref="RequestFailedException"/> |
| | | 2392 | | /// is thrown. |
| | | 2393 | | /// </param> |
| | | 2394 | | /// <param name="cancellationToken"> |
| | | 2395 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2396 | | /// notifications that the operation should be cancelled. |
| | | 2397 | | /// </param> |
| | | 2398 | | /// <returns> |
| | | 2399 | | /// A <see cref="Response{FileDownloadInfo}"/> describing the |
| | | 2400 | | /// downloaded file. <see cref="FileDownloadInfo.Content"/> contains |
| | | 2401 | | /// the file's data. |
| | | 2402 | | /// </returns> |
| | | 2403 | | /// <remarks> |
| | | 2404 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2405 | | /// a failure occurs. |
| | | 2406 | | /// </remarks> |
| | | 2407 | | public virtual async Task<Response<FileDownloadInfo>> ReadAsync( |
| | | 2408 | | HttpRange range = default, |
| | | 2409 | | DataLakeRequestConditions conditions = default, |
| | | 2410 | | bool rangeGetContentHash = default, |
| | | 2411 | | CancellationToken cancellationToken = default) |
| | | 2412 | | { |
| | 54 | 2413 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Read)}"); |
| | | 2414 | | |
| | | 2415 | | try |
| | | 2416 | | { |
| | 54 | 2417 | | scope.Start(); |
| | | 2418 | | |
| | 54 | 2419 | | Response<Blobs.Models.BlobDownloadInfo> response = await _blockBlobClient.DownloadAsync( |
| | 54 | 2420 | | range: range, |
| | 54 | 2421 | | conditions: conditions.ToBlobRequestConditions(), |
| | 54 | 2422 | | rangeGetContentHash: rangeGetContentHash, |
| | 54 | 2423 | | cancellationToken: cancellationToken) |
| | 54 | 2424 | | .ConfigureAwait(false); |
| | | 2425 | | |
| | 34 | 2426 | | return Response.FromValue( |
| | 34 | 2427 | | response.Value.ToFileDownloadInfo(), |
| | 34 | 2428 | | response.GetRawResponse()); |
| | | 2429 | | } |
| | 20 | 2430 | | catch (Exception ex) |
| | | 2431 | | { |
| | 20 | 2432 | | scope.Failed(ex); |
| | 20 | 2433 | | throw; |
| | | 2434 | | } |
| | | 2435 | | finally |
| | | 2436 | | { |
| | 54 | 2437 | | scope.Dispose(); |
| | | 2438 | | } |
| | 34 | 2439 | | } |
| | | 2440 | | #endregion Read Data |
| | | 2441 | | |
| | | 2442 | | #region Read To |
| | | 2443 | | /// <summary> |
| | | 2444 | | /// The <see cref="ReadTo(Stream, DataLakeRequestConditions, StorageTransferOptions, CancellationToken)"/> |
| | | 2445 | | /// operation downloads an entire file using parallel requests, |
| | | 2446 | | /// and writes the content to <paramref name="destination"/>. |
| | | 2447 | | /// </summary> |
| | | 2448 | | /// <param name="destination"> |
| | | 2449 | | /// A <see cref="Stream"/> to write the downloaded content to. |
| | | 2450 | | /// </param> |
| | | 2451 | | /// <param name="conditions"> |
| | | 2452 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2453 | | /// the download of this file. |
| | | 2454 | | /// </param> |
| | | 2455 | | /// <param name="transferOptions"> |
| | | 2456 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2457 | | /// parallel transfer behavior. |
| | | 2458 | | /// </param> |
| | | 2459 | | /// <param name="cancellationToken"> |
| | | 2460 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2461 | | /// notifications that the operation should be cancelled. |
| | | 2462 | | /// </param> |
| | | 2463 | | /// <returns> |
| | | 2464 | | /// A <see cref="Response"/> describing the operation. |
| | | 2465 | | /// </returns> |
| | | 2466 | | /// <remarks> |
| | | 2467 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2468 | | /// a failure occurs. |
| | | 2469 | | /// </remarks> |
| | | 2470 | | public virtual Response ReadTo( |
| | | 2471 | | Stream destination, |
| | | 2472 | | DataLakeRequestConditions conditions = default, |
| | | 2473 | | //IProgress<long> progressHandler = default, |
| | | 2474 | | StorageTransferOptions transferOptions = default, |
| | | 2475 | | CancellationToken cancellationToken = default) |
| | | 2476 | | { |
| | 8 | 2477 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(ReadTo)}"); |
| | | 2478 | | |
| | | 2479 | | try |
| | | 2480 | | { |
| | 8 | 2481 | | scope.Start(); |
| | | 2482 | | |
| | 8 | 2483 | | BlobRequestConditions blobRequestConditions = conditions.ToBlobRequestConditions(); |
| | | 2484 | | |
| | 8 | 2485 | | return _blockBlobClient.DownloadTo( |
| | 8 | 2486 | | destination, |
| | 8 | 2487 | | blobRequestConditions, |
| | 8 | 2488 | | //progressHandler, // TODO: #8506 |
| | 8 | 2489 | | transferOptions: transferOptions, |
| | 8 | 2490 | | cancellationToken: cancellationToken); |
| | | 2491 | | } |
| | 0 | 2492 | | catch (Exception ex) |
| | | 2493 | | { |
| | 0 | 2494 | | scope.Failed(ex); |
| | 0 | 2495 | | throw; |
| | | 2496 | | } |
| | | 2497 | | finally |
| | | 2498 | | { |
| | 8 | 2499 | | scope.Dispose(); |
| | 8 | 2500 | | } |
| | 8 | 2501 | | } |
| | | 2502 | | |
| | | 2503 | | /// <summary> |
| | | 2504 | | /// The <see cref="ReadTo(string, DataLakeRequestConditions, StorageTransferOptions, CancellationToken)"/> |
| | | 2505 | | /// operation downloads an entire file using parallel requests, |
| | | 2506 | | /// and writes the content to <paramref name="path"/>. |
| | | 2507 | | /// </summary> |
| | | 2508 | | /// <param name="path"> |
| | | 2509 | | /// A file path to write the downloaded content to. |
| | | 2510 | | /// </param> |
| | | 2511 | | /// <param name="conditions"> |
| | | 2512 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2513 | | /// the download of this file. |
| | | 2514 | | /// </param> |
| | | 2515 | | /// <param name="transferOptions"> |
| | | 2516 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2517 | | /// parallel transfer behavior. |
| | | 2518 | | /// </param> |
| | | 2519 | | /// <param name="cancellationToken"> |
| | | 2520 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2521 | | /// notifications that the operation should be cancelled. |
| | | 2522 | | /// </param> |
| | | 2523 | | /// <returns> |
| | | 2524 | | /// A <see cref="Response"/> describing the operation. |
| | | 2525 | | /// </returns> |
| | | 2526 | | /// <remarks> |
| | | 2527 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2528 | | /// a failure occurs. |
| | | 2529 | | /// </remarks> |
| | | 2530 | | public virtual Response ReadTo( |
| | | 2531 | | string path, |
| | | 2532 | | DataLakeRequestConditions conditions = default, |
| | | 2533 | | //IProgress<long> progressHandler = default, |
| | | 2534 | | StorageTransferOptions transferOptions = default, |
| | | 2535 | | CancellationToken cancellationToken = default) |
| | | 2536 | | { |
| | 0 | 2537 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(ReadTo)}"); |
| | | 2538 | | |
| | | 2539 | | try |
| | | 2540 | | { |
| | 0 | 2541 | | scope.Start(); |
| | | 2542 | | |
| | 0 | 2543 | | BlobRequestConditions blobRequestConditions = conditions.ToBlobRequestConditions(); |
| | | 2544 | | |
| | 0 | 2545 | | return _blockBlobClient.DownloadTo( |
| | 0 | 2546 | | path, |
| | 0 | 2547 | | blobRequestConditions, |
| | 0 | 2548 | | //progressHandler, // TODO: #8506 |
| | 0 | 2549 | | transferOptions: transferOptions, |
| | 0 | 2550 | | cancellationToken: cancellationToken); |
| | | 2551 | | } |
| | 0 | 2552 | | catch (Exception ex) |
| | | 2553 | | { |
| | 0 | 2554 | | scope.Failed(ex); |
| | 0 | 2555 | | throw; |
| | | 2556 | | } |
| | | 2557 | | finally |
| | | 2558 | | { |
| | 0 | 2559 | | scope.Dispose(); |
| | 0 | 2560 | | } |
| | 0 | 2561 | | } |
| | | 2562 | | |
| | | 2563 | | /// <summary> |
| | | 2564 | | /// The <see cref="ReadToAsync(Stream, DataLakeRequestConditions, StorageTransferOptions, CancellationToken)"/> |
| | | 2565 | | /// operation downloads an entire file using parallel requests, |
| | | 2566 | | /// and writes the content to <paramref name="destination"/>. |
| | | 2567 | | /// </summary> |
| | | 2568 | | /// <param name="destination"> |
| | | 2569 | | /// A <see cref="Stream"/> to write the downloaded content to. |
| | | 2570 | | /// </param> |
| | | 2571 | | /// <param name="conditions"> |
| | | 2572 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2573 | | /// the download of this file. |
| | | 2574 | | /// </param> |
| | | 2575 | | /// <param name="transferOptions"> |
| | | 2576 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2577 | | /// parallel transfer behavior. |
| | | 2578 | | /// </param> |
| | | 2579 | | /// <param name="cancellationToken"> |
| | | 2580 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2581 | | /// notifications that the operation should be cancelled. |
| | | 2582 | | /// </param> |
| | | 2583 | | /// <returns> |
| | | 2584 | | /// A <see cref="Response"/> describing the operation. |
| | | 2585 | | /// </returns> |
| | | 2586 | | /// <remarks> |
| | | 2587 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2588 | | /// a failure occurs. |
| | | 2589 | | /// </remarks> |
| | | 2590 | | public virtual async Task<Response> ReadToAsync( |
| | | 2591 | | Stream destination, |
| | | 2592 | | DataLakeRequestConditions conditions = default, |
| | | 2593 | | //IProgress<long> progressHandler = default, |
| | | 2594 | | StorageTransferOptions transferOptions = default, |
| | | 2595 | | CancellationToken cancellationToken = default) |
| | | 2596 | | { |
| | 28 | 2597 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(ReadTo)}"); |
| | | 2598 | | |
| | | 2599 | | try |
| | | 2600 | | { |
| | 28 | 2601 | | scope.Start(); |
| | | 2602 | | |
| | 28 | 2603 | | BlobRequestConditions blobRequestConditions = conditions.ToBlobRequestConditions(); |
| | | 2604 | | |
| | 28 | 2605 | | return await _blockBlobClient.DownloadToAsync( |
| | 28 | 2606 | | destination, |
| | 28 | 2607 | | blobRequestConditions, |
| | 28 | 2608 | | //progressHandler, // TODO: #8506 |
| | 28 | 2609 | | transferOptions: transferOptions, |
| | 28 | 2610 | | cancellationToken: cancellationToken) |
| | 28 | 2611 | | .ConfigureAwait(false); |
| | | 2612 | | } |
| | 0 | 2613 | | catch (Exception ex) |
| | | 2614 | | { |
| | 0 | 2615 | | scope.Failed(ex); |
| | 0 | 2616 | | throw; |
| | | 2617 | | } |
| | | 2618 | | finally |
| | | 2619 | | { |
| | 28 | 2620 | | scope.Dispose(); |
| | | 2621 | | } |
| | 28 | 2622 | | } |
| | | 2623 | | |
| | | 2624 | | /// <summary> |
| | | 2625 | | /// The <see cref="ReadToAsync(string, DataLakeRequestConditions, StorageTransferOptions, CancellationToken)"/> |
| | | 2626 | | /// operation downloads an entire file using parallel requests, |
| | | 2627 | | /// and writes the content to <paramref name="path"/>. |
| | | 2628 | | /// </summary> |
| | | 2629 | | /// <param name="path"> |
| | | 2630 | | /// A file path to write the downloaded content to. |
| | | 2631 | | /// </param> |
| | | 2632 | | /// <param name="conditions"> |
| | | 2633 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 2634 | | /// the download of this file. |
| | | 2635 | | /// </param> |
| | | 2636 | | /// <param name="transferOptions"> |
| | | 2637 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2638 | | /// parallel transfer behavior. |
| | | 2639 | | /// </param> |
| | | 2640 | | /// <param name="cancellationToken"> |
| | | 2641 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2642 | | /// notifications that the operation should be cancelled. |
| | | 2643 | | /// </param> |
| | | 2644 | | /// <returns> |
| | | 2645 | | /// A <see cref="Response"/> describing the operation. |
| | | 2646 | | /// </returns> |
| | | 2647 | | /// <remarks> |
| | | 2648 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2649 | | /// a failure occurs. |
| | | 2650 | | /// </remarks> |
| | | 2651 | | public virtual async Task<Response> ReadToAsync( |
| | | 2652 | | string path, |
| | | 2653 | | DataLakeRequestConditions conditions = default, |
| | | 2654 | | //IProgress<long> progressHandler = default, |
| | | 2655 | | StorageTransferOptions transferOptions = default, |
| | | 2656 | | CancellationToken cancellationToken = default) |
| | | 2657 | | { |
| | 12 | 2658 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($".{nameof(DataLakeFileClient)}.{nameof(ReadTo)}"); |
| | | 2659 | | |
| | | 2660 | | try |
| | | 2661 | | { |
| | 12 | 2662 | | scope.Start(); |
| | | 2663 | | |
| | 12 | 2664 | | BlobRequestConditions blobRequestConditions = conditions.ToBlobRequestConditions(); |
| | | 2665 | | |
| | 12 | 2666 | | return await _blockBlobClient.DownloadToAsync( |
| | 12 | 2667 | | path, |
| | 12 | 2668 | | blobRequestConditions, |
| | 12 | 2669 | | //progressHandler, // TODO: #8506 |
| | 12 | 2670 | | transferOptions: transferOptions, |
| | 12 | 2671 | | cancellationToken: cancellationToken) |
| | 12 | 2672 | | .ConfigureAwait(false); |
| | | 2673 | | } |
| | 0 | 2674 | | catch (Exception ex) |
| | | 2675 | | { |
| | 0 | 2676 | | scope.Failed(ex); |
| | 0 | 2677 | | throw; |
| | | 2678 | | } |
| | | 2679 | | finally |
| | | 2680 | | { |
| | 12 | 2681 | | scope.Dispose(); |
| | | 2682 | | } |
| | 12 | 2683 | | } |
| | | 2684 | | #endregion Read To |
| | | 2685 | | |
| | | 2686 | | #region Upload |
| | | 2687 | | /// <summary> |
| | | 2688 | | /// The <see cref="Upload(Stream, DataLakeFileUploadOptions, CancellationToken)"/> |
| | | 2689 | | /// operation creates and uploads content to a file. If the file already exists, its content will be overwritte |
| | | 2690 | | /// unless otherwise specified in the <see cref="DataLakeFileUploadOptions.Conditions"/> or alternatively use |
| | | 2691 | | /// <see cref="Upload(Stream)"/>, <see cref="Upload(Stream, bool, CancellationToken)"/>. |
| | | 2692 | | /// |
| | | 2693 | | /// For more information, see |
| | | 2694 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2695 | | /// Update Path</see>. |
| | | 2696 | | /// </summary> |
| | | 2697 | | /// <param name="content"> |
| | | 2698 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2699 | | /// </param> |
| | | 2700 | | /// <param name="options"> |
| | | 2701 | | /// Optional parameters. |
| | | 2702 | | /// </param> |
| | | 2703 | | /// <param name="cancellationToken"> |
| | | 2704 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2705 | | /// notifications that the operation should be cancelled. |
| | | 2706 | | /// </param> |
| | | 2707 | | /// <returns> |
| | | 2708 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2709 | | /// state of the updated file. |
| | | 2710 | | /// </returns> |
| | | 2711 | | /// <remarks> |
| | | 2712 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2713 | | /// a failure occurs. |
| | | 2714 | | /// </remarks> |
| | | 2715 | | public virtual Response<PathInfo> Upload( |
| | | 2716 | | Stream content, |
| | | 2717 | | DataLakeFileUploadOptions options, |
| | | 2718 | | CancellationToken cancellationToken = default) => |
| | 70 | 2719 | | StagedUploadInternal( |
| | 70 | 2720 | | content, |
| | 70 | 2721 | | options, |
| | 70 | 2722 | | async: false, |
| | 70 | 2723 | | cancellationToken: cancellationToken) |
| | 70 | 2724 | | .EnsureCompleted(); |
| | | 2725 | | |
| | | 2726 | | /// <summary> |
| | | 2727 | | /// The <see cref="Upload(Stream, PathHttpHeaders, DataLakeRequestConditions, IProgress{long}, StorageTransferOp |
| | | 2728 | | /// operation creates and uploads content to a file. If the file already exists, its content will be overwritte |
| | | 2729 | | /// unless otherwise specified in the <see cref="DataLakeRequestConditions"/> or alternatively use |
| | | 2730 | | /// <see cref="Upload(Stream)"/>, <see cref="Upload(Stream, bool, CancellationToken)"/>. |
| | | 2731 | | /// |
| | | 2732 | | /// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestora |
| | | 2733 | | /// </summary> |
| | | 2734 | | /// <param name="content"> |
| | | 2735 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2736 | | /// </param> |
| | | 2737 | | /// <param name="httpHeaders"> |
| | | 2738 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2739 | | /// </param> |
| | | 2740 | | /// <param name="conditions"> |
| | | 2741 | | /// Optional <see cref="DataLakeRequestConditions"/> to apply to the request. |
| | | 2742 | | /// </param> |
| | | 2743 | | /// <param name="progressHandler"> |
| | | 2744 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 2745 | | /// progress updates about data transfers. |
| | | 2746 | | /// </param> |
| | | 2747 | | /// <param name="transferOptions"> |
| | | 2748 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2749 | | /// parallel transfer behavior. |
| | | 2750 | | /// </param> |
| | | 2751 | | /// <param name="cancellationToken"> |
| | | 2752 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2753 | | /// notifications that the operation should be cancelled. |
| | | 2754 | | /// </param> |
| | | 2755 | | /// <returns> |
| | | 2756 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2757 | | /// state of the updated file. |
| | | 2758 | | /// </returns> |
| | | 2759 | | /// <remarks> |
| | | 2760 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2761 | | /// a failure occurs. |
| | | 2762 | | /// </remarks> |
| | | 2763 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2764 | | public virtual Response<PathInfo> Upload( |
| | | 2765 | | Stream content, |
| | | 2766 | | PathHttpHeaders httpHeaders = default, |
| | | 2767 | | DataLakeRequestConditions conditions = default, |
| | | 2768 | | IProgress<long> progressHandler = default, |
| | | 2769 | | StorageTransferOptions transferOptions = default, |
| | | 2770 | | CancellationToken cancellationToken = default) => |
| | 66 | 2771 | | Upload( |
| | 66 | 2772 | | content, |
| | 66 | 2773 | | new DataLakeFileUploadOptions |
| | 66 | 2774 | | { |
| | 66 | 2775 | | HttpHeaders = httpHeaders, |
| | 66 | 2776 | | Conditions = conditions, |
| | 66 | 2777 | | ProgressHandler = progressHandler, |
| | 66 | 2778 | | TransferOptions = transferOptions |
| | 66 | 2779 | | }, |
| | 66 | 2780 | | cancellationToken: cancellationToken); |
| | | 2781 | | |
| | | 2782 | | /// <summary> |
| | | 2783 | | /// The <see cref="Upload(Stream, bool, CancellationToken)"/> |
| | | 2784 | | /// operation creates and uploads content to a file. |
| | | 2785 | | /// |
| | | 2786 | | /// For more information, see |
| | | 2787 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2788 | | /// Update Path</see>. |
| | | 2789 | | /// </summary> |
| | | 2790 | | /// <param name="content"> |
| | | 2791 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2792 | | /// </param> |
| | | 2793 | | /// <returns> |
| | | 2794 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 2795 | | /// state of the updated file. |
| | | 2796 | | /// </returns> |
| | | 2797 | | /// <remarks> |
| | | 2798 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2799 | | /// a failure occurs. |
| | | 2800 | | /// </remarks> |
| | | 2801 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2802 | | public virtual Response<PathInfo> Upload( |
| | | 2803 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2804 | | Stream content) => |
| | 62 | 2805 | | Upload( |
| | 62 | 2806 | | content, |
| | 62 | 2807 | | overwrite: false); |
| | | 2808 | | |
| | | 2809 | | /// <summary> |
| | | 2810 | | /// The <see cref="Upload(Stream, bool, CancellationToken)"/> |
| | | 2811 | | /// operation creates and uploads content to a file. |
| | | 2812 | | /// |
| | | 2813 | | /// For more information, see |
| | | 2814 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2815 | | /// Update Path</see>. |
| | | 2816 | | /// </summary> |
| | | 2817 | | /// <param name="content"> |
| | | 2818 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2819 | | /// </param> |
| | | 2820 | | /// <param name="overwrite"> |
| | | 2821 | | /// Whether the upload should overwrite an existing file. The |
| | | 2822 | | /// default value is false. |
| | | 2823 | | /// </param> |
| | | 2824 | | /// <param name="cancellationToken"> |
| | | 2825 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2826 | | /// notifications that the operation should be cancelled. |
| | | 2827 | | /// </param> |
| | | 2828 | | /// <returns> |
| | | 2829 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 2830 | | /// state of the updated file. |
| | | 2831 | | /// </returns> |
| | | 2832 | | /// <remarks> |
| | | 2833 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2834 | | /// a failure occurs. |
| | | 2835 | | /// </remarks> |
| | | 2836 | | [ForwardsClientCalls] |
| | | 2837 | | public virtual Response<PathInfo> Upload( |
| | | 2838 | | Stream content, |
| | | 2839 | | bool overwrite = false, |
| | | 2840 | | CancellationToken cancellationToken = default) => |
| | 66 | 2841 | | Upload( |
| | 66 | 2842 | | content, |
| | 66 | 2843 | | conditions: overwrite ? null : new DataLakeRequestConditions { IfNoneMatch = new ETag(Constants.Wildcard |
| | 66 | 2844 | | cancellationToken: cancellationToken); |
| | | 2845 | | |
| | | 2846 | | /// <summary> |
| | | 2847 | | /// The <see cref="UploadAsync(Stream, DataLakeFileUploadOptions, CancellationToken)"/> |
| | | 2848 | | /// operation creates and uploads content to a file.If the file already exists, its content will be overwritten, |
| | | 2849 | | /// unless otherwise specified in the <see cref="DataLakeFileUploadOptions.Conditions"/> or alternatively use |
| | | 2850 | | /// <see cref="UploadAsync(Stream)"/>, <see cref="UploadAsync(Stream, bool, CancellationToken)"/>. |
| | | 2851 | | /// |
| | | 2852 | | /// For more information, see |
| | | 2853 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2854 | | /// Update Path</see>. |
| | | 2855 | | /// </summary> |
| | | 2856 | | /// <param name="content"> |
| | | 2857 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2858 | | /// </param> |
| | | 2859 | | /// <param name="options"> |
| | | 2860 | | /// Optional parameters. |
| | | 2861 | | /// </param> |
| | | 2862 | | /// <param name="cancellationToken"> |
| | | 2863 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2864 | | /// notifications that the operation should be cancelled. |
| | | 2865 | | /// </param> |
| | | 2866 | | /// <returns> |
| | | 2867 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2868 | | /// state of the updated block blob. |
| | | 2869 | | /// </returns> |
| | | 2870 | | /// <remarks> |
| | | 2871 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2872 | | /// a failure occurs. |
| | | 2873 | | /// </remarks> |
| | | 2874 | | [ForwardsClientCalls] |
| | | 2875 | | public virtual Task<Response<PathInfo>> UploadAsync( |
| | | 2876 | | Stream content, |
| | | 2877 | | DataLakeFileUploadOptions options, |
| | | 2878 | | CancellationToken cancellationToken = default) => |
| | 4 | 2879 | | StagedUploadInternal( |
| | 4 | 2880 | | content, |
| | 4 | 2881 | | options, |
| | 4 | 2882 | | async: true, |
| | 4 | 2883 | | cancellationToken: cancellationToken); |
| | | 2884 | | |
| | | 2885 | | /// <summary> |
| | | 2886 | | /// The <see cref="UploadAsync(Stream, PathHttpHeaders, DataLakeRequestConditions, IProgress{long}, StorageTrans |
| | | 2887 | | /// operation creates and uploads content to a file. If the file already exists, its content will be overwritte |
| | | 2888 | | /// unless otherwise specified in the <see cref="DataLakeRequestConditions"/> or alternatively use |
| | | 2889 | | /// <see cref="UploadAsync(Stream)"/>, <see cref="UploadAsync(Stream, bool, CancellationToken)"/>. |
| | | 2890 | | /// |
| | | 2891 | | /// For more information, see |
| | | 2892 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2893 | | /// Update Path</see>. |
| | | 2894 | | /// </summary> |
| | | 2895 | | /// <param name="content"> |
| | | 2896 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2897 | | /// </param> |
| | | 2898 | | /// <param name="httpHeaders"> |
| | | 2899 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2900 | | ///</param> |
| | | 2901 | | /// <param name="conditions"> |
| | | 2902 | | /// Optional <see cref="DataLakeRequestConditions"/> to apply to the request. |
| | | 2903 | | /// </param> |
| | | 2904 | | /// <param name="transferOptions"> |
| | | 2905 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 2906 | | /// parallel transfer behavior. |
| | | 2907 | | /// </param> |
| | | 2908 | | /// <param name="progressHandler"> |
| | | 2909 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 2910 | | /// progress updates about data transfers. |
| | | 2911 | | /// </param> |
| | | 2912 | | /// <param name="cancellationToken"> |
| | | 2913 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2914 | | /// notifications that the operation should be cancelled. |
| | | 2915 | | /// </param> |
| | | 2916 | | /// <returns> |
| | | 2917 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2918 | | /// state of the updated block blob. |
| | | 2919 | | /// </returns> |
| | | 2920 | | /// <remarks> |
| | | 2921 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2922 | | /// a failure occurs. |
| | | 2923 | | /// </remarks> |
| | | 2924 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2925 | | public virtual Task<Response<PathInfo>> UploadAsync( |
| | | 2926 | | Stream content, |
| | | 2927 | | PathHttpHeaders httpHeaders = default, |
| | | 2928 | | DataLakeRequestConditions conditions = default, |
| | | 2929 | | IProgress<long> progressHandler = default, |
| | | 2930 | | StorageTransferOptions transferOptions = default, |
| | | 2931 | | CancellationToken cancellationToken = default) => |
| | 70 | 2932 | | StagedUploadInternal( |
| | 70 | 2933 | | content, |
| | 70 | 2934 | | new DataLakeFileUploadOptions |
| | 70 | 2935 | | { |
| | 70 | 2936 | | HttpHeaders = httpHeaders, |
| | 70 | 2937 | | Conditions = conditions, |
| | 70 | 2938 | | ProgressHandler = progressHandler, |
| | 70 | 2939 | | TransferOptions = transferOptions |
| | 70 | 2940 | | }, |
| | 70 | 2941 | | async: true, |
| | 70 | 2942 | | cancellationToken: cancellationToken); |
| | | 2943 | | |
| | | 2944 | | /// <summary> |
| | | 2945 | | /// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/> |
| | | 2946 | | /// operation creates and uploads content to a file. |
| | | 2947 | | /// |
| | | 2948 | | /// For more information, see |
| | | 2949 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2950 | | /// Update Path</see>. |
| | | 2951 | | /// </summary> |
| | | 2952 | | /// <param name="content"> |
| | | 2953 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2954 | | /// </param> |
| | | 2955 | | /// <returns> |
| | | 2956 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2957 | | /// state of the updated block blob. |
| | | 2958 | | /// </returns> |
| | | 2959 | | /// <remarks> |
| | | 2960 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2961 | | /// a failure occurs. |
| | | 2962 | | /// </remarks> |
| | | 2963 | | [ForwardsClientCalls] |
| | | 2964 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2965 | | public virtual Task<Response<PathInfo>> UploadAsync( |
| | | 2966 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2967 | | Stream content) => |
| | 62 | 2968 | | UploadAsync( |
| | 62 | 2969 | | content, |
| | 62 | 2970 | | overwrite: false); |
| | | 2971 | | |
| | | 2972 | | /// <summary> |
| | | 2973 | | /// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/> |
| | | 2974 | | /// operation creates and uploads content to a file. |
| | | 2975 | | /// |
| | | 2976 | | /// For more information, see |
| | | 2977 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 2978 | | /// Update Path</see>. |
| | | 2979 | | /// </summary> |
| | | 2980 | | /// <param name="content"> |
| | | 2981 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 2982 | | /// </param> |
| | | 2983 | | /// <param name="overwrite"> |
| | | 2984 | | /// Whether the upload should overwrite an existing file. The |
| | | 2985 | | /// default value is false. |
| | | 2986 | | /// </param> |
| | | 2987 | | /// <param name="cancellationToken"> |
| | | 2988 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2989 | | /// notifications that the operation should be cancelled. |
| | | 2990 | | /// </param> |
| | | 2991 | | /// <returns> |
| | | 2992 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 2993 | | /// state of the updated block blob. |
| | | 2994 | | /// </returns> |
| | | 2995 | | /// <remarks> |
| | | 2996 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2997 | | /// a failure occurs. |
| | | 2998 | | /// </remarks> |
| | | 2999 | | [ForwardsClientCalls] |
| | | 3000 | | public virtual Task<Response<PathInfo>> UploadAsync( |
| | | 3001 | | Stream content, |
| | | 3002 | | bool overwrite = false, |
| | | 3003 | | CancellationToken cancellationToken = default) => |
| | 70 | 3004 | | UploadAsync( |
| | 70 | 3005 | | content, |
| | 70 | 3006 | | conditions: overwrite ? null : new DataLakeRequestConditions { IfNoneMatch = new ETag(Constants.Wildcard |
| | 70 | 3007 | | cancellationToken: cancellationToken); |
| | | 3008 | | |
| | | 3009 | | /// <summary> |
| | | 3010 | | /// The <see cref="Upload(string, DataLakeFileUploadOptions, CancellationToken)"/> |
| | | 3011 | | /// operation creates and uploads content to a file.If the file already exists, its content will be overwritten, |
| | | 3012 | | /// unless otherwise specified in the <see cref="DataLakeFileUploadOptions.Conditions"/> or alternatively use |
| | | 3013 | | /// <see cref="Upload(Stream)"/>, <see cref="Upload(Stream, bool, CancellationToken)"/>. |
| | | 3014 | | /// |
| | | 3015 | | /// For more information, see |
| | | 3016 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3017 | | /// Update Path</see>. |
| | | 3018 | | /// </summary> |
| | | 3019 | | /// <param name="path"> |
| | | 3020 | | /// A file path containing the content to upload. |
| | | 3021 | | /// </param> of this new block blob. |
| | | 3022 | | /// <param name="options"> |
| | | 3023 | | /// Optional parameters. |
| | | 3024 | | /// </param> |
| | | 3025 | | /// <param name="cancellationToken"> |
| | | 3026 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3027 | | /// notifications that the operation should be cancelled. |
| | | 3028 | | /// </param> |
| | | 3029 | | /// <returns> |
| | | 3030 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3031 | | /// state of the updated block blob. |
| | | 3032 | | /// </returns> |
| | | 3033 | | /// <remarks> |
| | | 3034 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3035 | | /// a failure occurs. |
| | | 3036 | | /// </remarks> |
| | | 3037 | | [ForwardsClientCalls] |
| | | 3038 | | public virtual Response<PathInfo> Upload( |
| | | 3039 | | string path, |
| | | 3040 | | DataLakeFileUploadOptions options, |
| | | 3041 | | CancellationToken cancellationToken = default) |
| | 4 | 3042 | | => StagedUploadInternal( |
| | 4 | 3043 | | path, |
| | 4 | 3044 | | options, |
| | 4 | 3045 | | async: false, |
| | 4 | 3046 | | cancellationToken: cancellationToken) |
| | 4 | 3047 | | .EnsureCompleted(); |
| | | 3048 | | |
| | | 3049 | | /// <summary> |
| | | 3050 | | /// The <see cref="Upload(string, PathHttpHeaders, DataLakeRequestConditions, IProgress{long}, StorageTransferOp |
| | | 3051 | | /// operation creates and uploads content to a file.If the file already exists, its content will be overwritten, |
| | | 3052 | | /// unless otherwise specified in the <see cref="DataLakeRequestConditions"/> or alternatively use |
| | | 3053 | | /// <see cref="Upload(Stream)"/>, <see cref="Upload(Stream, bool, CancellationToken)"/>. |
| | | 3054 | | /// |
| | | 3055 | | /// For more information, see |
| | | 3056 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3057 | | /// Update Path</see>. |
| | | 3058 | | /// </summary> |
| | | 3059 | | /// <param name="path"> |
| | | 3060 | | /// A file path containing the content to upload. |
| | | 3061 | | /// </param> of this new block blob. |
| | | 3062 | | /// <param name="httpHeaders"> |
| | | 3063 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 3064 | | ///</param> |
| | | 3065 | | /// <param name="conditions"> |
| | | 3066 | | /// Optional <see cref="DataLakeRequestConditions"/> to apply to the request. |
| | | 3067 | | /// </param> |
| | | 3068 | | /// <param name="progressHandler"> |
| | | 3069 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 3070 | | /// progress updates about data transfers. |
| | | 3071 | | /// </param> |
| | | 3072 | | /// <param name="transferOptions"> |
| | | 3073 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 3074 | | /// parallel transfer behavior. |
| | | 3075 | | /// </param> |
| | | 3076 | | /// <param name="cancellationToken"> |
| | | 3077 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3078 | | /// notifications that the operation should be cancelled. |
| | | 3079 | | /// </param> |
| | | 3080 | | /// <returns> |
| | | 3081 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3082 | | /// state of the updated block blob. |
| | | 3083 | | /// </returns> |
| | | 3084 | | /// <remarks> |
| | | 3085 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3086 | | /// a failure occurs. |
| | | 3087 | | /// </remarks> |
| | | 3088 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 3089 | | [ForwardsClientCalls] |
| | | 3090 | | public virtual Response<PathInfo> Upload( |
| | | 3091 | | string path, |
| | | 3092 | | PathHttpHeaders httpHeaders = default, |
| | | 3093 | | DataLakeRequestConditions conditions = default, |
| | | 3094 | | IProgress<long> progressHandler = default, |
| | | 3095 | | StorageTransferOptions transferOptions = default, |
| | | 3096 | | CancellationToken cancellationToken = default) |
| | | 3097 | | { |
| | 6 | 3098 | | using (FileStream stream = new FileStream(path, FileMode.Open)) |
| | | 3099 | | { |
| | 6 | 3100 | | return StagedUploadInternal( |
| | 6 | 3101 | | stream, |
| | 6 | 3102 | | new DataLakeFileUploadOptions |
| | 6 | 3103 | | { |
| | 6 | 3104 | | HttpHeaders = httpHeaders, |
| | 6 | 3105 | | Conditions = conditions, |
| | 6 | 3106 | | ProgressHandler = progressHandler, |
| | 6 | 3107 | | TransferOptions = transferOptions |
| | 6 | 3108 | | }, |
| | 6 | 3109 | | async: false, |
| | 6 | 3110 | | cancellationToken: cancellationToken) |
| | 6 | 3111 | | .EnsureCompleted(); |
| | | 3112 | | } |
| | 4 | 3113 | | } |
| | | 3114 | | |
| | | 3115 | | /// <summary> |
| | | 3116 | | /// The <see cref="Upload(Stream, bool, CancellationToken)"/> |
| | | 3117 | | /// operation creates and uploads content to a file. |
| | | 3118 | | /// |
| | | 3119 | | /// For more information, see |
| | | 3120 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3121 | | /// Update Path</see>. |
| | | 3122 | | /// </summary> |
| | | 3123 | | /// <param name="path"> |
| | | 3124 | | /// A file path containing the content to upload. |
| | | 3125 | | /// </param> of this new block blob. |
| | | 3126 | | /// <returns> |
| | | 3127 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3128 | | /// state of the updated block blob. |
| | | 3129 | | /// </returns> |
| | | 3130 | | /// <remarks> |
| | | 3131 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3132 | | /// a failure occurs. |
| | | 3133 | | /// </remarks> |
| | | 3134 | | [ForwardsClientCalls] |
| | | 3135 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 3136 | | public virtual Response<PathInfo> Upload( |
| | | 3137 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 3138 | | string path) => |
| | 2 | 3139 | | Upload( |
| | 2 | 3140 | | path, |
| | 2 | 3141 | | overwrite: false); |
| | | 3142 | | |
| | | 3143 | | /// <summary> |
| | | 3144 | | /// The <see cref="Upload(Stream, bool, CancellationToken)"/> |
| | | 3145 | | /// operation creates and uploads content to a file. |
| | | 3146 | | /// |
| | | 3147 | | /// For more information, see |
| | | 3148 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3149 | | /// Update Path</see>. |
| | | 3150 | | /// </summary> |
| | | 3151 | | /// <param name="path"> |
| | | 3152 | | /// A file path containing the content to upload. |
| | | 3153 | | /// </param> of this new block blob. |
| | | 3154 | | /// <param name="overwrite"> |
| | | 3155 | | /// Whether the upload should overwrite an existing file. The |
| | | 3156 | | /// default value is false. |
| | | 3157 | | /// </param> |
| | | 3158 | | /// <param name="cancellationToken"> |
| | | 3159 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3160 | | /// notifications that the operation should be cancelled. |
| | | 3161 | | /// </param> |
| | | 3162 | | /// <returns> |
| | | 3163 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3164 | | /// state of the updated block blob. |
| | | 3165 | | /// </returns> |
| | | 3166 | | /// <remarks> |
| | | 3167 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3168 | | /// a failure occurs. |
| | | 3169 | | /// </remarks> |
| | | 3170 | | [ForwardsClientCalls] |
| | | 3171 | | public virtual Response<PathInfo> Upload( |
| | | 3172 | | string path, |
| | | 3173 | | bool overwrite = false, |
| | | 3174 | | CancellationToken cancellationToken = default) => |
| | 6 | 3175 | | Upload( |
| | 6 | 3176 | | path, |
| | 6 | 3177 | | conditions: overwrite ? null : new DataLakeRequestConditions { IfNoneMatch = new ETag(Constants.Wildcard |
| | 6 | 3178 | | cancellationToken: cancellationToken); |
| | | 3179 | | |
| | | 3180 | | /// <summary> |
| | | 3181 | | /// The <see cref="UploadAsync(string, DataLakeFileUploadOptions, CancellationToken)"/> |
| | | 3182 | | /// operation creates and uploads content to a file. If the file already exists, its content will be overwritte |
| | | 3183 | | /// unless otherwise specified in the <see cref="DataLakeFileUploadOptions.Conditions"/> or alternatively use |
| | | 3184 | | /// <see cref="UploadAsync(Stream)"/>, <see cref="UploadAsync(Stream, bool, CancellationToken)"/>. |
| | | 3185 | | /// |
| | | 3186 | | /// For more information, see |
| | | 3187 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3188 | | /// Update Path</see>. |
| | | 3189 | | /// </summary> |
| | | 3190 | | /// <param name="path"> |
| | | 3191 | | /// A file path containing the content to upload. |
| | | 3192 | | /// </param> |
| | | 3193 | | /// <param name="options"> |
| | | 3194 | | /// Optional parameters. |
| | | 3195 | | /// </param> |
| | | 3196 | | /// <param name="cancellationToken"> |
| | | 3197 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3198 | | /// notifications that the operation should be cancelled. |
| | | 3199 | | /// </param> |
| | | 3200 | | /// <returns> |
| | | 3201 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3202 | | /// state of the updated block blob. |
| | | 3203 | | /// </returns> |
| | | 3204 | | /// <remarks> |
| | | 3205 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3206 | | /// a failure occurs. |
| | | 3207 | | /// </remarks> |
| | | 3208 | | [ForwardsClientCalls] |
| | | 3209 | | public virtual async Task<Response<PathInfo>> UploadAsync( |
| | | 3210 | | string path, |
| | | 3211 | | DataLakeFileUploadOptions options, |
| | | 3212 | | CancellationToken cancellationToken = default) |
| | | 3213 | | { |
| | 14 | 3214 | | using (FileStream stream = new FileStream(path, FileMode.Open)) |
| | | 3215 | | { |
| | 14 | 3216 | | return await StagedUploadInternal( |
| | 14 | 3217 | | stream, |
| | 14 | 3218 | | options, |
| | 14 | 3219 | | async: true, |
| | 14 | 3220 | | cancellationToken: cancellationToken) |
| | 14 | 3221 | | .ConfigureAwait(false); |
| | | 3222 | | } |
| | 12 | 3223 | | } |
| | | 3224 | | |
| | | 3225 | | /// <summary> |
| | | 3226 | | /// The <see cref="UploadAsync(string, PathHttpHeaders, DataLakeRequestConditions, IProgress{long}, StorageTrans |
| | | 3227 | | /// operation creates and uploads content to a file. If the file already exists, its content will be overwritte |
| | | 3228 | | /// unless otherwise specified in the <see cref="DataLakeRequestConditions"/> or alternatively use |
| | | 3229 | | /// <see cref="Upload(Stream)"/>, <see cref="Upload(Stream, bool, CancellationToken)"/>. |
| | | 3230 | | /// |
| | | 3231 | | /// For more information, see |
| | | 3232 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3233 | | /// Update Path</see>. |
| | | 3234 | | /// </summary> |
| | | 3235 | | /// <param name="path"> |
| | | 3236 | | /// A file path containing the content to upload. |
| | | 3237 | | /// </param> |
| | | 3238 | | /// <param name="httpHeaders"> |
| | | 3239 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 3240 | | ///</param> |
| | | 3241 | | /// <param name="conditions"> |
| | | 3242 | | /// Optional <see cref="DataLakeRequestConditions"/> to apply to the request. |
| | | 3243 | | /// </param> |
| | | 3244 | | /// <param name="progressHandler"> |
| | | 3245 | | /// Optional <see cref="IProgress{Long}"/> to provide |
| | | 3246 | | /// progress updates about data transfers. |
| | | 3247 | | /// </param> |
| | | 3248 | | /// <param name="transferOptions"> |
| | | 3249 | | /// Optional <see cref="StorageTransferOptions"/> to configure |
| | | 3250 | | /// parallel transfer behavior. |
| | | 3251 | | /// </param> |
| | | 3252 | | /// <param name="cancellationToken"> |
| | | 3253 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3254 | | /// notifications that the operation should be cancelled. |
| | | 3255 | | /// </param> |
| | | 3256 | | /// <returns> |
| | | 3257 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3258 | | /// state of the updated block blob. |
| | | 3259 | | /// </returns> |
| | | 3260 | | /// <remarks> |
| | | 3261 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3262 | | /// a failure occurs. |
| | | 3263 | | /// </remarks> |
| | | 3264 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 3265 | | [ForwardsClientCalls] |
| | | 3266 | | public virtual async Task<Response<PathInfo>> UploadAsync( |
| | | 3267 | | string path, |
| | | 3268 | | PathHttpHeaders httpHeaders = default, |
| | | 3269 | | DataLakeRequestConditions conditions = default, |
| | | 3270 | | IProgress<long> progressHandler = default, |
| | | 3271 | | StorageTransferOptions transferOptions = default, |
| | | 3272 | | CancellationToken cancellationToken = default) |
| | 10 | 3273 | | => await UploadAsync( |
| | 10 | 3274 | | path, |
| | 10 | 3275 | | new DataLakeFileUploadOptions |
| | 10 | 3276 | | { |
| | 10 | 3277 | | HttpHeaders = httpHeaders, |
| | 10 | 3278 | | Conditions = conditions, |
| | 10 | 3279 | | ProgressHandler = progressHandler, |
| | 10 | 3280 | | TransferOptions = transferOptions |
| | 10 | 3281 | | }, |
| | 10 | 3282 | | cancellationToken).ConfigureAwait(false); |
| | | 3283 | | |
| | | 3284 | | /// <summary> |
| | | 3285 | | /// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/> |
| | | 3286 | | /// operation creates and uploads content to a file. |
| | | 3287 | | /// |
| | | 3288 | | /// For more information, see |
| | | 3289 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3290 | | /// Update Path</see>. |
| | | 3291 | | /// </summary> |
| | | 3292 | | /// <param name="path"> |
| | | 3293 | | /// A file path containing the content to upload. |
| | | 3294 | | /// </param> |
| | | 3295 | | /// <returns> |
| | | 3296 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3297 | | /// state of the updated block blob. |
| | | 3298 | | /// </returns> |
| | | 3299 | | /// <remarks> |
| | | 3300 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3301 | | /// a failure occurs. |
| | | 3302 | | /// </remarks> |
| | | 3303 | | [ForwardsClientCalls] |
| | | 3304 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 3305 | | public virtual async Task<Response<PathInfo>> UploadAsync( |
| | | 3306 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 3307 | | string path) => |
| | 2 | 3308 | | await UploadAsync( |
| | 2 | 3309 | | path, |
| | 2 | 3310 | | overwrite: false).ConfigureAwait(false); |
| | | 3311 | | |
| | | 3312 | | /// <summary> |
| | | 3313 | | /// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/> |
| | | 3314 | | /// operation creates and uploads content to a file. |
| | | 3315 | | /// |
| | | 3316 | | /// For more information, see |
| | | 3317 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" > |
| | | 3318 | | /// Update Path</see>. |
| | | 3319 | | /// </summary> |
| | | 3320 | | /// <param name="path"> |
| | | 3321 | | /// A file path containing the content to upload. |
| | | 3322 | | /// </param> |
| | | 3323 | | /// <param name="overwrite"> |
| | | 3324 | | /// Whether the upload should overwrite an existing file. The |
| | | 3325 | | /// default value is false. |
| | | 3326 | | /// </param> |
| | | 3327 | | /// <param name="cancellationToken"> |
| | | 3328 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3329 | | /// notifications that the operation should be cancelled. |
| | | 3330 | | /// </param> |
| | | 3331 | | /// <returns> |
| | | 3332 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3333 | | /// state of the updated block blob. |
| | | 3334 | | /// </returns> |
| | | 3335 | | /// <remarks> |
| | | 3336 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3337 | | /// a failure occurs. |
| | | 3338 | | /// </remarks> |
| | | 3339 | | [ForwardsClientCalls] |
| | | 3340 | | public virtual async Task<Response<PathInfo>> UploadAsync( |
| | | 3341 | | string path, |
| | | 3342 | | bool overwrite = false, |
| | | 3343 | | CancellationToken cancellationToken = default) => |
| | 10 | 3344 | | await UploadAsync( |
| | 10 | 3345 | | path, |
| | 10 | 3346 | | conditions: overwrite ? null : new DataLakeRequestConditions { IfNoneMatch = new ETag(Constants.Wild |
| | 10 | 3347 | | cancellationToken: cancellationToken).ConfigureAwait(false); |
| | | 3348 | | |
| | | 3349 | | /// <summary> |
| | | 3350 | | /// This operation will upload data as indiviually staged |
| | | 3351 | | /// blocks if it's larger than the |
| | | 3352 | | /// <paramref name="options"/> <see cref="StorageTransferOptions.InitialTransferSize"/>. |
| | | 3353 | | /// </summary> |
| | | 3354 | | /// <param name="content"> |
| | | 3355 | | /// A <see cref="Stream"/> containing the content to upload. |
| | | 3356 | | /// </param> |
| | | 3357 | | /// <param name="options"> |
| | | 3358 | | /// Optional parameters. |
| | | 3359 | | /// </param> |
| | | 3360 | | /// <param name="async"> |
| | | 3361 | | /// </param> |
| | | 3362 | | /// <param name="cancellationToken"> |
| | | 3363 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3364 | | /// notifications that the operation should be cancelled. |
| | | 3365 | | /// </param> |
| | | 3366 | | /// <returns> |
| | | 3367 | | /// A <see cref="Response{PathInfo}"/> describing the |
| | | 3368 | | /// state of the updated file. |
| | | 3369 | | /// </returns> |
| | | 3370 | | /// <remarks> |
| | | 3371 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3372 | | /// a failure occurs. |
| | | 3373 | | /// </remarks> |
| | | 3374 | | internal async Task<Response<PathInfo>> StagedUploadInternal( |
| | | 3375 | | Stream content, |
| | | 3376 | | DataLakeFileUploadOptions options, |
| | | 3377 | | bool async = true, |
| | | 3378 | | CancellationToken cancellationToken = default) |
| | | 3379 | | { |
| | 168 | 3380 | | DataLakeFileClient client = new DataLakeFileClient(Uri, Pipeline, Version, ClientDiagnostics); |
| | | 3381 | | |
| | 168 | 3382 | | var uploader = GetPartitionedUploader( |
| | 168 | 3383 | | options.TransferOptions, |
| | 168 | 3384 | | operationName: $"{nameof(DataLakeFileClient)}.{nameof(Upload)}"); |
| | | 3385 | | |
| | 168 | 3386 | | return await uploader.UploadInternal( |
| | 168 | 3387 | | content, |
| | 168 | 3388 | | options, |
| | 168 | 3389 | | options.ProgressHandler, |
| | 168 | 3390 | | async, |
| | 168 | 3391 | | cancellationToken) |
| | 168 | 3392 | | .ConfigureAwait(false); |
| | 160 | 3393 | | } |
| | | 3394 | | |
| | | 3395 | | /// <summary> |
| | | 3396 | | /// This operation will upload data it as individually staged |
| | | 3397 | | /// blocks if it's larger than the |
| | | 3398 | | /// <paramref name="options"/> <see cref="StorageTransferOptions.InitialTransferSize"/>. |
| | | 3399 | | /// </summary> |
| | | 3400 | | /// <param name="path"> |
| | | 3401 | | /// A file path of the file to upload. |
| | | 3402 | | /// </param> |
| | | 3403 | | /// <param name="options"> |
| | | 3404 | | /// Optional parameters. |
| | | 3405 | | /// </param> |
| | | 3406 | | /// <param name="async"> |
| | | 3407 | | /// </param> |
| | | 3408 | | /// <param name="cancellationToken"> |
| | | 3409 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3410 | | /// notifications that the operation should be cancelled. |
| | | 3411 | | /// </param> |
| | | 3412 | | /// <returns> |
| | | 3413 | | /// A <see cref="Response{BlobContentInfo}"/> describing the |
| | | 3414 | | /// state of the updated block blob. |
| | | 3415 | | /// </returns> |
| | | 3416 | | /// <remarks> |
| | | 3417 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3418 | | /// a failure occurs. |
| | | 3419 | | /// </remarks> |
| | | 3420 | | internal async Task<Response<PathInfo>> StagedUploadInternal( |
| | | 3421 | | string path, |
| | | 3422 | | DataLakeFileUploadOptions options, |
| | | 3423 | | bool async = true, |
| | | 3424 | | CancellationToken cancellationToken = default) |
| | | 3425 | | { |
| | 4 | 3426 | | using (FileStream stream = new FileStream(path, FileMode.Open)) |
| | | 3427 | | { |
| | 4 | 3428 | | return await StagedUploadInternal( |
| | 4 | 3429 | | stream, |
| | 4 | 3430 | | options, |
| | 4 | 3431 | | async: async, |
| | 4 | 3432 | | cancellationToken: cancellationToken) |
| | 4 | 3433 | | .ConfigureAwait(false); |
| | | 3434 | | } |
| | 4 | 3435 | | } |
| | | 3436 | | #endregion Upload |
| | | 3437 | | |
| | | 3438 | | #region ScheduleDeletion |
| | | 3439 | | /// <summary> |
| | | 3440 | | /// Schedules the file for deletation. |
| | | 3441 | | /// </summary> |
| | | 3442 | | /// <param name="options"> |
| | | 3443 | | /// Schedule deletion parameters. |
| | | 3444 | | /// </param> |
| | | 3445 | | /// <param name="cancellationToken"> |
| | | 3446 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3447 | | /// notifications that the operation should be cancelled. |
| | | 3448 | | /// </param> |
| | | 3449 | | /// <returns> |
| | | 3450 | | /// A <see cref="Response{PathInfo}"/> describing the file. |
| | | 3451 | | /// </returns> |
| | | 3452 | | /// <remarks> |
| | | 3453 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3454 | | /// a failure occurs. |
| | | 3455 | | /// </remarks> |
| | | 3456 | | internal virtual Response<PathInfo> ScheduleDeletion( |
| | | 3457 | | DataLakeFileScheduleDeletionOptions options, |
| | | 3458 | | CancellationToken cancellationToken = default) |
| | 2 | 3459 | | => ScheduleDeletionInternal( |
| | 2 | 3460 | | options, |
| | 2 | 3461 | | async: false, |
| | 2 | 3462 | | cancellationToken) |
| | 2 | 3463 | | .EnsureCompleted(); |
| | | 3464 | | |
| | | 3465 | | /// <summary> |
| | | 3466 | | /// Schedules the file for deletation. |
| | | 3467 | | /// </summary> |
| | | 3468 | | /// <param name="options"> |
| | | 3469 | | /// Schedule deletion parameters. |
| | | 3470 | | /// </param> |
| | | 3471 | | /// <param name="cancellationToken"> |
| | | 3472 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3473 | | /// notifications that the operation should be cancelled. |
| | | 3474 | | /// </param> |
| | | 3475 | | /// <returns> |
| | | 3476 | | /// A <see cref="Response{PathInfo}"/> describing the file. |
| | | 3477 | | /// </returns> |
| | | 3478 | | /// <remarks> |
| | | 3479 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3480 | | /// a failure occurs. |
| | | 3481 | | /// </remarks> |
| | | 3482 | | internal virtual async Task<Response<PathInfo>> ScheduleDeletionAsync( |
| | | 3483 | | DataLakeFileScheduleDeletionOptions options, |
| | | 3484 | | CancellationToken cancellationToken = default) |
| | 22 | 3485 | | => await ScheduleDeletionInternal( |
| | 22 | 3486 | | options, |
| | 22 | 3487 | | async: true, |
| | 22 | 3488 | | cancellationToken).ConfigureAwait(false); |
| | | 3489 | | |
| | | 3490 | | /// <summary> |
| | | 3491 | | /// Schedules the file for deletion. |
| | | 3492 | | /// </summary> |
| | | 3493 | | /// <param name="options"> |
| | | 3494 | | /// Schedule deletion parameters. |
| | | 3495 | | /// </param> |
| | | 3496 | | /// <param name="async"> |
| | | 3497 | | /// Whether to invoke the operation asynchronously. |
| | | 3498 | | /// </param> |
| | | 3499 | | /// <param name="cancellationToken"> |
| | | 3500 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3501 | | /// notifications that the operation should be cancelled. |
| | | 3502 | | /// </param> |
| | | 3503 | | /// <returns> |
| | | 3504 | | /// A <see cref="Response{BlobInfo}"/> describing the file. |
| | | 3505 | | /// </returns> |
| | | 3506 | | /// <remarks> |
| | | 3507 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3508 | | /// a failure occurs. |
| | | 3509 | | /// </remarks> |
| | | 3510 | | private async Task<Response<PathInfo>> ScheduleDeletionInternal( |
| | | 3511 | | DataLakeFileScheduleDeletionOptions options, |
| | | 3512 | | bool async, |
| | | 3513 | | CancellationToken cancellationToken) |
| | | 3514 | | { |
| | 24 | 3515 | | using (Pipeline.BeginLoggingScope(nameof(DataLakeFileClient))) |
| | | 3516 | | { |
| | | 3517 | | Pipeline.LogMethodEnter( |
| | | 3518 | | nameof(DataLakeFileClient), |
| | | 3519 | | message: |
| | | 3520 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 3521 | | $"{nameof(options.TimeToExpire)}: {options.TimeToExpire}\n" + |
| | | 3522 | | $"{nameof(options.SetExpiryRelativeTo)}: {options.SetExpiryRelativeTo}\n" + |
| | | 3523 | | $"{nameof(options.ExpiresOn)}: {options.ExpiresOn}"); |
| | | 3524 | | try |
| | | 3525 | | { |
| | | 3526 | | |
| | | 3527 | | PathExpiryOptions blobExpiryOptions; |
| | 24 | 3528 | | string expiresOn = null; |
| | | 3529 | | |
| | | 3530 | | // Relative |
| | 24 | 3531 | | if (options.TimeToExpire.HasValue) |
| | | 3532 | | { |
| | 12 | 3533 | | if (options.SetExpiryRelativeTo.Value == DataLakeFileExpirationOrigin.CreationTime) |
| | | 3534 | | { |
| | 4 | 3535 | | blobExpiryOptions = PathExpiryOptions.RelativeToCreation; |
| | | 3536 | | } |
| | | 3537 | | else |
| | | 3538 | | { |
| | 8 | 3539 | | blobExpiryOptions = PathExpiryOptions.RelativeToNow; |
| | | 3540 | | } |
| | 12 | 3541 | | expiresOn = options.TimeToExpire.Value.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); |
| | | 3542 | | } |
| | | 3543 | | // Absolute |
| | | 3544 | | else |
| | | 3545 | | { |
| | 12 | 3546 | | if (options.ExpiresOn.HasValue) |
| | | 3547 | | { |
| | 8 | 3548 | | blobExpiryOptions = PathExpiryOptions.Absolute; |
| | 8 | 3549 | | expiresOn = options.ExpiresOn?.ToString("R", CultureInfo.InvariantCulture); |
| | | 3550 | | } |
| | | 3551 | | else |
| | | 3552 | | { |
| | 4 | 3553 | | blobExpiryOptions = PathExpiryOptions.NeverExpire; |
| | | 3554 | | } |
| | | 3555 | | } |
| | | 3556 | | |
| | 24 | 3557 | | Response<PathSetExpiryInternal> response = await DataLakeRestClient.Path.SetExpiryAsync( |
| | 24 | 3558 | | ClientDiagnostics, |
| | 24 | 3559 | | Pipeline, |
| | 24 | 3560 | | BlobUri, |
| | 24 | 3561 | | Version.ToVersionString(), |
| | 24 | 3562 | | blobExpiryOptions, |
| | 24 | 3563 | | expiresOn: expiresOn, |
| | 24 | 3564 | | async: async, |
| | 24 | 3565 | | operationName: $"{nameof(DataLakeFileClient)}.{nameof(ScheduleDeletion)}", |
| | 24 | 3566 | | cancellationToken: cancellationToken).ConfigureAwait(false); |
| | | 3567 | | |
| | 20 | 3568 | | return Response.FromValue( |
| | 20 | 3569 | | new PathInfo |
| | 20 | 3570 | | { |
| | 20 | 3571 | | ETag = response.Value.ETag, |
| | 20 | 3572 | | LastModified = response.Value.LastModified |
| | 20 | 3573 | | }, |
| | 20 | 3574 | | response.GetRawResponse()); |
| | | 3575 | | } |
| | 4 | 3576 | | catch (Exception ex) |
| | | 3577 | | { |
| | | 3578 | | Pipeline.LogException(ex); |
| | 4 | 3579 | | throw; |
| | | 3580 | | } |
| | | 3581 | | finally |
| | | 3582 | | { |
| | | 3583 | | Pipeline.LogMethodExit(nameof(DataLakeFileClient)); |
| | | 3584 | | } |
| | | 3585 | | } |
| | 20 | 3586 | | } |
| | | 3587 | | |
| | | 3588 | | #endregion ScheduleDeletion |
| | | 3589 | | |
| | | 3590 | | #region Query |
| | | 3591 | | /// <summary> |
| | | 3592 | | /// The <see cref="Query"/> API returns the |
| | | 3593 | | /// result of a query against the file. |
| | | 3594 | | /// </summary> |
| | | 3595 | | /// <param name="querySqlExpression"> |
| | | 3596 | | /// The query. |
| | | 3597 | | /// </param> |
| | | 3598 | | /// <param name="options"> |
| | | 3599 | | /// Optional parameters. |
| | | 3600 | | /// </param> |
| | | 3601 | | /// <param name="cancellationToken"> |
| | | 3602 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3603 | | /// notifications that the operation should be cancelled. |
| | | 3604 | | /// </param> |
| | | 3605 | | /// <remarks> |
| | | 3606 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3607 | | /// a failure occurs. |
| | | 3608 | | /// </remarks> |
| | | 3609 | | /// <returns> |
| | | 3610 | | /// A <see cref="Response{FileDownloadInfo}"/>. |
| | | 3611 | | /// </returns> |
| | | 3612 | | public virtual Response<FileDownloadInfo> Query( |
| | | 3613 | | string querySqlExpression, |
| | | 3614 | | DataLakeQueryOptions options = default, |
| | | 3615 | | CancellationToken cancellationToken = default) |
| | | 3616 | | { |
| | 32 | 3617 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Query)}"); |
| | | 3618 | | try |
| | | 3619 | | { |
| | 32 | 3620 | | scope.Start(); |
| | 32 | 3621 | | Response<BlobDownloadInfo> response = _blockBlobClient.Query( |
| | 32 | 3622 | | querySqlExpression, |
| | 32 | 3623 | | options.ToBlobQueryOptions(), |
| | 32 | 3624 | | cancellationToken); |
| | | 3625 | | |
| | 20 | 3626 | | return Response.FromValue( |
| | 20 | 3627 | | response.Value.ToFileDownloadInfo(), |
| | 20 | 3628 | | response.GetRawResponse()); |
| | | 3629 | | } |
| | 12 | 3630 | | catch (Exception ex) |
| | | 3631 | | { |
| | 12 | 3632 | | scope.Failed(ex); |
| | 12 | 3633 | | throw; |
| | | 3634 | | } |
| | | 3635 | | finally |
| | | 3636 | | { |
| | 32 | 3637 | | scope.Dispose(); |
| | 32 | 3638 | | } |
| | 20 | 3639 | | } |
| | | 3640 | | |
| | | 3641 | | /// <summary> |
| | | 3642 | | /// The <see cref="Query"/> API returns the |
| | | 3643 | | /// result of a query against the file. |
| | | 3644 | | /// </summary> |
| | | 3645 | | /// <param name="querySqlExpression"> |
| | | 3646 | | /// The query. |
| | | 3647 | | /// </param> |
| | | 3648 | | /// <param name="options"> |
| | | 3649 | | /// Optional parameters. |
| | | 3650 | | /// </param> |
| | | 3651 | | /// <param name="cancellationToken"> |
| | | 3652 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3653 | | /// notifications that the operation should be cancelled. |
| | | 3654 | | /// </param> |
| | | 3655 | | /// <remarks> |
| | | 3656 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 3657 | | /// a failure occurs. |
| | | 3658 | | /// </remarks> |
| | | 3659 | | /// <returns> |
| | | 3660 | | /// A <see cref="Response{FileDownloadInfo}"/>. |
| | | 3661 | | /// </returns> |
| | | 3662 | | public virtual async Task<Response<FileDownloadInfo>> QueryAsync( |
| | | 3663 | | string querySqlExpression, |
| | | 3664 | | DataLakeQueryOptions options = default, |
| | | 3665 | | CancellationToken cancellationToken = default) |
| | | 3666 | | { |
| | 32 | 3667 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(Query)}"); |
| | | 3668 | | try |
| | | 3669 | | { |
| | 32 | 3670 | | scope.Start(); |
| | 32 | 3671 | | Response<BlobDownloadInfo> response = await _blockBlobClient.QueryAsync( |
| | 32 | 3672 | | querySqlExpression, |
| | 32 | 3673 | | options.ToBlobQueryOptions(), |
| | 32 | 3674 | | cancellationToken) |
| | 32 | 3675 | | .ConfigureAwait(false); |
| | | 3676 | | |
| | 20 | 3677 | | return Response.FromValue( |
| | 20 | 3678 | | response.Value.ToFileDownloadInfo(), |
| | 20 | 3679 | | response.GetRawResponse()); |
| | | 3680 | | } |
| | 12 | 3681 | | catch (Exception ex) |
| | | 3682 | | { |
| | 12 | 3683 | | scope.Failed(ex); |
| | 12 | 3684 | | throw; |
| | | 3685 | | } |
| | | 3686 | | finally |
| | | 3687 | | { |
| | 32 | 3688 | | scope.Dispose(); |
| | | 3689 | | } |
| | 20 | 3690 | | } |
| | | 3691 | | #endregion Query |
| | | 3692 | | |
| | | 3693 | | #region OpenRead |
| | | 3694 | | /// <summary> |
| | | 3695 | | /// Opens a stream for reading from the file. The stream will only download |
| | | 3696 | | /// the file as the stream is read from. |
| | | 3697 | | /// </summary> |
| | | 3698 | | /// <param name="position"> |
| | | 3699 | | /// The position within the file to begin the stream. |
| | | 3700 | | /// Defaults to the beginning of the file. |
| | | 3701 | | /// </param> |
| | | 3702 | | /// <param name="bufferSize"> |
| | | 3703 | | /// The buffer size to use when the stream downloads parts |
| | | 3704 | | /// of the file. Defaults to 1 MB. |
| | | 3705 | | /// </param> |
| | | 3706 | | /// <param name="conditions"> |
| | | 3707 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 3708 | | /// the download of this file. |
| | | 3709 | | /// </param> |
| | | 3710 | | /// <param name="cancellationToken"> |
| | | 3711 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3712 | | /// notifications that the operation should be cancelled. |
| | | 3713 | | /// </param> |
| | | 3714 | | /// <returns> |
| | | 3715 | | /// Returns a stream that will download the file as the stream |
| | | 3716 | | /// is read from. |
| | | 3717 | | /// </returns> |
| | | 3718 | | #pragma warning disable AZC0015 // Unexpected client method return type. |
| | | 3719 | | public virtual Stream OpenRead( |
| | | 3720 | | #pragma warning restore AZC0015 // Unexpected client method return type. |
| | | 3721 | | long position = 0, |
| | | 3722 | | int? bufferSize = default, |
| | | 3723 | | DataLakeRequestConditions conditions = default, |
| | | 3724 | | CancellationToken cancellationToken = default) |
| | | 3725 | | { |
| | 34 | 3726 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(OpenRead)}"); |
| | | 3727 | | try |
| | | 3728 | | { |
| | 34 | 3729 | | scope.Start(); |
| | 34 | 3730 | | return _blockBlobClient.OpenRead( |
| | 34 | 3731 | | position, |
| | 34 | 3732 | | bufferSize, |
| | 34 | 3733 | | conditions.ToBlobRequestConditions(), |
| | 34 | 3734 | | cancellationToken); |
| | | 3735 | | } |
| | 0 | 3736 | | catch (Exception ex) |
| | | 3737 | | { |
| | 0 | 3738 | | scope.Failed(ex); |
| | 0 | 3739 | | throw; |
| | | 3740 | | } |
| | | 3741 | | finally |
| | | 3742 | | { |
| | 34 | 3743 | | scope.Dispose(); |
| | 34 | 3744 | | } |
| | 34 | 3745 | | } |
| | | 3746 | | |
| | | 3747 | | /// <summary> |
| | | 3748 | | /// Opens a stream for reading from the file. The stream will only download |
| | | 3749 | | /// the file as the stream is read from. |
| | | 3750 | | /// </summary> |
| | | 3751 | | /// <param name="allowfileModifications"> |
| | | 3752 | | /// If true, you can continue streaming a blob even if it has been modified. |
| | | 3753 | | /// </param> |
| | | 3754 | | /// <param name="position"> |
| | | 3755 | | /// The position within the file to begin the stream. |
| | | 3756 | | /// Defaults to the beginning of the file. |
| | | 3757 | | /// </param> |
| | | 3758 | | /// <param name="bufferSize"> |
| | | 3759 | | /// The buffer size to use when the stream downloads parts |
| | | 3760 | | /// of the file. Defaults to 1 MB. |
| | | 3761 | | /// </param> |
| | | 3762 | | /// <param name="cancellationToken"> |
| | | 3763 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3764 | | /// notifications that the operation should be cancelled. |
| | | 3765 | | /// </param> |
| | | 3766 | | /// <returns> |
| | | 3767 | | /// Returns a stream that will download the file as the stream |
| | | 3768 | | /// is read from. |
| | | 3769 | | /// </returns> |
| | | 3770 | | #pragma warning disable AZC0015 // Unexpected client method return type. |
| | | 3771 | | public virtual Stream OpenRead( |
| | | 3772 | | #pragma warning restore AZC0015 // Unexpected client method return type. |
| | | 3773 | | bool allowfileModifications, |
| | | 3774 | | long position = 0, |
| | | 3775 | | int? bufferSize = default, |
| | | 3776 | | CancellationToken cancellationToken = default) |
| | 2 | 3777 | | => allowfileModifications ? OpenRead(position, bufferSize, new DataLakeRequestConditions(), cancellation |
| | 2 | 3778 | | : OpenRead(position, bufferSize, null, cancellationToken); |
| | | 3779 | | |
| | | 3780 | | /// <summary> |
| | | 3781 | | /// Opens a stream for reading from the file. The stream will only download |
| | | 3782 | | /// the file as the stream is read from. |
| | | 3783 | | /// </summary> |
| | | 3784 | | /// <param name="position"> |
| | | 3785 | | /// The position within the file to begin the stream. |
| | | 3786 | | /// Defaults to the beginning of the file. |
| | | 3787 | | /// </param> |
| | | 3788 | | /// <param name="bufferSize"> |
| | | 3789 | | /// The buffer size to use when the stream downloads parts |
| | | 3790 | | /// of the file. Defaults to 1 MB. |
| | | 3791 | | /// </param> |
| | | 3792 | | /// <param name="conditions"> |
| | | 3793 | | /// Optional <see cref="DataLakeRequestConditions"/> to add conditions on |
| | | 3794 | | /// the download of the file. |
| | | 3795 | | /// </param> |
| | | 3796 | | /// <param name="cancellationToken"> |
| | | 3797 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3798 | | /// notifications that the operation should be cancelled. |
| | | 3799 | | /// </param> |
| | | 3800 | | /// <returns> |
| | | 3801 | | /// Returns a stream that will download the file as the stream |
| | | 3802 | | /// is read from. |
| | | 3803 | | /// </returns> |
| | | 3804 | | #pragma warning disable AZC0015 // Unexpected client method return type. |
| | | 3805 | | public virtual async Task<Stream> OpenReadAsync( |
| | | 3806 | | #pragma warning restore AZC0015 // Unexpected client method return type. |
| | | 3807 | | long position = 0, |
| | | 3808 | | int? bufferSize = default, |
| | | 3809 | | DataLakeRequestConditions conditions = default, |
| | | 3810 | | CancellationToken cancellationToken = default) |
| | | 3811 | | { |
| | 38 | 3812 | | DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(DataLakeFileClient)}.{nameof(OpenRead)}"); |
| | | 3813 | | try |
| | | 3814 | | { |
| | 38 | 3815 | | scope.Start(); |
| | 38 | 3816 | | return await _blockBlobClient.OpenReadAsync( |
| | 38 | 3817 | | position, |
| | 38 | 3818 | | bufferSize, |
| | 38 | 3819 | | conditions?.ToBlobRequestConditions(), |
| | 38 | 3820 | | cancellationToken).ConfigureAwait(false); |
| | | 3821 | | } |
| | 0 | 3822 | | catch (Exception ex) |
| | | 3823 | | { |
| | 0 | 3824 | | scope.Failed(ex); |
| | 0 | 3825 | | throw; |
| | | 3826 | | } |
| | | 3827 | | finally |
| | | 3828 | | { |
| | 38 | 3829 | | scope.Dispose(); |
| | | 3830 | | } |
| | 38 | 3831 | | } |
| | | 3832 | | |
| | | 3833 | | /// <summary> |
| | | 3834 | | /// Opens a stream for reading from the file. The stream will only download |
| | | 3835 | | /// the file as the stream is read from. |
| | | 3836 | | /// </summary> |
| | | 3837 | | /// <param name="allowfileModifications"> |
| | | 3838 | | /// If true, you can continue streaming a blob even if it has been modified. |
| | | 3839 | | /// </param> |
| | | 3840 | | /// <param name="position"> |
| | | 3841 | | /// The position within the file to begin the stream. |
| | | 3842 | | /// Defaults to the beginning of the file. |
| | | 3843 | | /// </param> |
| | | 3844 | | /// <param name="bufferSize"> |
| | | 3845 | | /// The buffer size to use when the stream downloads parts |
| | | 3846 | | /// of the file. Defaults to 1 MB. |
| | | 3847 | | /// </param> |
| | | 3848 | | /// <param name="cancellationToken"> |
| | | 3849 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 3850 | | /// notifications that the operation should be cancelled. |
| | | 3851 | | /// </param> |
| | | 3852 | | /// <returns> |
| | | 3853 | | /// Returns a stream that will download the file as the stream |
| | | 3854 | | /// is read from. |
| | | 3855 | | /// </returns> |
| | | 3856 | | #pragma warning disable AZC0015 // Unexpected client method return type. |
| | | 3857 | | public virtual async Task<Stream> OpenReadAsync( |
| | | 3858 | | #pragma warning restore AZC0015 // Unexpected client method return type. |
| | | 3859 | | bool allowfileModifications, |
| | | 3860 | | long position = 0, |
| | | 3861 | | int? bufferSize = default, |
| | | 3862 | | CancellationToken cancellationToken = default) |
| | 2 | 3863 | | => await (allowfileModifications ? OpenReadAsync(position, bufferSize, new DataLakeRequestConditions(), |
| | 2 | 3864 | | : OpenReadAsync(position, bufferSize, null, cancellationToken)).ConfigureAwait(false); |
| | | 3865 | | #endregion OpenRead |
| | | 3866 | | |
| | | 3867 | | #region PartitionedUplaoder |
| | | 3868 | | internal PartitionedUploader<DataLakeFileUploadOptions, PathInfo> GetPartitionedUploader( |
| | | 3869 | | StorageTransferOptions transferOptions, |
| | | 3870 | | ArrayPool<byte> arrayPool = null, |
| | | 3871 | | string operationName = null) |
| | 168 | 3872 | | => new PartitionedUploader<DataLakeFileUploadOptions, PathInfo>( |
| | 168 | 3873 | | GetPartitionedUploaderBehaviors(this), |
| | 168 | 3874 | | transferOptions, |
| | 168 | 3875 | | arrayPool, |
| | 168 | 3876 | | operationName); |
| | | 3877 | | |
| | | 3878 | | // static because it makes mocking easier in tests |
| | | 3879 | | internal static PartitionedUploader<DataLakeFileUploadOptions, PathInfo>.Behaviors GetPartitionedUploaderBehavio |
| | 192 | 3880 | | => new PartitionedUploader<DataLakeFileUploadOptions, PathInfo>.Behaviors |
| | 192 | 3881 | | { |
| | 192 | 3882 | | InitializeDestination = async (args, async, cancellationToken) |
| | 384 | 3883 | | => await client.CreateInternal( |
| | 384 | 3884 | | PathResourceType.File, |
| | 384 | 3885 | | args.HttpHeaders, |
| | 384 | 3886 | | args.Metadata, |
| | 384 | 3887 | | args.Permissions, |
| | 384 | 3888 | | args.Umask, |
| | 384 | 3889 | | args.Conditions, |
| | 384 | 3890 | | async, |
| | 384 | 3891 | | cancellationToken).ConfigureAwait(false), |
| | 192 | 3892 | | SingleUpload = async (stream, args, progressHandler, operationName, async, cancellationToken) => |
| | 192 | 3893 | | { |
| | 192 | 3894 | | // After the File is Create, Lease ID is the only valid request parameter. |
| | 352 | 3895 | | if (args?.Conditions != null) |
| | 328 | 3896 | | args.Conditions = new DataLakeRequestConditions { LeaseId = args.Conditions.LeaseId }; |
| | 192 | 3897 | | |
| | 192 | 3898 | | // Append data |
| | 352 | 3899 | | await client.AppendInternal( |
| | 352 | 3900 | | stream, |
| | 352 | 3901 | | offset: 0, |
| | 352 | 3902 | | contentHash: default, |
| | 352 | 3903 | | args.Conditions?.LeaseId, |
| | 352 | 3904 | | progressHandler, |
| | 352 | 3905 | | async, |
| | 352 | 3906 | | cancellationToken).ConfigureAwait(false); |
| | 192 | 3907 | | |
| | 192 | 3908 | | // Flush data |
| | 352 | 3909 | | return await client.FlushInternal( |
| | 352 | 3910 | | position: stream.Length, |
| | 352 | 3911 | | retainUncommittedData: default, |
| | 352 | 3912 | | close: default, |
| | 352 | 3913 | | args.HttpHeaders, |
| | 352 | 3914 | | args.Conditions, |
| | 352 | 3915 | | async, |
| | 352 | 3916 | | cancellationToken) |
| | 352 | 3917 | | .ConfigureAwait(false); |
| | 352 | 3918 | | }, |
| | 192 | 3919 | | UploadPartition = async (stream, offset, args, progressHandler, async, cancellationToken) |
| | 384 | 3920 | | => await client.AppendInternal( |
| | 384 | 3921 | | stream, |
| | 384 | 3922 | | offset, |
| | 384 | 3923 | | contentHash: default, |
| | 384 | 3924 | | args.Conditions.LeaseId, |
| | 384 | 3925 | | progressHandler, |
| | 384 | 3926 | | async, |
| | 384 | 3927 | | cancellationToken).ConfigureAwait(false), |
| | 192 | 3928 | | CommitPartitionedUpload = async (partitions, args, async, cancellationToken) => |
| | 192 | 3929 | | { |
| | 216 | 3930 | | (var offset, var size) = partitions.LastOrDefault(); |
| | 192 | 3931 | | |
| | 192 | 3932 | | // After the File is Create, Lease ID is the only valid request parameter. |
| | 216 | 3933 | | if (args?.Conditions != null) |
| | 216 | 3934 | | args.Conditions = new DataLakeRequestConditions { LeaseId = args.Conditions.LeaseId }; |
| | 192 | 3935 | | |
| | 216 | 3936 | | return await client.FlushInternal( |
| | 216 | 3937 | | offset + size, |
| | 216 | 3938 | | retainUncommittedData: default, |
| | 216 | 3939 | | close: default, |
| | 216 | 3940 | | httpHeaders: args.HttpHeaders, |
| | 216 | 3941 | | conditions: args.Conditions, |
| | 216 | 3942 | | async, |
| | 216 | 3943 | | cancellationToken).ConfigureAwait(false); |
| | 216 | 3944 | | }, |
| | 216 | 3945 | | Scope = operationName => client.ClientDiagnostics.CreateScope(operationName ?? |
| | 216 | 3946 | | $"{nameof(Azure)}.{nameof(Storage)}.{nameof(Files)}.{nameof(DataLake)}.{nameof(DataLakeFileClient)}. |
| | 192 | 3947 | | }; |
| | | 3948 | | #endregion |
| | | 3949 | | } |
| | | 3950 | | } |