forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppendBlobRestClient.cs
More file actions
656 lines (634 loc) · 56.8 KB
/
AppendBlobRestClient.cs
File metadata and controls
656 lines (634 loc) · 56.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Blobs.Models;
namespace Azure.Storage.Blobs
{
internal partial class AppendBlobRestClient
{
private readonly HttpPipeline _pipeline;
private readonly string _url;
private readonly string _version;
/// <summary> The ClientDiagnostics is used to provide tracing support for the client library. </summary>
internal ClientDiagnostics ClientDiagnostics { get; }
/// <summary> Initializes a new instance of AppendBlobRestClient. </summary>
/// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
/// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
/// <param name="url"> The URL of the service account, container, or blob that is the target of the desired operation. </param>
/// <param name="version"> Specifies the version of the operation to use for this request. The default value is "2024-08-04". </param>
/// <exception cref="ArgumentNullException"> <paramref name="clientDiagnostics"/>, <paramref name="pipeline"/>, <paramref name="url"/> or <paramref name="version"/> is null. </exception>
public AppendBlobRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version)
{
ClientDiagnostics = clientDiagnostics ?? throw new ArgumentNullException(nameof(clientDiagnostics));
_pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
_url = url ?? throw new ArgumentNullException(nameof(url));
_version = version ?? throw new ArgumentNullException(nameof(version));
}
internal HttpMessage CreateCreateRequest(long contentLength, int? timeout, string blobContentType, string blobContentEncoding, string blobContentLanguage, byte[] blobContentMD5, string blobCacheControl, IDictionary<string, string> metadata, string leaseId, string blobContentDisposition, string encryptionKey, string encryptionKeySha256, EncryptionAlgorithmTypeInternal? encryptionAlgorithm, string encryptionScope, DateTimeOffset? ifModifiedSince, DateTimeOffset? ifUnmodifiedSince, string ifMatch, string ifNoneMatch, string ifTags, string blobTagsString, DateTimeOffset? immutabilityPolicyExpiry, BlobImmutabilityPolicyMode? immutabilityPolicyMode, bool? legalHold)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(_url, false);
if (timeout != null)
{
uri.AppendQuery("timeout", timeout.Value, true);
}
request.Uri = uri;
request.Headers.Add("x-ms-blob-type", "AppendBlob");
if (blobContentType != null)
{
request.Headers.Add("x-ms-blob-content-type", blobContentType);
}
if (blobContentEncoding != null)
{
request.Headers.Add("x-ms-blob-content-encoding", blobContentEncoding);
}
if (blobContentLanguage != null)
{
request.Headers.Add("x-ms-blob-content-language", blobContentLanguage);
}
if (blobContentMD5 != null)
{
request.Headers.Add("x-ms-blob-content-md5", blobContentMD5, "D");
}
if (blobCacheControl != null)
{
request.Headers.Add("x-ms-blob-cache-control", blobCacheControl);
}
if (metadata != null)
{
request.Headers.Add("x-ms-meta-", metadata);
}
if (leaseId != null)
{
request.Headers.Add("x-ms-lease-id", leaseId);
}
if (blobContentDisposition != null)
{
request.Headers.Add("x-ms-blob-content-disposition", blobContentDisposition);
}
if (encryptionKey != null)
{
request.Headers.Add("x-ms-encryption-key", encryptionKey);
}
if (encryptionKeySha256 != null)
{
request.Headers.Add("x-ms-encryption-key-sha256", encryptionKeySha256);
}
if (encryptionAlgorithm != null)
{
request.Headers.Add("x-ms-encryption-algorithm", encryptionAlgorithm.Value.ToSerialString());
}
if (encryptionScope != null)
{
request.Headers.Add("x-ms-encryption-scope", encryptionScope);
}
if (ifModifiedSince != null)
{
request.Headers.Add("If-Modified-Since", ifModifiedSince.Value, "R");
}
if (ifUnmodifiedSince != null)
{
request.Headers.Add("If-Unmodified-Since", ifUnmodifiedSince.Value, "R");
}
if (ifMatch != null)
{
request.Headers.Add("If-Match", ifMatch);
}
if (ifNoneMatch != null)
{
request.Headers.Add("If-None-Match", ifNoneMatch);
}
if (ifTags != null)
{
request.Headers.Add("x-ms-if-tags", ifTags);
}
request.Headers.Add("x-ms-version", _version);
if (blobTagsString != null)
{
request.Headers.Add("x-ms-tags", blobTagsString);
}
if (immutabilityPolicyExpiry != null)
{
request.Headers.Add("x-ms-immutability-policy-until-date", immutabilityPolicyExpiry.Value, "R");
}
if (immutabilityPolicyMode != null)
{
request.Headers.Add("x-ms-immutability-policy-mode", immutabilityPolicyMode.Value.ToSerialString());
}
if (legalHold != null)
{
request.Headers.Add("x-ms-legal-hold", legalHold.Value);
}
request.Headers.Add("Accept", "application/xml");
return message;
}
/// <summary> The Create Append Blob operation creates a new append blob. </summary>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="blobContentType"> Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentEncoding"> Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentLanguage"> Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentMD5"> Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. </param>
/// <param name="blobCacheControl"> Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="metadata"> Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="blobContentDisposition"> Optional. Sets the blob's Content-Disposition header. </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="blobTagsString"> Optional. Used to set blob tags in various blob operations. </param>
/// <param name="immutabilityPolicyExpiry"> Specifies the date time when the blobs immutability policy is set to expire. </param>
/// <param name="immutabilityPolicyMode"> Specifies the immutability policy mode to set on the blob. </param>
/// <param name="legalHold"> Specified if a legal hold should be set on the blob. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public async Task<ResponseWithHeaders<AppendBlobCreateHeaders>> CreateAsync(long contentLength, int? timeout = null, string blobContentType = null, string blobContentEncoding = null, string blobContentLanguage = null, byte[] blobContentMD5 = null, string blobCacheControl = null, IDictionary<string, string> metadata = null, string leaseId = null, string blobContentDisposition = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, string blobTagsString = null, DateTimeOffset? immutabilityPolicyExpiry = null, BlobImmutabilityPolicyMode? immutabilityPolicyMode = null, bool? legalHold = null, CancellationToken cancellationToken = default)
{
using var message = CreateCreateRequest(contentLength, timeout, blobContentType, blobContentEncoding, blobContentLanguage, blobContentMD5, blobCacheControl, metadata, leaseId, blobContentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
var headers = new AppendBlobCreateHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
/// <summary> The Create Append Blob operation creates a new append blob. </summary>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="blobContentType"> Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentEncoding"> Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentLanguage"> Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="blobContentMD5"> Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. </param>
/// <param name="blobCacheControl"> Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. </param>
/// <param name="metadata"> Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="blobContentDisposition"> Optional. Sets the blob's Content-Disposition header. </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="blobTagsString"> Optional. Used to set blob tags in various blob operations. </param>
/// <param name="immutabilityPolicyExpiry"> Specifies the date time when the blobs immutability policy is set to expire. </param>
/// <param name="immutabilityPolicyMode"> Specifies the immutability policy mode to set on the blob. </param>
/// <param name="legalHold"> Specified if a legal hold should be set on the blob. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public ResponseWithHeaders<AppendBlobCreateHeaders> Create(long contentLength, int? timeout = null, string blobContentType = null, string blobContentEncoding = null, string blobContentLanguage = null, byte[] blobContentMD5 = null, string blobCacheControl = null, IDictionary<string, string> metadata = null, string leaseId = null, string blobContentDisposition = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, string blobTagsString = null, DateTimeOffset? immutabilityPolicyExpiry = null, BlobImmutabilityPolicyMode? immutabilityPolicyMode = null, bool? legalHold = null, CancellationToken cancellationToken = default)
{
using var message = CreateCreateRequest(contentLength, timeout, blobContentType, blobContentEncoding, blobContentLanguage, blobContentMD5, blobCacheControl, metadata, leaseId, blobContentDisposition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, blobTagsString, immutabilityPolicyExpiry, immutabilityPolicyMode, legalHold);
_pipeline.Send(message, cancellationToken);
var headers = new AppendBlobCreateHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
internal HttpMessage CreateAppendBlockRequest(long contentLength, Stream body, int? timeout, byte[] transactionalContentMD5, byte[] transactionalContentCrc64, string leaseId, long? maxSize, long? appendPosition, string encryptionKey, string encryptionKeySha256, EncryptionAlgorithmTypeInternal? encryptionAlgorithm, string encryptionScope, DateTimeOffset? ifModifiedSince, DateTimeOffset? ifUnmodifiedSince, string ifMatch, string ifNoneMatch, string ifTags)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(_url, false);
uri.AppendQuery("comp", "appendblock", true);
if (timeout != null)
{
uri.AppendQuery("timeout", timeout.Value, true);
}
request.Uri = uri;
if (transactionalContentCrc64 != null)
{
request.Headers.Add("x-ms-content-crc64", transactionalContentCrc64, "D");
}
if (leaseId != null)
{
request.Headers.Add("x-ms-lease-id", leaseId);
}
if (maxSize != null)
{
request.Headers.Add("x-ms-blob-condition-maxsize", maxSize.Value);
}
if (appendPosition != null)
{
request.Headers.Add("x-ms-blob-condition-appendpos", appendPosition.Value);
}
if (encryptionKey != null)
{
request.Headers.Add("x-ms-encryption-key", encryptionKey);
}
if (encryptionKeySha256 != null)
{
request.Headers.Add("x-ms-encryption-key-sha256", encryptionKeySha256);
}
if (encryptionAlgorithm != null)
{
request.Headers.Add("x-ms-encryption-algorithm", encryptionAlgorithm.Value.ToSerialString());
}
if (encryptionScope != null)
{
request.Headers.Add("x-ms-encryption-scope", encryptionScope);
}
if (ifModifiedSince != null)
{
request.Headers.Add("If-Modified-Since", ifModifiedSince.Value, "R");
}
if (ifUnmodifiedSince != null)
{
request.Headers.Add("If-Unmodified-Since", ifUnmodifiedSince.Value, "R");
}
if (ifMatch != null)
{
request.Headers.Add("If-Match", ifMatch);
}
if (ifNoneMatch != null)
{
request.Headers.Add("If-None-Match", ifNoneMatch);
}
if (ifTags != null)
{
request.Headers.Add("x-ms-if-tags", ifTags);
}
request.Headers.Add("x-ms-version", _version);
request.Headers.Add("Accept", "application/xml");
request.Headers.Add("Content-Length", contentLength);
if (transactionalContentMD5 != null)
{
request.Headers.Add("Content-MD5", transactionalContentMD5, "D");
}
request.Headers.Add("Content-Type", "application/octet-stream");
request.Content = RequestContent.Create(body);
return message;
}
/// <summary> The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. </summary>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="body"> Initial data. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="transactionalContentMD5"> Specify the transactional md5 for the body, to be validated by the service. </param>
/// <param name="transactionalContentCrc64"> Specify the transactional crc64 for the body, to be validated by the service. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="maxSize"> Optional conditional header. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="body"/> is null. </exception>
public async Task<ResponseWithHeaders<AppendBlobAppendBlockHeaders>> AppendBlockAsync(long contentLength, Stream body, int? timeout = null, byte[] transactionalContentMD5 = null, byte[] transactionalContentCrc64 = null, string leaseId = null, long? maxSize = null, long? appendPosition = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, CancellationToken cancellationToken = default)
{
if (body == null)
{
throw new ArgumentNullException(nameof(body));
}
using var message = CreateAppendBlockRequest(contentLength, body, timeout, transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
var headers = new AppendBlobAppendBlockHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
/// <summary> The Append Block operation commits a new block of data to the end of an existing append blob. The Append Block operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. </summary>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="body"> Initial data. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="transactionalContentMD5"> Specify the transactional md5 for the body, to be validated by the service. </param>
/// <param name="transactionalContentCrc64"> Specify the transactional crc64 for the body, to be validated by the service. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="maxSize"> Optional conditional header. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="body"/> is null. </exception>
public ResponseWithHeaders<AppendBlobAppendBlockHeaders> AppendBlock(long contentLength, Stream body, int? timeout = null, byte[] transactionalContentMD5 = null, byte[] transactionalContentCrc64 = null, string leaseId = null, long? maxSize = null, long? appendPosition = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, CancellationToken cancellationToken = default)
{
if (body == null)
{
throw new ArgumentNullException(nameof(body));
}
using var message = CreateAppendBlockRequest(contentLength, body, timeout, transactionalContentMD5, transactionalContentCrc64, leaseId, maxSize, appendPosition, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags);
_pipeline.Send(message, cancellationToken);
var headers = new AppendBlobAppendBlockHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
internal HttpMessage CreateAppendBlockFromUrlRequest(string sourceUrl, long contentLength, string sourceRange, byte[] sourceContentMD5, byte[] sourceContentcrc64, int? timeout, byte[] transactionalContentMD5, string encryptionKey, string encryptionKeySha256, EncryptionAlgorithmTypeInternal? encryptionAlgorithm, string encryptionScope, string leaseId, long? maxSize, long? appendPosition, DateTimeOffset? ifModifiedSince, DateTimeOffset? ifUnmodifiedSince, string ifMatch, string ifNoneMatch, string ifTags, DateTimeOffset? sourceIfModifiedSince, DateTimeOffset? sourceIfUnmodifiedSince, string sourceIfMatch, string sourceIfNoneMatch, string copySourceAuthorization)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(_url, false);
uri.AppendQuery("comp", "appendblock", true);
if (timeout != null)
{
uri.AppendQuery("timeout", timeout.Value, true);
}
request.Uri = uri;
request.Headers.Add("x-ms-copy-source", sourceUrl);
if (sourceRange != null)
{
request.Headers.Add("x-ms-source-range", sourceRange);
}
if (sourceContentMD5 != null)
{
request.Headers.Add("x-ms-source-content-md5", sourceContentMD5, "D");
}
if (sourceContentcrc64 != null)
{
request.Headers.Add("x-ms-source-content-crc64", sourceContentcrc64, "D");
}
if (encryptionKey != null)
{
request.Headers.Add("x-ms-encryption-key", encryptionKey);
}
if (encryptionKeySha256 != null)
{
request.Headers.Add("x-ms-encryption-key-sha256", encryptionKeySha256);
}
if (encryptionAlgorithm != null)
{
request.Headers.Add("x-ms-encryption-algorithm", encryptionAlgorithm.Value.ToSerialString());
}
if (encryptionScope != null)
{
request.Headers.Add("x-ms-encryption-scope", encryptionScope);
}
if (leaseId != null)
{
request.Headers.Add("x-ms-lease-id", leaseId);
}
if (maxSize != null)
{
request.Headers.Add("x-ms-blob-condition-maxsize", maxSize.Value);
}
if (appendPosition != null)
{
request.Headers.Add("x-ms-blob-condition-appendpos", appendPosition.Value);
}
if (ifModifiedSince != null)
{
request.Headers.Add("If-Modified-Since", ifModifiedSince.Value, "R");
}
if (ifUnmodifiedSince != null)
{
request.Headers.Add("If-Unmodified-Since", ifUnmodifiedSince.Value, "R");
}
if (ifMatch != null)
{
request.Headers.Add("If-Match", ifMatch);
}
if (ifNoneMatch != null)
{
request.Headers.Add("If-None-Match", ifNoneMatch);
}
if (ifTags != null)
{
request.Headers.Add("x-ms-if-tags", ifTags);
}
if (sourceIfModifiedSince != null)
{
request.Headers.Add("x-ms-source-if-modified-since", sourceIfModifiedSince.Value, "R");
}
if (sourceIfUnmodifiedSince != null)
{
request.Headers.Add("x-ms-source-if-unmodified-since", sourceIfUnmodifiedSince.Value, "R");
}
if (sourceIfMatch != null)
{
request.Headers.Add("x-ms-source-if-match", sourceIfMatch);
}
if (sourceIfNoneMatch != null)
{
request.Headers.Add("x-ms-source-if-none-match", sourceIfNoneMatch);
}
request.Headers.Add("x-ms-version", _version);
if (copySourceAuthorization != null)
{
request.Headers.Add("x-ms-copy-source-authorization", copySourceAuthorization);
}
request.Headers.Add("Accept", "application/xml");
return message;
}
/// <summary> The Append Block operation commits a new block of data to the end of an existing append blob where the contents are read from a source url. The Append Block operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. </summary>
/// <param name="sourceUrl"> Specify a URL to the copy source. </param>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="sourceRange"> Bytes of source data in the specified range. </param>
/// <param name="sourceContentMD5"> Specify the md5 calculated for the range of bytes that must be read from the copy source. </param>
/// <param name="sourceContentcrc64"> Specify the crc64 calculated for the range of bytes that must be read from the copy source. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="transactionalContentMD5"> Specify the transactional md5 for the body, to be validated by the service. </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="maxSize"> Optional conditional header. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="sourceIfModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="sourceIfUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="sourceIfMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="sourceIfNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="copySourceAuthorization"> Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="sourceUrl"/> is null. </exception>
public async Task<ResponseWithHeaders<AppendBlobAppendBlockFromUrlHeaders>> AppendBlockFromUrlAsync(string sourceUrl, long contentLength, string sourceRange = null, byte[] sourceContentMD5 = null, byte[] sourceContentcrc64 = null, int? timeout = null, byte[] transactionalContentMD5 = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, string leaseId = null, long? maxSize = null, long? appendPosition = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, DateTimeOffset? sourceIfModifiedSince = null, DateTimeOffset? sourceIfUnmodifiedSince = null, string sourceIfMatch = null, string sourceIfNoneMatch = null, string copySourceAuthorization = null, CancellationToken cancellationToken = default)
{
if (sourceUrl == null)
{
throw new ArgumentNullException(nameof(sourceUrl));
}
using var message = CreateAppendBlockFromUrlRequest(sourceUrl, contentLength, sourceRange, sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, copySourceAuthorization);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
var headers = new AppendBlobAppendBlockFromUrlHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
/// <summary> The Append Block operation commits a new block of data to the end of an existing append blob where the contents are read from a source url. The Append Block operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. </summary>
/// <param name="sourceUrl"> Specify a URL to the copy source. </param>
/// <param name="contentLength"> The length of the request. </param>
/// <param name="sourceRange"> Bytes of source data in the specified range. </param>
/// <param name="sourceContentMD5"> Specify the md5 calculated for the range of bytes that must be read from the copy source. </param>
/// <param name="sourceContentcrc64"> Specify the crc64 calculated for the range of bytes that must be read from the copy source. </param>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="transactionalContentMD5"> Specify the transactional md5 for the body, to be validated by the service. </param>
/// <param name="encryptionKey"> Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="encryptionKeySha256"> The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionAlgorithm"> The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. </param>
/// <param name="encryptionScope"> Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="maxSize"> Optional conditional header. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="ifTags"> Specify a SQL where clause on blob tags to operate only on blobs with a matching value. </param>
/// <param name="sourceIfModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="sourceIfUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="sourceIfMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="sourceIfNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="copySourceAuthorization"> Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="sourceUrl"/> is null. </exception>
public ResponseWithHeaders<AppendBlobAppendBlockFromUrlHeaders> AppendBlockFromUrl(string sourceUrl, long contentLength, string sourceRange = null, byte[] sourceContentMD5 = null, byte[] sourceContentcrc64 = null, int? timeout = null, byte[] transactionalContentMD5 = null, string encryptionKey = null, string encryptionKeySha256 = null, EncryptionAlgorithmTypeInternal? encryptionAlgorithm = null, string encryptionScope = null, string leaseId = null, long? maxSize = null, long? appendPosition = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, string ifTags = null, DateTimeOffset? sourceIfModifiedSince = null, DateTimeOffset? sourceIfUnmodifiedSince = null, string sourceIfMatch = null, string sourceIfNoneMatch = null, string copySourceAuthorization = null, CancellationToken cancellationToken = default)
{
if (sourceUrl == null)
{
throw new ArgumentNullException(nameof(sourceUrl));
}
using var message = CreateAppendBlockFromUrlRequest(sourceUrl, contentLength, sourceRange, sourceContentMD5, sourceContentcrc64, timeout, transactionalContentMD5, encryptionKey, encryptionKeySha256, encryptionAlgorithm, encryptionScope, leaseId, maxSize, appendPosition, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, ifTags, sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatch, sourceIfNoneMatch, copySourceAuthorization);
_pipeline.Send(message, cancellationToken);
var headers = new AppendBlobAppendBlockFromUrlHeaders(message.Response);
switch (message.Response.Status)
{
case 201:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
internal HttpMessage CreateSealRequest(int? timeout, string leaseId, DateTimeOffset? ifModifiedSince, DateTimeOffset? ifUnmodifiedSince, string ifMatch, string ifNoneMatch, long? appendPosition)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(_url, false);
uri.AppendQuery("comp", "seal", true);
if (timeout != null)
{
uri.AppendQuery("timeout", timeout.Value, true);
}
request.Uri = uri;
request.Headers.Add("x-ms-version", _version);
if (leaseId != null)
{
request.Headers.Add("x-ms-lease-id", leaseId);
}
if (ifModifiedSince != null)
{
request.Headers.Add("If-Modified-Since", ifModifiedSince.Value, "R");
}
if (ifUnmodifiedSince != null)
{
request.Headers.Add("If-Unmodified-Since", ifUnmodifiedSince.Value, "R");
}
if (ifMatch != null)
{
request.Headers.Add("If-Match", ifMatch);
}
if (ifNoneMatch != null)
{
request.Headers.Add("If-None-Match", ifNoneMatch);
}
if (appendPosition != null)
{
request.Headers.Add("x-ms-blob-condition-appendpos", appendPosition.Value);
}
request.Headers.Add("Accept", "application/xml");
return message;
}
/// <summary> The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 version or later. </summary>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public async Task<ResponseWithHeaders<AppendBlobSealHeaders>> SealAsync(int? timeout = null, string leaseId = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, long? appendPosition = null, CancellationToken cancellationToken = default)
{
using var message = CreateSealRequest(timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
var headers = new AppendBlobSealHeaders(message.Response);
switch (message.Response.Status)
{
case 200:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
/// <summary> The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 version or later. </summary>
/// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting Timeouts for Blob Service Operations.</a>. </param>
/// <param name="leaseId"> If specified, the operation only succeeds if the resource's lease is active and matches this ID. </param>
/// <param name="ifModifiedSince"> Specify this header value to operate only on a blob if it has been modified since the specified date/time. </param>
/// <param name="ifUnmodifiedSince"> Specify this header value to operate only on a blob if it has not been modified since the specified date/time. </param>
/// <param name="ifMatch"> Specify an ETag value to operate only on blobs with a matching value. </param>
/// <param name="ifNoneMatch"> Specify an ETag value to operate only on blobs without a matching value. </param>
/// <param name="appendPosition"> Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed). </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public ResponseWithHeaders<AppendBlobSealHeaders> Seal(int? timeout = null, string leaseId = null, DateTimeOffset? ifModifiedSince = null, DateTimeOffset? ifUnmodifiedSince = null, string ifMatch = null, string ifNoneMatch = null, long? appendPosition = null, CancellationToken cancellationToken = default)
{
using var message = CreateSealRequest(timeout, leaseId, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch, appendPosition);
_pipeline.Send(message, cancellationToken);
var headers = new AppendBlobSealHeaders(message.Response);
switch (message.Response.Status)
{
case 200:
return ResponseWithHeaders.FromValue(headers, message.Response);
default:
throw new RequestFailedException(message.Response);
}
}
}
}