@azure/storage-blob 12.9.1-alpha.20220407.2 → 12.9.1-alpha.20220418.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/index.js +437 -5
- package/dist/index.js.map +1 -1
- package/dist-esm/storage-blob/src/Clients.js +372 -6
- package/dist-esm/storage-blob/src/Clients.js.map +1 -1
- package/dist-esm/storage-blob/src/ContainerClient.js.map +1 -1
- package/dist-esm/storage-blob/src/PageBlobRangeResponse.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/models/mappers.js +7 -0
- package/dist-esm/storage-blob/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/models/parameters.js +11 -0
- package/dist-esm/storage-blob/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/operations/blob.js +2 -1
- package/dist-esm/storage-blob/src/generated/src/operations/blob.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/operations/blockBlob.js +1 -0
- package/dist-esm/storage-blob/src/generated/src/operations/blockBlob.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/operations/pageBlob.js +4 -0
- package/dist-esm/storage-blob/src/generated/src/operations/pageBlob.js.map +1 -1
- package/dist-esm/storage-blob/src/generatedModels.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/constants.js +1 -0
- package/dist-esm/storage-blob/src/utils/constants.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/utils.common.js +42 -0
- package/dist-esm/storage-blob/src/utils/utils.common.js.map +1 -1
- package/package.json +4 -1
- package/types/3.1/storage-blob.d.ts +330 -1
- package/types/latest/storage-blob.d.ts +340 -1
@@ -1,3 +1,4 @@
|
|
1
|
+
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
1
2
|
import { generateUuid, getDefaultProxySettings, isNode, isTokenCredential, URLBuilder, } from "@azure/core-http";
|
2
3
|
import { SpanStatusCode } from "@azure/core-tracing";
|
3
4
|
import { BlobDownloadResponse } from "./BlobDownloadResponse";
|
@@ -13,9 +14,9 @@ import { rangeToString } from "./Range";
|
|
13
14
|
import { StorageClient } from "./StorageClient";
|
14
15
|
import { Batch } from "./utils/Batch";
|
15
16
|
import { BufferScheduler } from "../../storage-common/src";
|
16
|
-
import { BlobUsesCustomerSpecifiedEncryptionMsg, BLOCK_BLOB_MAX_BLOCKS, BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES, BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES, DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES, DEFAULT_BLOCK_BUFFER_SIZE_BYTES, DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, ETagAny, URLConstants, } from "./utils/constants";
|
17
|
+
import { BlobDoesNotUseCustomerSpecifiedEncryption, BlobUsesCustomerSpecifiedEncryptionMsg, BLOCK_BLOB_MAX_BLOCKS, BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES, BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES, DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES, DEFAULT_BLOCK_BUFFER_SIZE_BYTES, DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, ETagAny, URLConstants, } from "./utils/constants";
|
17
18
|
import { createSpan, convertTracingToRequestOptionsBase } from "./utils/tracing";
|
18
|
-
import { appendToURLPath, appendToURLQuery, extractConnectionStringParts, generateBlockID, getURLParameter, httpAuthorizationToString, isIpEndpointStyle, parseObjectReplicationRecord, setURLParameter, toBlobTags, toBlobTagsString, toQuerySerialization, toTags, } from "./utils/utils.common";
|
19
|
+
import { appendToURLPath, appendToURLQuery, extractConnectionStringParts, ExtractPageRangeInfoItems, generateBlockID, getURLParameter, httpAuthorizationToString, isIpEndpointStyle, parseObjectReplicationRecord, setURLParameter, toBlobTags, toBlobTagsString, toQuerySerialization, toTags, } from "./utils/utils.common";
|
19
20
|
import { fsCreateReadStream, fsStat, readStreamToLocalFile, streamToBuffer, } from "./utils/utils.node";
|
20
21
|
import { generateBlobSASQueryParameters } from "./sas/BlobSASSignatureValues";
|
21
22
|
import { BlobLeaseClient } from "./BlobLeaseClient";
|
@@ -305,7 +306,8 @@ export class BlobClient extends StorageClient {
|
|
305
306
|
return false;
|
306
307
|
}
|
307
308
|
else if (e.statusCode === 409 &&
|
308
|
-
e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg
|
309
|
+
(e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg ||
|
310
|
+
e.details.errorCode === BlobDoesNotUseCustomerSpecifiedEncryption)) {
|
309
311
|
// Expected exception when checking blob existence
|
310
312
|
return true;
|
311
313
|
}
|
@@ -718,7 +720,7 @@ export class BlobClient extends StorageClient {
|
|
718
720
|
sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
|
719
721
|
sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
|
720
722
|
sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
|
721
|
-
}, sourceContentMD5: options.sourceContentMD5, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), blobTagsString: toBlobTagsString(options.tags), immutabilityPolicyExpiry: (_b = options.immutabilityPolicy) === null || _b === void 0 ? void 0 : _b.expiriesOn, immutabilityPolicyMode: (_c = options.immutabilityPolicy) === null || _c === void 0 ? void 0 : _c.policyMode, legalHold: options.legalHold, encryptionScope: options.encryptionScope }, convertTracingToRequestOptionsBase(updatedOptions)));
|
723
|
+
}, sourceContentMD5: options.sourceContentMD5, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), blobTagsString: toBlobTagsString(options.tags), immutabilityPolicyExpiry: (_b = options.immutabilityPolicy) === null || _b === void 0 ? void 0 : _b.expiriesOn, immutabilityPolicyMode: (_c = options.immutabilityPolicy) === null || _c === void 0 ? void 0 : _c.policyMode, legalHold: options.legalHold, encryptionScope: options.encryptionScope, copySourceTags: options.copySourceTags }, convertTracingToRequestOptionsBase(updatedOptions)));
|
722
724
|
}
|
723
725
|
catch (e) {
|
724
726
|
span.setStatus({
|
@@ -1441,12 +1443,13 @@ export class BlockBlobClient extends BlobClient {
|
|
1441
1443
|
if (!isNode) {
|
1442
1444
|
throw new Error("This operation currently is only supported in Node.js.");
|
1443
1445
|
}
|
1446
|
+
ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
|
1444
1447
|
const response = await this._blobContext.query(Object.assign({ abortSignal: options.abortSignal, queryRequest: {
|
1445
1448
|
queryType: "SQL",
|
1446
1449
|
expression: query,
|
1447
1450
|
inputSerialization: toQuerySerialization(options.inputTextConfiguration),
|
1448
1451
|
outputSerialization: toQuerySerialization(options.outputTextConfiguration),
|
1449
|
-
}, leaseAccessConditions: options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }) }, convertTracingToRequestOptionsBase(updatedOptions)));
|
1452
|
+
}, leaseAccessConditions: options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }), cpkInfo: options.customerProvidedKey }, convertTracingToRequestOptionsBase(updatedOptions)));
|
1450
1453
|
return new BlobQueryResponse(response, {
|
1451
1454
|
abortSignal: options.abortSignal,
|
1452
1455
|
onProgress: options.onProgress,
|
@@ -1542,7 +1545,7 @@ export class BlockBlobClient extends BlobClient {
|
|
1542
1545
|
sourceIfNoneMatch: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch,
|
1543
1546
|
sourceIfUnmodifiedSince: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifUnmodifiedSince,
|
1544
1547
|
sourceIfTags: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.tagConditions,
|
1545
|
-
}, cpkInfo: options.customerProvidedKey, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags) }), convertTracingToRequestOptionsBase(updatedOptions)));
|
1548
|
+
}, cpkInfo: options.customerProvidedKey, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), copySourceTags: options.copySourceTags }), convertTracingToRequestOptionsBase(updatedOptions)));
|
1546
1549
|
}
|
1547
1550
|
catch (e) {
|
1548
1551
|
span.setStatus({
|
@@ -2238,6 +2241,183 @@ export class PageBlobClient extends BlobClient {
|
|
2238
2241
|
span.end();
|
2239
2242
|
}
|
2240
2243
|
}
|
2244
|
+
/**
|
2245
|
+
* getPageRangesSegment returns a single segment of page ranges starting from the
|
2246
|
+
* specified Marker. Use an empty Marker to start enumeration from the beginning.
|
2247
|
+
* After getting a segment, process it, and then call getPageRangesSegment again
|
2248
|
+
* (passing the the previously-returned Marker) to get the next segment.
|
2249
|
+
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|
2250
|
+
*
|
2251
|
+
* @param offset - Starting byte position of the page ranges.
|
2252
|
+
* @param count - Number of bytes to get.
|
2253
|
+
* @param marker - A string value that identifies the portion of the list to be returned with the next list operation.
|
2254
|
+
* @param options - Options to PageBlob Get Page Ranges Segment operation.
|
2255
|
+
*/
|
2256
|
+
async listPageRangesSegment(offset = 0, count, marker, options = {}) {
|
2257
|
+
var _a;
|
2258
|
+
const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesSegment", options);
|
2259
|
+
try {
|
2260
|
+
return await this.pageBlobContext.getPageRanges(Object.assign({ abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }), range: rangeToString({ offset, count }), marker: marker, maxPageSize: options.maxPageSize }, convertTracingToRequestOptionsBase(updatedOptions)));
|
2261
|
+
}
|
2262
|
+
catch (e) {
|
2263
|
+
span.setStatus({
|
2264
|
+
code: SpanStatusCode.ERROR,
|
2265
|
+
message: e.message,
|
2266
|
+
});
|
2267
|
+
throw e;
|
2268
|
+
}
|
2269
|
+
finally {
|
2270
|
+
span.end();
|
2271
|
+
}
|
2272
|
+
}
|
2273
|
+
/**
|
2274
|
+
* Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesResponseModel}
|
2275
|
+
*
|
2276
|
+
* @param offset - Starting byte position of the page ranges.
|
2277
|
+
* @param count - Number of bytes to get.
|
2278
|
+
* @param marker - A string value that identifies the portion of
|
2279
|
+
* the get of page ranges to be returned with the next getting operation. The
|
2280
|
+
* operation returns the ContinuationToken value within the response body if the
|
2281
|
+
* getting operation did not return all page ranges remaining within the current page.
|
2282
|
+
* The ContinuationToken value can be used as the value for
|
2283
|
+
* the marker parameter in a subsequent call to request the next page of get
|
2284
|
+
* items. The marker value is opaque to the client.
|
2285
|
+
* @param options - Options to List Page Ranges operation.
|
2286
|
+
*/
|
2287
|
+
listPageRangeItemSegments(offset = 0, count, marker, options = {}) {
|
2288
|
+
return __asyncGenerator(this, arguments, function* listPageRangeItemSegments_1() {
|
2289
|
+
let getPageRangeItemSegmentsResponse;
|
2290
|
+
if (!!marker || marker === undefined) {
|
2291
|
+
do {
|
2292
|
+
getPageRangeItemSegmentsResponse = yield __await(this.listPageRangesSegment(offset, count, marker, options));
|
2293
|
+
marker = getPageRangeItemSegmentsResponse.continuationToken;
|
2294
|
+
yield yield __await(yield __await(getPageRangeItemSegmentsResponse));
|
2295
|
+
} while (marker);
|
2296
|
+
}
|
2297
|
+
});
|
2298
|
+
}
|
2299
|
+
/**
|
2300
|
+
* Returns an AsyncIterableIterator of {@link PageRangeInfo} objects
|
2301
|
+
*
|
2302
|
+
* @param offset - Starting byte position of the page ranges.
|
2303
|
+
* @param count - Number of bytes to get.
|
2304
|
+
* @param options - Options to List Page Ranges operation.
|
2305
|
+
*/
|
2306
|
+
listPageRangeItems(offset = 0, count, options = {}) {
|
2307
|
+
return __asyncGenerator(this, arguments, function* listPageRangeItems_1() {
|
2308
|
+
var e_1, _a;
|
2309
|
+
let marker;
|
2310
|
+
try {
|
2311
|
+
for (var _b = __asyncValues(this.listPageRangeItemSegments(offset, count, marker, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
|
2312
|
+
const getPageRangesSegment = _c.value;
|
2313
|
+
yield __await(yield* __asyncDelegator(__asyncValues(ExtractPageRangeInfoItems(getPageRangesSegment))));
|
2314
|
+
}
|
2315
|
+
}
|
2316
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
2317
|
+
finally {
|
2318
|
+
try {
|
2319
|
+
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
|
2320
|
+
}
|
2321
|
+
finally { if (e_1) throw e_1.error; }
|
2322
|
+
}
|
2323
|
+
});
|
2324
|
+
}
|
2325
|
+
/**
|
2326
|
+
* Returns an async iterable iterator to list of page ranges for a page blob.
|
2327
|
+
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|
2328
|
+
*
|
2329
|
+
* .byPage() returns an async iterable iterator to list of page ranges for a page blob.
|
2330
|
+
*
|
2331
|
+
* Example using `for await` syntax:
|
2332
|
+
*
|
2333
|
+
* ```js
|
2334
|
+
* // Get the pageBlobClient before you run these snippets,
|
2335
|
+
* // Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
|
2336
|
+
* let i = 1;
|
2337
|
+
* for await (const pageRange of pageBlobClient.listPageRanges()) {
|
2338
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2339
|
+
* }
|
2340
|
+
* ```
|
2341
|
+
*
|
2342
|
+
* Example using `iter.next()`:
|
2343
|
+
*
|
2344
|
+
* ```js
|
2345
|
+
* let i = 1;
|
2346
|
+
* let iter = pageBlobClient.listPageRanges();
|
2347
|
+
* let pageRangeItem = await iter.next();
|
2348
|
+
* while (!pageRangeItem.done) {
|
2349
|
+
* console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
|
2350
|
+
* pageRangeItem = await iter.next();
|
2351
|
+
* }
|
2352
|
+
* ```
|
2353
|
+
*
|
2354
|
+
* Example using `byPage()`:
|
2355
|
+
*
|
2356
|
+
* ```js
|
2357
|
+
* // passing optional maxPageSize in the page settings
|
2358
|
+
* let i = 1;
|
2359
|
+
* for await (const response of pageBlobClient.listPageRanges().byPage({ maxPageSize: 20 })) {
|
2360
|
+
* for (const pageRange of response) {
|
2361
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2362
|
+
* }
|
2363
|
+
* }
|
2364
|
+
* ```
|
2365
|
+
*
|
2366
|
+
* Example using paging with a marker:
|
2367
|
+
*
|
2368
|
+
* ```js
|
2369
|
+
* let i = 1;
|
2370
|
+
* let iterator = pageBlobClient.listPageRanges().byPage({ maxPageSize: 2 });
|
2371
|
+
* let response = (await iterator.next()).value;
|
2372
|
+
*
|
2373
|
+
* // Prints 2 page ranges
|
2374
|
+
* for (const pageRange of response) {
|
2375
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2376
|
+
* }
|
2377
|
+
*
|
2378
|
+
* // Gets next marker
|
2379
|
+
* let marker = response.continuationToken;
|
2380
|
+
*
|
2381
|
+
* // Passing next marker as continuationToken
|
2382
|
+
*
|
2383
|
+
* iterator = pageBlobClient.listPageRanges().byPage({ continuationToken: marker, maxPageSize: 10 });
|
2384
|
+
* response = (await iterator.next()).value;
|
2385
|
+
*
|
2386
|
+
* // Prints 10 page ranges
|
2387
|
+
* for (const blob of response) {
|
2388
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2389
|
+
* }
|
2390
|
+
* ```
|
2391
|
+
* @param offset - Starting byte position of the page ranges.
|
2392
|
+
* @param count - Number of bytes to get.
|
2393
|
+
* @param options - Options to the Page Blob Get Ranges operation.
|
2394
|
+
* @returns An asyncIterableIterator that supports paging.
|
2395
|
+
*/
|
2396
|
+
listPageRanges(offset = 0, count, options = {}) {
|
2397
|
+
options.conditions = options.conditions || {};
|
2398
|
+
// AsyncIterableIterator to iterate over blobs
|
2399
|
+
const iter = this.listPageRangeItems(offset, count, options);
|
2400
|
+
return {
|
2401
|
+
/**
|
2402
|
+
* The next method, part of the iteration protocol
|
2403
|
+
*/
|
2404
|
+
next() {
|
2405
|
+
return iter.next();
|
2406
|
+
},
|
2407
|
+
/**
|
2408
|
+
* The connection to the async iterator, part of the iteration protocol
|
2409
|
+
*/
|
2410
|
+
[Symbol.asyncIterator]() {
|
2411
|
+
return this;
|
2412
|
+
},
|
2413
|
+
/**
|
2414
|
+
* Return an AsyncIterableIterator that works a page at a time
|
2415
|
+
*/
|
2416
|
+
byPage: (settings = {}) => {
|
2417
|
+
return this.listPageRangeItemSegments(offset, count, settings.continuationToken, Object.assign({ maxPageSize: settings.maxPageSize }, options));
|
2418
|
+
},
|
2419
|
+
};
|
2420
|
+
}
|
2241
2421
|
/**
|
2242
2422
|
* Gets the collection of page ranges that differ between a specified snapshot and this page blob.
|
2243
2423
|
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|
@@ -2268,6 +2448,192 @@ export class PageBlobClient extends BlobClient {
|
|
2268
2448
|
span.end();
|
2269
2449
|
}
|
2270
2450
|
}
|
2451
|
+
/**
|
2452
|
+
* getPageRangesDiffSegment returns a single segment of page ranges starting from the
|
2453
|
+
* specified Marker for difference between previous snapshot and the target page blob.
|
2454
|
+
* Use an empty Marker to start enumeration from the beginning.
|
2455
|
+
* After getting a segment, process it, and then call getPageRangesDiffSegment again
|
2456
|
+
* (passing the the previously-returned Marker) to get the next segment.
|
2457
|
+
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|
2458
|
+
*
|
2459
|
+
* @param offset - Starting byte position of the page ranges.
|
2460
|
+
* @param count - Number of bytes to get.
|
2461
|
+
* @param prevSnapshotOrUrl - Timestamp of snapshot to retrieve the difference or URL of snapshot to retrieve the difference.
|
2462
|
+
* @param marker - A string value that identifies the portion of the get to be returned with the next get operation.
|
2463
|
+
* @param options - Options to the Page Blob Get Page Ranges Diff operation.
|
2464
|
+
*/
|
2465
|
+
async listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options) {
|
2466
|
+
var _a;
|
2467
|
+
const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiffSegment", options);
|
2468
|
+
try {
|
2469
|
+
return await this.pageBlobContext.getPageRangesDiff(Object.assign({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal, leaseAccessConditions: options === null || options === void 0 ? void 0 : options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.conditions), { ifTags: (_a = options === null || options === void 0 ? void 0 : options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }), prevsnapshot: prevSnapshotOrUrl, range: rangeToString({
|
2470
|
+
offset: offset,
|
2471
|
+
count: count,
|
2472
|
+
}), marker: marker, maxPageSize: options === null || options === void 0 ? void 0 : options.maxPageSize }, convertTracingToRequestOptionsBase(updatedOptions)));
|
2473
|
+
}
|
2474
|
+
catch (e) {
|
2475
|
+
span.setStatus({
|
2476
|
+
code: SpanStatusCode.ERROR,
|
2477
|
+
message: e.message,
|
2478
|
+
});
|
2479
|
+
throw e;
|
2480
|
+
}
|
2481
|
+
finally {
|
2482
|
+
span.end();
|
2483
|
+
}
|
2484
|
+
}
|
2485
|
+
/**
|
2486
|
+
* Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesDiffResponseModel}
|
2487
|
+
*
|
2488
|
+
*
|
2489
|
+
* @param offset - Starting byte position of the page ranges.
|
2490
|
+
* @param count - Number of bytes to get.
|
2491
|
+
* @param prevSnapshotOrUrl - Timestamp of snapshot to retrieve the difference or URL of snapshot to retrieve the difference.
|
2492
|
+
* @param marker - A string value that identifies the portion of
|
2493
|
+
* the get of page ranges to be returned with the next getting operation. The
|
2494
|
+
* operation returns the ContinuationToken value within the response body if the
|
2495
|
+
* getting operation did not return all page ranges remaining within the current page.
|
2496
|
+
* The ContinuationToken value can be used as the value for
|
2497
|
+
* the marker parameter in a subsequent call to request the next page of get
|
2498
|
+
* items. The marker value is opaque to the client.
|
2499
|
+
* @param options - Options to the Page Blob Get Page Ranges Diff operation.
|
2500
|
+
*/
|
2501
|
+
listPageRangeDiffItemSegments(offset, count, prevSnapshotOrUrl, marker, options) {
|
2502
|
+
return __asyncGenerator(this, arguments, function* listPageRangeDiffItemSegments_1() {
|
2503
|
+
let getPageRangeItemSegmentsResponse;
|
2504
|
+
if (!!marker || marker === undefined) {
|
2505
|
+
do {
|
2506
|
+
getPageRangeItemSegmentsResponse = yield __await(this.listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options));
|
2507
|
+
marker = getPageRangeItemSegmentsResponse.continuationToken;
|
2508
|
+
yield yield __await(yield __await(getPageRangeItemSegmentsResponse));
|
2509
|
+
} while (marker);
|
2510
|
+
}
|
2511
|
+
});
|
2512
|
+
}
|
2513
|
+
/**
|
2514
|
+
* Returns an AsyncIterableIterator of {@link PageRangeInfo} objects
|
2515
|
+
*
|
2516
|
+
* @param offset - Starting byte position of the page ranges.
|
2517
|
+
* @param count - Number of bytes to get.
|
2518
|
+
* @param prevSnapshotOrUrl - Timestamp of snapshot to retrieve the difference or URL of snapshot to retrieve the difference.
|
2519
|
+
* @param options - Options to the Page Blob Get Page Ranges Diff operation.
|
2520
|
+
*/
|
2521
|
+
listPageRangeDiffItems(offset, count, prevSnapshotOrUrl, options) {
|
2522
|
+
return __asyncGenerator(this, arguments, function* listPageRangeDiffItems_1() {
|
2523
|
+
var e_2, _a;
|
2524
|
+
let marker;
|
2525
|
+
try {
|
2526
|
+
for (var _b = __asyncValues(this.listPageRangeDiffItemSegments(offset, count, prevSnapshotOrUrl, marker, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
|
2527
|
+
const getPageRangesSegment = _c.value;
|
2528
|
+
yield __await(yield* __asyncDelegator(__asyncValues(ExtractPageRangeInfoItems(getPageRangesSegment))));
|
2529
|
+
}
|
2530
|
+
}
|
2531
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
2532
|
+
finally {
|
2533
|
+
try {
|
2534
|
+
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
|
2535
|
+
}
|
2536
|
+
finally { if (e_2) throw e_2.error; }
|
2537
|
+
}
|
2538
|
+
});
|
2539
|
+
}
|
2540
|
+
/**
|
2541
|
+
* Returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
|
2542
|
+
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|
2543
|
+
*
|
2544
|
+
* .byPage() returns an async iterable iterator to list of page ranges that differ between a specified snapshot and this page blob.
|
2545
|
+
*
|
2546
|
+
* Example using `for await` syntax:
|
2547
|
+
*
|
2548
|
+
* ```js
|
2549
|
+
* // Get the pageBlobClient before you run these snippets,
|
2550
|
+
* // Can be obtained from `blobServiceClient.getContainerClient("<your-container-name>").getPageBlobClient("<your-blob-name>");`
|
2551
|
+
* let i = 1;
|
2552
|
+
* for await (const pageRange of pageBlobClient.listPageRangesDiff()) {
|
2553
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2554
|
+
* }
|
2555
|
+
* ```
|
2556
|
+
*
|
2557
|
+
* Example using `iter.next()`:
|
2558
|
+
*
|
2559
|
+
* ```js
|
2560
|
+
* let i = 1;
|
2561
|
+
* let iter = pageBlobClient.listPageRangesDiff();
|
2562
|
+
* let pageRangeItem = await iter.next();
|
2563
|
+
* while (!pageRangeItem.done) {
|
2564
|
+
* console.log(`Page range ${i++}: ${pageRangeItem.value.start} - ${pageRangeItem.value.end}, IsClear: ${pageRangeItem.value.isClear}`);
|
2565
|
+
* pageRangeItem = await iter.next();
|
2566
|
+
* }
|
2567
|
+
* ```
|
2568
|
+
*
|
2569
|
+
* Example using `byPage()`:
|
2570
|
+
*
|
2571
|
+
* ```js
|
2572
|
+
* // passing optional maxPageSize in the page settings
|
2573
|
+
* let i = 1;
|
2574
|
+
* for await (const response of pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 20 })) {
|
2575
|
+
* for (const pageRange of response) {
|
2576
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2577
|
+
* }
|
2578
|
+
* }
|
2579
|
+
* ```
|
2580
|
+
*
|
2581
|
+
* Example using paging with a marker:
|
2582
|
+
*
|
2583
|
+
* ```js
|
2584
|
+
* let i = 1;
|
2585
|
+
* let iterator = pageBlobClient.listPageRangesDiff().byPage({ maxPageSize: 2 });
|
2586
|
+
* let response = (await iterator.next()).value;
|
2587
|
+
*
|
2588
|
+
* // Prints 2 page ranges
|
2589
|
+
* for (const pageRange of response) {
|
2590
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2591
|
+
* }
|
2592
|
+
*
|
2593
|
+
* // Gets next marker
|
2594
|
+
* let marker = response.continuationToken;
|
2595
|
+
*
|
2596
|
+
* // Passing next marker as continuationToken
|
2597
|
+
*
|
2598
|
+
* iterator = pageBlobClient.listPageRangesDiff().byPage({ continuationToken: marker, maxPageSize: 10 });
|
2599
|
+
* response = (await iterator.next()).value;
|
2600
|
+
*
|
2601
|
+
* // Prints 10 page ranges
|
2602
|
+
* for (const blob of response) {
|
2603
|
+
* console.log(`Page range ${i++}: ${pageRange.start} - ${pageRange.end}`);
|
2604
|
+
* }
|
2605
|
+
* ```
|
2606
|
+
* @param offset - Starting byte position of the page ranges.
|
2607
|
+
* @param count - Number of bytes to get.
|
2608
|
+
* @param prevSnapshot - Timestamp of snapshot to retrieve the difference.
|
2609
|
+
* @param options - Options to the Page Blob Get Ranges operation.
|
2610
|
+
* @returns An asyncIterableIterator that supports paging.
|
2611
|
+
*/
|
2612
|
+
listPageRangesDiff(offset, count, prevSnapshot, options = {}) {
|
2613
|
+
options.conditions = options.conditions || {};
|
2614
|
+
// AsyncIterableIterator to iterate over blobs
|
2615
|
+
const iter = this.listPageRangeDiffItems(offset, count, prevSnapshot, Object.assign({}, options));
|
2616
|
+
return {
|
2617
|
+
/**
|
2618
|
+
* The next method, part of the iteration protocol
|
2619
|
+
*/
|
2620
|
+
next() {
|
2621
|
+
return iter.next();
|
2622
|
+
},
|
2623
|
+
/**
|
2624
|
+
* The connection to the async iterator, part of the iteration protocol
|
2625
|
+
*/
|
2626
|
+
[Symbol.asyncIterator]() {
|
2627
|
+
return this;
|
2628
|
+
},
|
2629
|
+
/**
|
2630
|
+
* Return an AsyncIterableIterator that works a page at a time
|
2631
|
+
*/
|
2632
|
+
byPage: (settings = {}) => {
|
2633
|
+
return this.listPageRangeDiffItemSegments(offset, count, prevSnapshot, settings.continuationToken, Object.assign({ maxPageSize: settings.maxPageSize }, options));
|
2634
|
+
},
|
2635
|
+
};
|
2636
|
+
}
|
2271
2637
|
/**
|
2272
2638
|
* Gets the collection of page ranges that differ between a specified snapshot and this page blob for managed disks.
|
2273
2639
|
* @see https://docs.microsoft.com/rest/api/storageservices/get-page-ranges
|