@azure/storage-blob 12.28.0-beta.2 → 12.29.0-beta.1
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/dist/browser/BatchResponseParser.js +1 -1
- package/dist/browser/BatchResponseParser.js.map +1 -1
- package/dist/browser/BlobBatch.d.ts +8 -8
- package/dist/browser/BlobBatch.js +1 -1
- package/dist/browser/BlobBatch.js.map +1 -1
- package/dist/browser/BlobBatchClient.d.ts +10 -10
- package/dist/browser/BlobBatchClient.js +2 -2
- package/dist/browser/BlobBatchClient.js.map +1 -1
- package/dist/browser/BlobLeaseClient.d.ts +10 -10
- package/dist/browser/BlobLeaseClient.js +10 -10
- package/dist/browser/BlobLeaseClient.js.map +1 -1
- package/dist/browser/BlobServiceClient.d.ts +11 -11
- package/dist/browser/BlobServiceClient.js +11 -11
- package/dist/browser/BlobServiceClient.js.map +1 -1
- package/dist/browser/Clients.d.ts +36 -36
- package/dist/browser/Clients.js +23 -23
- package/dist/browser/Clients.js.map +1 -1
- package/dist/browser/ContainerClient.d.ts +16 -16
- package/dist/browser/ContainerClient.js +15 -15
- package/dist/browser/ContainerClient.js.map +1 -1
- package/dist/browser/Pipeline.d.ts.map +1 -1
- package/dist/browser/Pipeline.js +2 -1
- package/dist/browser/Pipeline.js.map +1 -1
- package/dist/browser/Range.d.ts +1 -1
- package/dist/browser/Range.js.map +1 -1
- package/dist/browser/StorageRetryPolicyFactory.d.ts +2 -2
- package/dist/browser/StorageRetryPolicyFactory.js.map +1 -1
- package/dist/browser/generated/src/models/index.d.ts +97 -82
- package/dist/browser/generated/src/models/index.d.ts.map +1 -1
- package/dist/browser/generated/src/models/index.js.map +1 -1
- package/dist/browser/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/browser/generated/src/models/mappers.js +105 -0
- package/dist/browser/generated/src/models/mappers.js.map +1 -1
- package/dist/browser/generated/src/models/parameters.js +1 -1
- package/dist/browser/generated/src/models/parameters.js.map +1 -1
- package/dist/browser/generated/src/storageClient.js +2 -2
- package/dist/browser/generated/src/storageClient.js.map +1 -1
- package/dist/browser/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/StorageRetryPolicy.js +15 -16
- package/dist/browser/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/browser/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/browser/policies/StorageRetryPolicyV2.js +15 -16
- package/dist/browser/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.d.ts +1 -1
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.js +2 -2
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist/browser/sas/AccountSASPermissions.d.ts +1 -1
- package/dist/browser/sas/AccountSASPermissions.js +2 -2
- package/dist/browser/sas/AccountSASPermissions.js.map +1 -1
- package/dist/browser/sas/AccountSASResourceTypes.d.ts +1 -1
- package/dist/browser/sas/AccountSASResourceTypes.js +1 -1
- package/dist/browser/sas/AccountSASResourceTypes.js.map +1 -1
- package/dist/browser/sas/AccountSASSignatureValues.d.ts +3 -3
- package/dist/browser/sas/AccountSASSignatureValues.js +1 -1
- package/dist/browser/sas/AccountSASSignatureValues.js.map +1 -1
- package/dist/browser/sas/BlobSASSignatureValues.d.ts +1 -1
- package/dist/browser/sas/BlobSASSignatureValues.js +1 -1
- package/dist/browser/sas/BlobSASSignatureValues.js.map +1 -1
- package/dist/browser/sas/ContainerSASPermissions.d.ts +1 -1
- package/dist/browser/sas/ContainerSASPermissions.js +1 -1
- package/dist/browser/sas/ContainerSASPermissions.js.map +1 -1
- package/dist/browser/sas/SASQueryParameters.d.ts +2 -2
- package/dist/browser/sas/SASQueryParameters.js.map +1 -1
- package/dist/browser/utils/constants.js +2 -2
- package/dist/browser/utils/constants.js.map +1 -1
- package/dist/browser/utils/utils.common.d.ts +2 -2
- package/dist/browser/utils/utils.common.js +3 -3
- package/dist/browser/utils/utils.common.js.map +1 -1
- package/dist/commonjs/BatchResponseParser.js +1 -1
- package/dist/commonjs/BatchResponseParser.js.map +1 -1
- package/dist/commonjs/BlobBatch.d.ts +8 -8
- package/dist/commonjs/BlobBatch.js +1 -1
- package/dist/commonjs/BlobBatch.js.map +1 -1
- package/dist/commonjs/BlobBatchClient.d.ts +10 -10
- package/dist/commonjs/BlobBatchClient.js +2 -2
- package/dist/commonjs/BlobBatchClient.js.map +1 -1
- package/dist/commonjs/BlobLeaseClient.d.ts +10 -10
- package/dist/commonjs/BlobLeaseClient.js +10 -10
- package/dist/commonjs/BlobLeaseClient.js.map +1 -1
- package/dist/commonjs/BlobServiceClient.d.ts +11 -11
- package/dist/commonjs/BlobServiceClient.js +11 -11
- package/dist/commonjs/BlobServiceClient.js.map +1 -1
- package/dist/commonjs/Clients.d.ts +36 -36
- package/dist/commonjs/Clients.js +23 -23
- package/dist/commonjs/Clients.js.map +1 -1
- package/dist/commonjs/ContainerClient.d.ts +16 -16
- package/dist/commonjs/ContainerClient.js +15 -15
- package/dist/commonjs/ContainerClient.js.map +1 -1
- package/dist/commonjs/Pipeline.d.ts.map +1 -1
- package/dist/commonjs/Pipeline.js +1 -0
- package/dist/commonjs/Pipeline.js.map +1 -1
- package/dist/commonjs/Range.d.ts +1 -1
- package/dist/commonjs/Range.js.map +1 -1
- package/dist/commonjs/StorageRetryPolicyFactory.d.ts +2 -2
- package/dist/commonjs/StorageRetryPolicyFactory.js.map +1 -1
- package/dist/commonjs/credentials/UserDelegationKeyCredential.d.ts +1 -1
- package/dist/commonjs/credentials/UserDelegationKeyCredential.js +1 -1
- package/dist/commonjs/credentials/UserDelegationKeyCredential.js.map +1 -1
- package/dist/commonjs/generated/src/models/index.d.ts +97 -82
- package/dist/commonjs/generated/src/models/index.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/index.js.map +1 -1
- package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/mappers.js +105 -0
- package/dist/commonjs/generated/src/models/mappers.js.map +1 -1
- package/dist/commonjs/generated/src/models/parameters.js +1 -1
- package/dist/commonjs/generated/src/models/parameters.js.map +1 -1
- package/dist/commonjs/generated/src/storageClient.js +2 -2
- package/dist/commonjs/generated/src/storageClient.js.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicy.js +14 -15
- package/dist/commonjs/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicyV2.js +14 -15
- package/dist/commonjs/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts +1 -1
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js +2 -2
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js +2 -2
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
- package/dist/commonjs/sas/AccountSASPermissions.d.ts +1 -1
- package/dist/commonjs/sas/AccountSASPermissions.js +2 -2
- package/dist/commonjs/sas/AccountSASPermissions.js.map +1 -1
- package/dist/commonjs/sas/AccountSASResourceTypes.d.ts +1 -1
- package/dist/commonjs/sas/AccountSASResourceTypes.js +1 -1
- package/dist/commonjs/sas/AccountSASResourceTypes.js.map +1 -1
- package/dist/commonjs/sas/AccountSASSignatureValues.d.ts +3 -3
- package/dist/commonjs/sas/AccountSASSignatureValues.js +1 -1
- package/dist/commonjs/sas/AccountSASSignatureValues.js.map +1 -1
- package/dist/commonjs/sas/BlobSASSignatureValues.d.ts +1 -1
- package/dist/commonjs/sas/BlobSASSignatureValues.js +1 -1
- package/dist/commonjs/sas/BlobSASSignatureValues.js.map +1 -1
- package/dist/commonjs/sas/ContainerSASPermissions.d.ts +1 -1
- package/dist/commonjs/sas/ContainerSASPermissions.js +1 -1
- package/dist/commonjs/sas/ContainerSASPermissions.js.map +1 -1
- package/dist/commonjs/sas/SASQueryParameters.d.ts +2 -2
- package/dist/commonjs/sas/SASQueryParameters.js.map +1 -1
- package/dist/commonjs/utils/constants.js +2 -2
- package/dist/commonjs/utils/constants.js.map +1 -1
- package/dist/commonjs/utils/utils.common.d.ts +2 -2
- package/dist/commonjs/utils/utils.common.js +3 -3
- package/dist/commonjs/utils/utils.common.js.map +1 -1
- package/dist/esm/BatchResponseParser.js +1 -1
- package/dist/esm/BatchResponseParser.js.map +1 -1
- package/dist/esm/BlobBatch.d.ts +8 -8
- package/dist/esm/BlobBatch.js +1 -1
- package/dist/esm/BlobBatch.js.map +1 -1
- package/dist/esm/BlobBatchClient.d.ts +10 -10
- package/dist/esm/BlobBatchClient.js +2 -2
- package/dist/esm/BlobBatchClient.js.map +1 -1
- package/dist/esm/BlobLeaseClient.d.ts +10 -10
- package/dist/esm/BlobLeaseClient.js +10 -10
- package/dist/esm/BlobLeaseClient.js.map +1 -1
- package/dist/esm/BlobServiceClient.d.ts +11 -11
- package/dist/esm/BlobServiceClient.js +11 -11
- package/dist/esm/BlobServiceClient.js.map +1 -1
- package/dist/esm/Clients.d.ts +36 -36
- package/dist/esm/Clients.js +23 -23
- package/dist/esm/Clients.js.map +1 -1
- package/dist/esm/ContainerClient.d.ts +16 -16
- package/dist/esm/ContainerClient.js +15 -15
- package/dist/esm/ContainerClient.js.map +1 -1
- package/dist/esm/Pipeline.d.ts.map +1 -1
- package/dist/esm/Pipeline.js +2 -1
- package/dist/esm/Pipeline.js.map +1 -1
- package/dist/esm/Range.d.ts +1 -1
- package/dist/esm/Range.js.map +1 -1
- package/dist/esm/StorageRetryPolicyFactory.d.ts +2 -2
- package/dist/esm/StorageRetryPolicyFactory.js.map +1 -1
- package/dist/esm/credentials/UserDelegationKeyCredential.d.ts +1 -1
- package/dist/esm/credentials/UserDelegationKeyCredential.js +1 -1
- package/dist/esm/credentials/UserDelegationKeyCredential.js.map +1 -1
- package/dist/esm/generated/src/models/index.d.ts +97 -82
- package/dist/esm/generated/src/models/index.d.ts.map +1 -1
- package/dist/esm/generated/src/models/index.js.map +1 -1
- package/dist/esm/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/esm/generated/src/models/mappers.js +105 -0
- package/dist/esm/generated/src/models/mappers.js.map +1 -1
- package/dist/esm/generated/src/models/parameters.js +1 -1
- package/dist/esm/generated/src/models/parameters.js.map +1 -1
- package/dist/esm/generated/src/storageClient.js +2 -2
- package/dist/esm/generated/src/storageClient.js.map +1 -1
- package/dist/esm/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/StorageRetryPolicy.js +15 -16
- package/dist/esm/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/esm/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/esm/policies/StorageRetryPolicyV2.js +15 -16
- package/dist/esm/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js +2 -2
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js +2 -2
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
- package/dist/esm/sas/AccountSASPermissions.d.ts +1 -1
- package/dist/esm/sas/AccountSASPermissions.js +2 -2
- package/dist/esm/sas/AccountSASPermissions.js.map +1 -1
- package/dist/esm/sas/AccountSASResourceTypes.d.ts +1 -1
- package/dist/esm/sas/AccountSASResourceTypes.js +1 -1
- package/dist/esm/sas/AccountSASResourceTypes.js.map +1 -1
- package/dist/esm/sas/AccountSASSignatureValues.d.ts +3 -3
- package/dist/esm/sas/AccountSASSignatureValues.js +1 -1
- package/dist/esm/sas/AccountSASSignatureValues.js.map +1 -1
- package/dist/esm/sas/BlobSASSignatureValues.d.ts +1 -1
- package/dist/esm/sas/BlobSASSignatureValues.js +1 -1
- package/dist/esm/sas/BlobSASSignatureValues.js.map +1 -1
- package/dist/esm/sas/ContainerSASPermissions.d.ts +1 -1
- package/dist/esm/sas/ContainerSASPermissions.js +1 -1
- package/dist/esm/sas/ContainerSASPermissions.js.map +1 -1
- package/dist/esm/sas/SASQueryParameters.d.ts +2 -2
- package/dist/esm/sas/SASQueryParameters.js.map +1 -1
- package/dist/esm/utils/constants.js +2 -2
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/utils.common.d.ts +2 -2
- package/dist/esm/utils/utils.common.js +3 -3
- package/dist/esm/utils/utils.common.js.map +1 -1
- package/dist/react-native/BatchResponseParser.js +1 -1
- package/dist/react-native/BatchResponseParser.js.map +1 -1
- package/dist/react-native/BlobBatch.d.ts +8 -8
- package/dist/react-native/BlobBatch.js +1 -1
- package/dist/react-native/BlobBatch.js.map +1 -1
- package/dist/react-native/BlobBatchClient.d.ts +10 -10
- package/dist/react-native/BlobBatchClient.js +2 -2
- package/dist/react-native/BlobBatchClient.js.map +1 -1
- package/dist/react-native/BlobLeaseClient.d.ts +10 -10
- package/dist/react-native/BlobLeaseClient.js +10 -10
- package/dist/react-native/BlobLeaseClient.js.map +1 -1
- package/dist/react-native/BlobServiceClient.d.ts +11 -11
- package/dist/react-native/BlobServiceClient.js +11 -11
- package/dist/react-native/BlobServiceClient.js.map +1 -1
- package/dist/react-native/Clients.d.ts +36 -36
- package/dist/react-native/Clients.js +23 -23
- package/dist/react-native/Clients.js.map +1 -1
- package/dist/react-native/ContainerClient.d.ts +16 -16
- package/dist/react-native/ContainerClient.js +15 -15
- package/dist/react-native/ContainerClient.js.map +1 -1
- package/dist/react-native/Pipeline.d.ts.map +1 -1
- package/dist/react-native/Pipeline.js +2 -1
- package/dist/react-native/Pipeline.js.map +1 -1
- package/dist/react-native/Range.d.ts +1 -1
- package/dist/react-native/Range.js.map +1 -1
- package/dist/react-native/StorageRetryPolicyFactory.d.ts +2 -2
- package/dist/react-native/StorageRetryPolicyFactory.js.map +1 -1
- package/dist/react-native/credentials/UserDelegationKeyCredential.d.ts +1 -1
- package/dist/react-native/credentials/UserDelegationKeyCredential.js +1 -1
- package/dist/react-native/credentials/UserDelegationKeyCredential.js.map +1 -1
- package/dist/react-native/generated/src/models/index.d.ts +97 -82
- package/dist/react-native/generated/src/models/index.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/index.js.map +1 -1
- package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/mappers.js +105 -0
- package/dist/react-native/generated/src/models/mappers.js.map +1 -1
- package/dist/react-native/generated/src/models/parameters.js +1 -1
- package/dist/react-native/generated/src/models/parameters.js.map +1 -1
- package/dist/react-native/generated/src/storageClient.js +2 -2
- package/dist/react-native/generated/src/storageClient.js.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicy.js +15 -16
- package/dist/react-native/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicyV2.js +15 -16
- package/dist/react-native/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.d.ts +1 -1
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.js +2 -2
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.js +2 -2
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
- package/dist/react-native/sas/AccountSASPermissions.d.ts +1 -1
- package/dist/react-native/sas/AccountSASPermissions.js +2 -2
- package/dist/react-native/sas/AccountSASPermissions.js.map +1 -1
- package/dist/react-native/sas/AccountSASResourceTypes.d.ts +1 -1
- package/dist/react-native/sas/AccountSASResourceTypes.js +1 -1
- package/dist/react-native/sas/AccountSASResourceTypes.js.map +1 -1
- package/dist/react-native/sas/AccountSASSignatureValues.d.ts +3 -3
- package/dist/react-native/sas/AccountSASSignatureValues.js +1 -1
- package/dist/react-native/sas/AccountSASSignatureValues.js.map +1 -1
- package/dist/react-native/sas/BlobSASSignatureValues.d.ts +1 -1
- package/dist/react-native/sas/BlobSASSignatureValues.js +1 -1
- package/dist/react-native/sas/BlobSASSignatureValues.js.map +1 -1
- package/dist/react-native/sas/ContainerSASPermissions.d.ts +1 -1
- package/dist/react-native/sas/ContainerSASPermissions.js +1 -1
- package/dist/react-native/sas/ContainerSASPermissions.js.map +1 -1
- package/dist/react-native/sas/SASQueryParameters.d.ts +2 -2
- package/dist/react-native/sas/SASQueryParameters.js.map +1 -1
- package/dist/react-native/utils/constants.js +2 -2
- package/dist/react-native/utils/constants.js.map +1 -1
- package/dist/react-native/utils/utils.common.d.ts +2 -2
- package/dist/react-native/utils/utils.common.js +3 -3
- package/dist/react-native/utils/utils.common.js.map +1 -1
- package/package.json +4 -4
@@ -27,7 +27,7 @@ export class BatchResponseParser {
|
|
27
27
|
this.perResponsePrefix = `--${this.responseBatchBoundary}${HTTP_LINE_ENDING}`;
|
28
28
|
this.batchResponseEnding = `--${this.responseBatchBoundary}--`;
|
29
29
|
}
|
30
|
-
// For example of response, please refer to https://learn.microsoft.com/
|
30
|
+
// For example of response, please refer to https://learn.microsoft.com/rest/api/storageservices/blob-batch#response
|
31
31
|
async parseBatchResponse() {
|
32
32
|
// When logic reach here, suppose batch request has already succeeded with 202, so we can further parse
|
33
33
|
// sub request's response.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BatchResponseParser.js","sourceRoot":"","sources":["../../src/BatchResponseParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,E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AAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,EAAE,wBAAwB;YACtC,0BAA0B,EAAE,0BAA0B;YACtD,uBAAuB,EAAE,uBAAuB;SACjD,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { toHttpHeadersLike } from \"@azure/core-http-compat\";\n\nimport type { ServiceSubmitBatchResponseModel } from \"./generatedModels.js\";\nimport {\n HTTP_VERSION_1_1,\n HTTP_LINE_ENDING,\n HeaderConstants,\n HTTPURLConnection,\n} from \"./utils/constants.js\";\nimport { getBodyAsText } from \"./BatchUtils.js\";\nimport type { BatchSubRequest } from \"./BlobBatch.js\";\nimport type { BatchSubResponse, ParsedBatchResponse } from \"./BatchResponse.js\";\nimport { logger } from \"./log.js\";\n\nconst HTTP_HEADER_DELIMITER = \": \";\nconst SPACE_DELIMITER = \" \";\nconst NOT_FOUND = -1;\n\n/**\n * Util class for parsing batch response.\n */\nexport class BatchResponseParser {\n private readonly batchResponse: ServiceSubmitBatchResponseModel;\n private readonly responseBatchBoundary: string;\n private readonly perResponsePrefix: string;\n private readonly batchResponseEnding: string;\n private readonly subRequests: Map<number, BatchSubRequest>;\n\n constructor(\n batchResponse: ServiceSubmitBatchResponseModel,\n subRequests: Map<number, BatchSubRequest>,\n ) {\n if (!batchResponse || !batchResponse.contentType) {\n // In special case(reported), server may return invalid content-type which could not be parsed.\n throw new RangeError(\"batchResponse is malformed or doesn't contain valid content-type.\");\n }\n\n if (!subRequests || subRequests.size === 0) {\n // This should be prevent during coding.\n throw new RangeError(\"Invalid state: subRequests is not provided or size is 0.\");\n }\n\n this.batchResponse = batchResponse;\n this.subRequests = subRequests;\n this.responseBatchBoundary = this.batchResponse.contentType!.split(\"=\")[1];\n this.perResponsePrefix = `--${this.responseBatchBoundary}${HTTP_LINE_ENDING}`;\n this.batchResponseEnding = `--${this.responseBatchBoundary}--`;\n }\n\n // For example of response, please refer to https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#response\n public async parseBatchResponse(): Promise<ParsedBatchResponse> {\n // When logic reach here, suppose batch request has already succeeded with 202, so we can further parse\n // sub request's response.\n if (this.batchResponse._response.status !== HTTPURLConnection.HTTP_ACCEPTED) {\n throw new Error(\n `Invalid state: batch request failed with status: '${this.batchResponse._response.status}'.`,\n );\n }\n\n const responseBodyAsText = await getBodyAsText(this.batchResponse);\n\n const subResponses = responseBodyAsText\n .split(this.batchResponseEnding)[0] // string after ending is useless\n .split(this.perResponsePrefix)\n .slice(1); // string before first response boundary is useless\n const subResponseCount = subResponses.length;\n\n // Defensive coding in case of potential error parsing.\n // Note: subResponseCount == 1 is special case where sub request is invalid.\n // We try to prevent such cases through early validation, e.g. validate sub request count >= 1.\n // While in unexpected sub request invalid case, we allow sub response to be parsed and return to user.\n if (subResponseCount !== this.subRequests.size && subResponseCount !== 1) {\n throw new Error(\"Invalid state: sub responses' count is not equal to sub requests' count.\");\n }\n\n const deserializedSubResponses: Array<BatchSubResponse> = new Array(subResponseCount);\n let subResponsesSucceededCount: number = 0;\n let subResponsesFailedCount: number = 0;\n\n // Parse sub subResponses.\n for (let index = 0; index < subResponseCount; index++) {\n const subResponse = subResponses[index];\n const deserializedSubResponse = {} as BatchSubResponse;\n deserializedSubResponse.headers = toHttpHeadersLike(createHttpHeaders());\n\n const responseLines = subResponse.split(`${HTTP_LINE_ENDING}`);\n let subRespHeaderStartFound = false;\n let subRespHeaderEndFound = false;\n let subRespFailed = false;\n let contentId = NOT_FOUND;\n\n for (const responseLine of responseLines) {\n if (!subRespHeaderStartFound) {\n // Convention line to indicate content ID\n if (responseLine.startsWith(HeaderConstants.CONTENT_ID)) {\n contentId = parseInt(responseLine.split(HTTP_HEADER_DELIMITER)[1]);\n }\n\n // Http version line with status code indicates the start of sub request's response.\n // Example: HTTP/1.1 202 Accepted\n if (responseLine.startsWith(HTTP_VERSION_1_1)) {\n subRespHeaderStartFound = true;\n\n const tokens = responseLine.split(SPACE_DELIMITER);\n deserializedSubResponse.status = parseInt(tokens[1]);\n deserializedSubResponse.statusMessage = tokens.slice(2).join(SPACE_DELIMITER);\n }\n\n continue; // Skip convention headers not specifically for sub request i.e. Content-Type: application/http and Content-ID: *\n }\n\n if (responseLine.trim() === \"\") {\n // Sub response's header start line already found, and the first empty line indicates header end line found.\n if (!subRespHeaderEndFound) {\n subRespHeaderEndFound = true;\n }\n\n continue; // Skip empty line\n }\n\n // Note: when code reach here, it indicates subRespHeaderStartFound == true\n if (!subRespHeaderEndFound) {\n if (responseLine.indexOf(HTTP_HEADER_DELIMITER) === -1) {\n // Defensive coding to prevent from missing valuable lines.\n throw new Error(\n `Invalid state: find non-empty line '${responseLine}' without HTTP header delimiter '${HTTP_HEADER_DELIMITER}'.`,\n );\n }\n\n // Parse headers of sub response.\n const tokens = responseLine.split(HTTP_HEADER_DELIMITER);\n deserializedSubResponse.headers.set(tokens[0], tokens[1]);\n if (tokens[0] === HeaderConstants.X_MS_ERROR_CODE) {\n deserializedSubResponse.errorCode = tokens[1];\n subRespFailed = true;\n }\n } else {\n // Assemble body of sub response.\n if (!deserializedSubResponse.bodyAsText) {\n deserializedSubResponse.bodyAsText = \"\";\n }\n\n deserializedSubResponse.bodyAsText += responseLine;\n }\n } // Inner for end\n\n // The response will contain the Content-ID header for each corresponding subrequest response to use for tracking.\n // The Content-IDs are set to a valid index in the subrequests we sent. In the status code 202 path, we could expect it\n // to be 1-1 mapping from the [0, subRequests.size) to the Content-IDs returned. If not, we simply don't return that\n // unexpected subResponse in the parsed reponse and we can always look it up in the raw response for debugging purpose.\n if (\n contentId !== NOT_FOUND &&\n Number.isInteger(contentId) &&\n contentId >= 0 &&\n contentId < this.subRequests.size &&\n deserializedSubResponses[contentId] === undefined\n ) {\n deserializedSubResponse._request = this.subRequests.get(contentId)!;\n deserializedSubResponses[contentId] = deserializedSubResponse;\n } else {\n logger.error(\n `subResponses[${index}] is dropped as the Content-ID is not found or invalid, Content-ID: ${contentId}`,\n );\n }\n\n if (subRespFailed) {\n subResponsesFailedCount++;\n } else {\n subResponsesSucceededCount++;\n }\n }\n\n return {\n subResponses: deserializedSubResponses,\n subResponsesSucceededCount: subResponsesSucceededCount,\n subResponsesFailedCount: subResponsesFailedCount,\n };\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"BatchResponseParser.js","sourceRoot":"","sources":["../../src/BatchResponseParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC;AAErB;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAO9B,YACE,aAA8C,EAC9C,WAAyC;QAEzC,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YACjD,+FAA+F;YAC/F,MAAM,IAAI,UAAU,CAAC,mEAAmE,CAAC,CAAC;QAC5F,CAAC;QAED,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC3C,wCAAwC;YACxC,MAAM,IAAI,UAAU,CAAC,0DAA0D,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa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,IAAI,CAAC,WAAW,CAAC,IAAI;gBACjC,wBAAwB,CAAC,SAAS,CAAC,KAAK,SAAS,EACjD,CAAC;gBACD,uBAAuB,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;gBACpE,wBAAwB,CAAC,SAAS,CAAC,GAAG,uBAAuB,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CACV,gBAAgB,KAAK,uEAAuE,SAAS,EAAE,CACxG,CAAC;YACJ,CAAC;YAED,IAAI,aAAa,EAAE,CAAC;gBAClB,uBAAuB,EAAE,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,0BAA0B,EAAE,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,EAAE,wBAAwB;YACtC,0BAA0B,EAAE,0BAA0B;YACtD,uBAAuB,EAAE,uBAAuB;SACjD,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { toHttpHeadersLike } from \"@azure/core-http-compat\";\n\nimport type { ServiceSubmitBatchResponseModel } from \"./generatedModels.js\";\nimport {\n HTTP_VERSION_1_1,\n HTTP_LINE_ENDING,\n HeaderConstants,\n HTTPURLConnection,\n} from \"./utils/constants.js\";\nimport { getBodyAsText } from \"./BatchUtils.js\";\nimport type { BatchSubRequest } from \"./BlobBatch.js\";\nimport type { BatchSubResponse, ParsedBatchResponse } from \"./BatchResponse.js\";\nimport { logger } from \"./log.js\";\n\nconst HTTP_HEADER_DELIMITER = \": \";\nconst SPACE_DELIMITER = \" \";\nconst NOT_FOUND = -1;\n\n/**\n * Util class for parsing batch response.\n */\nexport class BatchResponseParser {\n private readonly batchResponse: ServiceSubmitBatchResponseModel;\n private readonly responseBatchBoundary: string;\n private readonly perResponsePrefix: string;\n private readonly batchResponseEnding: string;\n private readonly subRequests: Map<number, BatchSubRequest>;\n\n constructor(\n batchResponse: ServiceSubmitBatchResponseModel,\n subRequests: Map<number, BatchSubRequest>,\n ) {\n if (!batchResponse || !batchResponse.contentType) {\n // In special case(reported), server may return invalid content-type which could not be parsed.\n throw new RangeError(\"batchResponse is malformed or doesn't contain valid content-type.\");\n }\n\n if (!subRequests || subRequests.size === 0) {\n // This should be prevent during coding.\n throw new RangeError(\"Invalid state: subRequests is not provided or size is 0.\");\n }\n\n this.batchResponse = batchResponse;\n this.subRequests = subRequests;\n this.responseBatchBoundary = this.batchResponse.contentType!.split(\"=\")[1];\n this.perResponsePrefix = `--${this.responseBatchBoundary}${HTTP_LINE_ENDING}`;\n this.batchResponseEnding = `--${this.responseBatchBoundary}--`;\n }\n\n // For example of response, please refer to https://learn.microsoft.com/rest/api/storageservices/blob-batch#response\n public async parseBatchResponse(): Promise<ParsedBatchResponse> {\n // When logic reach here, suppose batch request has already succeeded with 202, so we can further parse\n // sub request's response.\n if (this.batchResponse._response.status !== HTTPURLConnection.HTTP_ACCEPTED) {\n throw new Error(\n `Invalid state: batch request failed with status: '${this.batchResponse._response.status}'.`,\n );\n }\n\n const responseBodyAsText = await getBodyAsText(this.batchResponse);\n\n const subResponses = responseBodyAsText\n .split(this.batchResponseEnding)[0] // string after ending is useless\n .split(this.perResponsePrefix)\n .slice(1); // string before first response boundary is useless\n const subResponseCount = subResponses.length;\n\n // Defensive coding in case of potential error parsing.\n // Note: subResponseCount == 1 is special case where sub request is invalid.\n // We try to prevent such cases through early validation, e.g. validate sub request count >= 1.\n // While in unexpected sub request invalid case, we allow sub response to be parsed and return to user.\n if (subResponseCount !== this.subRequests.size && subResponseCount !== 1) {\n throw new Error(\"Invalid state: sub responses' count is not equal to sub requests' count.\");\n }\n\n const deserializedSubResponses: Array<BatchSubResponse> = new Array(subResponseCount);\n let subResponsesSucceededCount: number = 0;\n let subResponsesFailedCount: number = 0;\n\n // Parse sub subResponses.\n for (let index = 0; index < subResponseCount; index++) {\n const subResponse = subResponses[index];\n const deserializedSubResponse = {} as BatchSubResponse;\n deserializedSubResponse.headers = toHttpHeadersLike(createHttpHeaders());\n\n const responseLines = subResponse.split(`${HTTP_LINE_ENDING}`);\n let subRespHeaderStartFound = false;\n let subRespHeaderEndFound = false;\n let subRespFailed = false;\n let contentId = NOT_FOUND;\n\n for (const responseLine of responseLines) {\n if (!subRespHeaderStartFound) {\n // Convention line to indicate content ID\n if (responseLine.startsWith(HeaderConstants.CONTENT_ID)) {\n contentId = parseInt(responseLine.split(HTTP_HEADER_DELIMITER)[1]);\n }\n\n // Http version line with status code indicates the start of sub request's response.\n // Example: HTTP/1.1 202 Accepted\n if (responseLine.startsWith(HTTP_VERSION_1_1)) {\n subRespHeaderStartFound = true;\n\n const tokens = responseLine.split(SPACE_DELIMITER);\n deserializedSubResponse.status = parseInt(tokens[1]);\n deserializedSubResponse.statusMessage = tokens.slice(2).join(SPACE_DELIMITER);\n }\n\n continue; // Skip convention headers not specifically for sub request i.e. Content-Type: application/http and Content-ID: *\n }\n\n if (responseLine.trim() === \"\") {\n // Sub response's header start line already found, and the first empty line indicates header end line found.\n if (!subRespHeaderEndFound) {\n subRespHeaderEndFound = true;\n }\n\n continue; // Skip empty line\n }\n\n // Note: when code reach here, it indicates subRespHeaderStartFound == true\n if (!subRespHeaderEndFound) {\n if (responseLine.indexOf(HTTP_HEADER_DELIMITER) === -1) {\n // Defensive coding to prevent from missing valuable lines.\n throw new Error(\n `Invalid state: find non-empty line '${responseLine}' without HTTP header delimiter '${HTTP_HEADER_DELIMITER}'.`,\n );\n }\n\n // Parse headers of sub response.\n const tokens = responseLine.split(HTTP_HEADER_DELIMITER);\n deserializedSubResponse.headers.set(tokens[0], tokens[1]);\n if (tokens[0] === HeaderConstants.X_MS_ERROR_CODE) {\n deserializedSubResponse.errorCode = tokens[1];\n subRespFailed = true;\n }\n } else {\n // Assemble body of sub response.\n if (!deserializedSubResponse.bodyAsText) {\n deserializedSubResponse.bodyAsText = \"\";\n }\n\n deserializedSubResponse.bodyAsText += responseLine;\n }\n } // Inner for end\n\n // The response will contain the Content-ID header for each corresponding subrequest response to use for tracking.\n // The Content-IDs are set to a valid index in the subrequests we sent. In the status code 202 path, we could expect it\n // to be 1-1 mapping from the [0, subRequests.size) to the Content-IDs returned. If not, we simply don't return that\n // unexpected subResponse in the parsed reponse and we can always look it up in the raw response for debugging purpose.\n if (\n contentId !== NOT_FOUND &&\n Number.isInteger(contentId) &&\n contentId >= 0 &&\n contentId < this.subRequests.size &&\n deserializedSubResponses[contentId] === undefined\n ) {\n deserializedSubResponse._request = this.subRequests.get(contentId)!;\n deserializedSubResponses[contentId] = deserializedSubResponse;\n } else {\n logger.error(\n `subResponses[${index}] is dropped as the Content-ID is not found or invalid, Content-ID: ${contentId}`,\n );\n }\n\n if (subRespFailed) {\n subResponsesFailedCount++;\n } else {\n subResponsesSucceededCount++;\n }\n }\n\n return {\n subResponses: deserializedSubResponses,\n subResponsesSucceededCount: subResponsesSucceededCount,\n subResponsesFailedCount: subResponsesFailedCount,\n };\n }\n}\n"]}
|
@@ -50,9 +50,9 @@ export declare class BlobBatch {
|
|
50
50
|
* Only one kind of operation is allowed per batch request.
|
51
51
|
*
|
52
52
|
* Note that in order to delete a blob, you must delete all of its snapshots.
|
53
|
-
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/
|
53
|
+
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).
|
54
54
|
* The operation will be authenticated and authorized with specified credential.
|
55
|
-
* See [blob batch authorization details](https://learn.microsoft.com/
|
55
|
+
* See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
56
56
|
*
|
57
57
|
* @param url - The url of the blob resource to delete.
|
58
58
|
* @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
|
@@ -65,9 +65,9 @@ export declare class BlobBatch {
|
|
65
65
|
* Only one kind of operation is allowed per batch request.
|
66
66
|
*
|
67
67
|
* Note that in order to delete a blob, you must delete all of its snapshots.
|
68
|
-
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/
|
68
|
+
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).
|
69
69
|
* The operation will be authenticated and authorized with specified credential.
|
70
|
-
* See [blob batch authorization details](https://learn.microsoft.com/
|
70
|
+
* See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
71
71
|
*
|
72
72
|
* @param blobClient - The BlobClient.
|
73
73
|
* @param options -
|
@@ -81,9 +81,9 @@ export declare class BlobBatch {
|
|
81
81
|
* A block blob's tier determines Hot/Cool/Archive storage type.
|
82
82
|
* This operation does not update the blob's ETag.
|
83
83
|
* For detailed information about block blob level tiering
|
84
|
-
* see [hot, cool, and archive access tiers](https://learn.microsoft.com/
|
84
|
+
* see [hot, cool, and archive access tiers](https://learn.microsoft.com/azure/storage/blobs/storage-blob-storage-tiers).
|
85
85
|
* The operation will be authenticated and authorized
|
86
|
-
* with specified credential. See [blob batch authorization details](https://learn.microsoft.com/
|
86
|
+
* with specified credential. See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
87
87
|
*
|
88
88
|
* @param url - The url of the blob resource to delete.
|
89
89
|
* @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
|
@@ -99,9 +99,9 @@ export declare class BlobBatch {
|
|
99
99
|
* A block blob's tier determines Hot/Cool/Archive storage type.
|
100
100
|
* This operation does not update the blob's ETag.
|
101
101
|
* For detailed information about block blob level tiering
|
102
|
-
* see [hot, cool, and archive access tiers](https://learn.microsoft.com/
|
102
|
+
* see [hot, cool, and archive access tiers](https://learn.microsoft.com/azure/storage/blobs/storage-blob-storage-tiers).
|
103
103
|
* The operation will be authenticated and authorized
|
104
|
-
* with specified credential. See [blob batch authorization details](https://learn.microsoft.com/
|
104
|
+
* with specified credential. See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
105
105
|
*
|
106
106
|
* @param blobClient - The BlobClient.
|
107
107
|
* @param tier -
|
@@ -135,7 +135,7 @@ export class BlobBatch {
|
|
135
135
|
}
|
136
136
|
/**
|
137
137
|
* Inner batch request class which is responsible for assembling and serializing sub requests.
|
138
|
-
* See https://learn.microsoft.com/
|
138
|
+
* See https://learn.microsoft.com/rest/api/storageservices/blob-batch#request-body for how requests are assembled.
|
139
139
|
*/
|
140
140
|
class InnerBatchRequest {
|
141
141
|
constructor() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BlobBatch.js","sourceRoot":"","sources":["../../src/BlobBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,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iBAAiB,EAAE;aAC7B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB;IAC9B,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,aAAa,GAAG,EAAE,CAAC;YAEvB,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,IAAI,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC/C,aAAa,GAAG,IAAI,CAAC;gBACvB,CAAC;YACH,CAAC;YAED,IAAI,aAAa,KAAK,EAAE,EAAE,CAAC;gBACzB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,2DAA2D;YACpG,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { randomUUID } from \"@azure/core-util\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createEmptyPipeline,\n createHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { isNodeLike } from \"@azure/core-util\";\nimport { AnonymousCredential } from \"./credentials/AnonymousCredential.js\";\nimport type { BlobDeleteOptions, BlobSetTierOptions } from \"./Clients.js\";\nimport { BlobClient } from \"./Clients.js\";\nimport type { AccessTier } from \"./generatedModels.js\";\nimport { Mutex } from \"./utils/Mutex.js\";\nimport { Pipeline } from \"./Pipeline.js\";\nimport { getURLPath, getURLPathAndQuery, iEqual } from \"./utils/utils.common.js\";\nimport { stringifyXML } from \"@azure/core-xml\";\nimport {\n HeaderConstants,\n BATCH_MAX_REQUEST,\n HTTP_VERSION_1_1,\n HTTP_LINE_ENDING,\n StorageOAuthScopes,\n} from \"./utils/constants.js\";\nimport { StorageSharedKeyCredential } from \"./credentials/StorageSharedKeyCredential.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport { authorizeRequestOnTenantChallenge, serializationPolicy } from \"@azure/core-client\";\nimport { storageSharedKeyCredentialPolicy } from \"./policies/StorageSharedKeyCredentialPolicyV2.js\";\n\n/**\n * A request associated with a batch operation.\n */\nexport interface BatchSubRequest {\n /**\n * The URL of the resource to request operation.\n */\n url: string;\n\n /**\n * The credential used for sub request.\n * Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service.\n * You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n */\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n}\n\n/**\n * A BlobBatch represents an aggregated set of operations on blobs.\n * Currently, only `delete` and `setAccessTier` are supported.\n */\nexport class BlobBatch {\n private batchRequest: InnerBatchRequest;\n private readonly batch: string = \"batch\";\n private batchType: \"delete\" | \"setAccessTier\" | undefined;\n\n constructor() {\n this.batchRequest = new InnerBatchRequest();\n }\n\n /**\n * Get the value of Content-Type for a batch request.\n * The value must be multipart/mixed with a batch boundary.\n * Example: multipart/mixed; boundary=batch_a81786c8-e301-4e42-a729-a32ca24ae252\n */\n public getMultiPartContentType(): string {\n return this.batchRequest.getMultipartContentType();\n }\n\n /**\n * Get assembled HTTP request body for sub requests.\n */\n public getHttpRequestBody(): string {\n return this.batchRequest.getHttpRequestBody();\n }\n\n /**\n * Get sub requests that are added into the batch request.\n */\n public getSubRequests(): Map<number, BatchSubRequest> {\n return this.batchRequest.getSubRequests();\n }\n\n private async addSubRequestInternal(\n subRequest: BatchSubRequest,\n assembleSubRequestFunc: () => Promise<void>,\n ): Promise<void> {\n await Mutex.lock(this.batch);\n\n try {\n this.batchRequest.preAddSubRequest(subRequest);\n await assembleSubRequestFunc();\n this.batchRequest.postAddSubRequest(subRequest);\n } finally {\n await Mutex.unlock(this.batch);\n }\n }\n\n private setBatchType(batchType: \"delete\" | \"setAccessTier\"): void {\n if (!this.batchType) {\n this.batchType = batchType;\n }\n if (this.batchType !== batchType) {\n throw new RangeError(\n `BlobBatch only supports one operation type per batch and it already is being used for ${this.batchType} operations.`,\n );\n }\n }\n\n /**\n * The deleteBlob operation marks the specified blob or snapshot for deletion.\n * The blob is later deleted during garbage collection.\n * Only one kind of operation is allowed per batch request.\n *\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob).\n * The operation will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param url - The url of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options -\n */\n public async deleteBlob(\n url: string,\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n options?: BlobDeleteOptions,\n ): Promise<void>;\n\n /**\n * The deleteBlob operation marks the specified blob or snapshot for deletion.\n * The blob is later deleted during garbage collection.\n * Only one kind of operation is allowed per batch request.\n *\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob).\n * The operation will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClient - The BlobClient.\n * @param options -\n */\n public async deleteBlob(blobClient: BlobClient, options?: BlobDeleteOptions): Promise<void>;\n\n public async deleteBlob(\n urlOrBlobClient: string | BlobClient,\n credentialOrOptions:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | BlobDeleteOptions\n | undefined,\n options?: BlobDeleteOptions,\n ): Promise<void> {\n let url: string;\n let credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n\n if (\n typeof urlOrBlobClient === \"string\" &&\n ((isNodeLike && credentialOrOptions instanceof StorageSharedKeyCredential) ||\n credentialOrOptions instanceof AnonymousCredential ||\n isTokenCredential(credentialOrOptions))\n ) {\n // First overload\n url = urlOrBlobClient;\n credential = credentialOrOptions;\n } else if (urlOrBlobClient instanceof BlobClient) {\n // Second overload\n url = urlOrBlobClient.url;\n credential = urlOrBlobClient.credential;\n options = credentialOrOptions as BlobDeleteOptions;\n } else {\n throw new RangeError(\n \"Invalid arguments. Either url and credential, or BlobClient need be provided.\",\n );\n }\n\n if (!options) {\n options = {};\n }\n\n return tracingClient.withSpan(\n \"BatchDeleteRequest-addSubRequest\",\n options,\n async (updatedOptions) => {\n this.setBatchType(\"delete\");\n await this.addSubRequestInternal(\n {\n url: url,\n credential: credential,\n },\n async () => {\n await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete(\n updatedOptions,\n );\n },\n );\n },\n );\n }\n\n /**\n * The setBlobAccessTier operation sets the tier on a blob.\n * The operation is allowed on block blobs in a blob storage or general purpose v2 account.\n * Only one kind of operation is allowed per batch request.\n *\n * A block blob's tier determines Hot/Cool/Archive storage type.\n * This operation does not update the blob's ETag.\n * For detailed information about block blob level tiering\n * see [hot, cool, and archive access tiers](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers).\n * The operation will be authenticated and authorized\n * with specified credential. See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param url - The url of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param tier -\n * @param options -\n */\n public async setBlobAccessTier(\n url: string,\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n tier: AccessTier,\n options?: BlobSetTierOptions,\n ): Promise<void>;\n\n /**\n * The setBlobAccessTier operation sets the tier on a blob.\n * The operation is allowed on block blobs in a blob storage or general purpose v2 account.\n * Only one kind of operation is allowed per batch request.\n *\n * A block blob's tier determines Hot/Cool/Archive storage type.\n * This operation does not update the blob's ETag.\n * For detailed information about block blob level tiering\n * see [hot, cool, and archive access tiers](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers).\n * The operation will be authenticated and authorized\n * with specified credential. See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClient - The BlobClient.\n * @param tier -\n * @param options -\n */\n public async setBlobAccessTier(\n blobClient: BlobClient,\n tier: AccessTier,\n options?: BlobSetTierOptions,\n ): Promise<void>;\n\n public async setBlobAccessTier(\n urlOrBlobClient: string | BlobClient,\n credentialOrTier:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | AccessTier,\n tierOrOptions?: AccessTier | BlobSetTierOptions,\n options?: BlobSetTierOptions,\n ): Promise<void> {\n let url: string;\n let credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n let tier: AccessTier;\n\n if (\n typeof urlOrBlobClient === \"string\" &&\n ((isNodeLike && credentialOrTier instanceof StorageSharedKeyCredential) ||\n credentialOrTier instanceof AnonymousCredential ||\n isTokenCredential(credentialOrTier))\n ) {\n // First overload\n url = urlOrBlobClient;\n credential = credentialOrTier as\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential;\n tier = tierOrOptions as AccessTier;\n } else if (urlOrBlobClient instanceof BlobClient) {\n // Second overload\n url = urlOrBlobClient.url;\n credential = urlOrBlobClient.credential;\n tier = credentialOrTier as AccessTier;\n options = tierOrOptions as BlobSetTierOptions;\n } else {\n throw new RangeError(\n \"Invalid arguments. Either url and credential, or BlobClient need be provided.\",\n );\n }\n\n if (!options) {\n options = {};\n }\n\n return tracingClient.withSpan(\n \"BatchSetTierRequest-addSubRequest\",\n options,\n async (updatedOptions) => {\n this.setBatchType(\"setAccessTier\");\n await this.addSubRequestInternal(\n {\n url: url,\n credential: credential,\n },\n async () => {\n await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier(\n tier,\n updatedOptions,\n );\n },\n );\n },\n );\n }\n}\n\n/**\n * Inner batch request class which is responsible for assembling and serializing sub requests.\n * See https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#request-body for how requests are assembled.\n */\nclass InnerBatchRequest {\n private operationCount: number;\n private body: string;\n private subRequests: Map<number, BatchSubRequest>;\n private readonly boundary: string;\n private readonly subRequestPrefix: string;\n private readonly multipartContentType: string;\n private readonly batchRequestEnding: string;\n\n constructor() {\n this.operationCount = 0;\n this.body = \"\";\n\n const tempGuid = randomUUID();\n\n // batch_{batchid}\n this.boundary = `batch_${tempGuid}`;\n // --batch_{batchid}\n // Content-Type: application/http\n // Content-Transfer-Encoding: binary\n this.subRequestPrefix = `--${this.boundary}${HTTP_LINE_ENDING}${HeaderConstants.CONTENT_TYPE}: application/http${HTTP_LINE_ENDING}${HeaderConstants.CONTENT_TRANSFER_ENCODING}: binary`;\n // multipart/mixed; boundary=batch_{batchid}\n this.multipartContentType = `multipart/mixed; boundary=${this.boundary}`;\n // --batch_{batchid}--\n this.batchRequestEnding = `--${this.boundary}--`;\n\n this.subRequests = new Map();\n }\n\n /**\n * Create pipeline to assemble sub requests. The idea here is to use existing\n * credential and serialization/deserialization components, with additional policies to\n * filter unnecessary headers, assemble sub requests into request's body\n * and intercept request from going to wire.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n */\n public createPipeline(\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n ): Pipeline {\n const corePipeline = createEmptyPipeline();\n corePipeline.addPolicy(\n serializationPolicy({\n stringifyXML,\n serializerOptions: {\n xml: {\n xmlCharKey: \"#\",\n },\n },\n }),\n { phase: \"Serialize\" },\n );\n // Use batch header filter policy to exclude unnecessary headers\n corePipeline.addPolicy(batchHeaderFilterPolicy());\n // Use batch assemble policy to assemble request and intercept request from going to wire\n corePipeline.addPolicy(batchRequestAssemblePolicy(this), { afterPhase: \"Sign\" });\n if (isTokenCredential(credential)) {\n corePipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: StorageOAuthScopes,\n challengeCallbacks: { authorizeRequestOnChallenge: authorizeRequestOnTenantChallenge },\n }),\n { phase: \"Sign\" },\n );\n } else if (credential instanceof StorageSharedKeyCredential) {\n corePipeline.addPolicy(\n storageSharedKeyCredentialPolicy({\n accountName: credential.accountName,\n accountKey: (credential as any).accountKey,\n }),\n { phase: \"Sign\" },\n );\n }\n const pipeline = new Pipeline([]);\n // attach the v2 pipeline to this one\n (pipeline as any)._credential = credential;\n (pipeline as any)._corePipeline = corePipeline;\n\n return pipeline;\n }\n\n public appendSubRequestToBody(request: PipelineRequest) {\n // Start to assemble sub request\n this.body += [\n this.subRequestPrefix, // sub request constant prefix\n `${HeaderConstants.CONTENT_ID}: ${this.operationCount}`, // sub request's content ID\n \"\", // empty line after sub request's content ID\n `${request.method.toString()} ${getURLPathAndQuery(\n request.url,\n )} ${HTTP_VERSION_1_1}${HTTP_LINE_ENDING}`, // sub request start line with method\n ].join(HTTP_LINE_ENDING);\n\n for (const [name, value] of request.headers) {\n this.body += `${name}: ${value}${HTTP_LINE_ENDING}`;\n }\n\n this.body += HTTP_LINE_ENDING; // sub request's headers need be ending with an empty line\n // No body to assemble for current batch request support\n // End to assemble sub request\n }\n\n public preAddSubRequest(subRequest: BatchSubRequest) {\n if (this.operationCount >= BATCH_MAX_REQUEST) {\n throw new RangeError(`Cannot exceed ${BATCH_MAX_REQUEST} sub requests in a single batch`);\n }\n\n // Fast fail if url for sub request is invalid\n const path = getURLPath(subRequest.url);\n if (!path || path === \"\") {\n throw new RangeError(`Invalid url for sub request: '${subRequest.url}'`);\n }\n }\n\n public postAddSubRequest(subRequest: BatchSubRequest) {\n this.subRequests.set(this.operationCount, subRequest);\n this.operationCount++;\n }\n\n // Return the http request body with assembling the ending line to the sub request body.\n public getHttpRequestBody(): string {\n return `${this.body}${this.batchRequestEnding}${HTTP_LINE_ENDING}`;\n }\n\n public getMultipartContentType(): string {\n return this.multipartContentType;\n }\n\n public getSubRequests(): Map<number, BatchSubRequest> {\n return this.subRequests;\n }\n}\n\nfunction batchRequestAssemblePolicy(batchRequest: InnerBatchRequest): PipelinePolicy {\n return {\n name: \"batchRequestAssemblePolicy\",\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n batchRequest.appendSubRequestToBody(request);\n\n return {\n request,\n status: 200,\n headers: createHttpHeaders(),\n };\n },\n };\n}\n\nfunction batchHeaderFilterPolicy(): PipelinePolicy {\n return {\n name: \"batchHeaderFilterPolicy\",\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n let xMsHeaderName = \"\";\n\n for (const [name] of request.headers) {\n if (iEqual(name, HeaderConstants.X_MS_VERSION)) {\n xMsHeaderName = name;\n }\n }\n\n if (xMsHeaderName !== \"\") {\n request.headers.delete(xMsHeaderName); // The subrequests should not have the x-ms-version header.\n }\n\n return next(request);\n },\n };\n}\n"]}
|
1
|
+
{"version":3,"file":"BlobBatch.js","sourceRoot":"","sources":["../../src/BlobBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE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,uBAAuB;QAC5B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,SAAS,0BAA0B,CAAC,YAA+B;IACjE,OAAO;QACL,IAAI,EAAE,4BAA4B;QAClC,KAAK,CAAC,WAAW,CAAC,OAAwB;YACxC,YAAY,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAE7C,OAAO;gBACL,OAAO;gBACP,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,iBAAiB,EAAE;aAC7B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB;IAC9B,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,aAAa,GAAG,EAAE,CAAC;YAEvB,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,IAAI,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC/C,aAAa,GAAG,IAAI,CAAC;gBACvB,CAAC;YACH,CAAC;YAED,IAAI,aAAa,KAAK,EAAE,EAAE,CAAC;gBACzB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,2DAA2D;YACpG,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { randomUUID } from \"@azure/core-util\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createEmptyPipeline,\n createHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { isNodeLike } from \"@azure/core-util\";\nimport { AnonymousCredential } from \"./credentials/AnonymousCredential.js\";\nimport type { BlobDeleteOptions, BlobSetTierOptions } from \"./Clients.js\";\nimport { BlobClient } from \"./Clients.js\";\nimport type { AccessTier } from \"./generatedModels.js\";\nimport { Mutex } from \"./utils/Mutex.js\";\nimport { Pipeline } from \"./Pipeline.js\";\nimport { getURLPath, getURLPathAndQuery, iEqual } from \"./utils/utils.common.js\";\nimport { stringifyXML } from \"@azure/core-xml\";\nimport {\n HeaderConstants,\n BATCH_MAX_REQUEST,\n HTTP_VERSION_1_1,\n HTTP_LINE_ENDING,\n StorageOAuthScopes,\n} from \"./utils/constants.js\";\nimport { StorageSharedKeyCredential } from \"./credentials/StorageSharedKeyCredential.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport { authorizeRequestOnTenantChallenge, serializationPolicy } from \"@azure/core-client\";\nimport { storageSharedKeyCredentialPolicy } from \"./policies/StorageSharedKeyCredentialPolicyV2.js\";\n\n/**\n * A request associated with a batch operation.\n */\nexport interface BatchSubRequest {\n /**\n * The URL of the resource to request operation.\n */\n url: string;\n\n /**\n * The credential used for sub request.\n * Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service.\n * You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n */\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n}\n\n/**\n * A BlobBatch represents an aggregated set of operations on blobs.\n * Currently, only `delete` and `setAccessTier` are supported.\n */\nexport class BlobBatch {\n private batchRequest: InnerBatchRequest;\n private readonly batch: string = \"batch\";\n private batchType: \"delete\" | \"setAccessTier\" | undefined;\n\n constructor() {\n this.batchRequest = new InnerBatchRequest();\n }\n\n /**\n * Get the value of Content-Type for a batch request.\n * The value must be multipart/mixed with a batch boundary.\n * Example: multipart/mixed; boundary=batch_a81786c8-e301-4e42-a729-a32ca24ae252\n */\n public getMultiPartContentType(): string {\n return this.batchRequest.getMultipartContentType();\n }\n\n /**\n * Get assembled HTTP request body for sub requests.\n */\n public getHttpRequestBody(): string {\n return this.batchRequest.getHttpRequestBody();\n }\n\n /**\n * Get sub requests that are added into the batch request.\n */\n public getSubRequests(): Map<number, BatchSubRequest> {\n return this.batchRequest.getSubRequests();\n }\n\n private async addSubRequestInternal(\n subRequest: BatchSubRequest,\n assembleSubRequestFunc: () => Promise<void>,\n ): Promise<void> {\n await Mutex.lock(this.batch);\n\n try {\n this.batchRequest.preAddSubRequest(subRequest);\n await assembleSubRequestFunc();\n this.batchRequest.postAddSubRequest(subRequest);\n } finally {\n await Mutex.unlock(this.batch);\n }\n }\n\n private setBatchType(batchType: \"delete\" | \"setAccessTier\"): void {\n if (!this.batchType) {\n this.batchType = batchType;\n }\n if (this.batchType !== batchType) {\n throw new RangeError(\n `BlobBatch only supports one operation type per batch and it already is being used for ${this.batchType} operations.`,\n );\n }\n }\n\n /**\n * The deleteBlob operation marks the specified blob or snapshot for deletion.\n * The blob is later deleted during garbage collection.\n * Only one kind of operation is allowed per batch request.\n *\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).\n * The operation will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param url - The url of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options -\n */\n public async deleteBlob(\n url: string,\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n options?: BlobDeleteOptions,\n ): Promise<void>;\n\n /**\n * The deleteBlob operation marks the specified blob or snapshot for deletion.\n * The blob is later deleted during garbage collection.\n * Only one kind of operation is allowed per batch request.\n *\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).\n * The operation will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClient - The BlobClient.\n * @param options -\n */\n public async deleteBlob(blobClient: BlobClient, options?: BlobDeleteOptions): Promise<void>;\n\n public async deleteBlob(\n urlOrBlobClient: string | BlobClient,\n credentialOrOptions:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | BlobDeleteOptions\n | undefined,\n options?: BlobDeleteOptions,\n ): Promise<void> {\n let url: string;\n let credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n\n if (\n typeof urlOrBlobClient === \"string\" &&\n ((isNodeLike && credentialOrOptions instanceof StorageSharedKeyCredential) ||\n credentialOrOptions instanceof AnonymousCredential ||\n isTokenCredential(credentialOrOptions))\n ) {\n // First overload\n url = urlOrBlobClient;\n credential = credentialOrOptions;\n } else if (urlOrBlobClient instanceof BlobClient) {\n // Second overload\n url = urlOrBlobClient.url;\n credential = urlOrBlobClient.credential;\n options = credentialOrOptions as BlobDeleteOptions;\n } else {\n throw new RangeError(\n \"Invalid arguments. Either url and credential, or BlobClient need be provided.\",\n );\n }\n\n if (!options) {\n options = {};\n }\n\n return tracingClient.withSpan(\n \"BatchDeleteRequest-addSubRequest\",\n options,\n async (updatedOptions) => {\n this.setBatchType(\"delete\");\n await this.addSubRequestInternal(\n {\n url: url,\n credential: credential,\n },\n async () => {\n await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete(\n updatedOptions,\n );\n },\n );\n },\n );\n }\n\n /**\n * The setBlobAccessTier operation sets the tier on a blob.\n * The operation is allowed on block blobs in a blob storage or general purpose v2 account.\n * Only one kind of operation is allowed per batch request.\n *\n * A block blob's tier determines Hot/Cool/Archive storage type.\n * This operation does not update the blob's ETag.\n * For detailed information about block blob level tiering\n * see [hot, cool, and archive access tiers](https://learn.microsoft.com/azure/storage/blobs/storage-blob-storage-tiers).\n * The operation will be authenticated and authorized\n * with specified credential. See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param url - The url of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param tier -\n * @param options -\n */\n public async setBlobAccessTier(\n url: string,\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n tier: AccessTier,\n options?: BlobSetTierOptions,\n ): Promise<void>;\n\n /**\n * The setBlobAccessTier operation sets the tier on a blob.\n * The operation is allowed on block blobs in a blob storage or general purpose v2 account.\n * Only one kind of operation is allowed per batch request.\n *\n * A block blob's tier determines Hot/Cool/Archive storage type.\n * This operation does not update the blob's ETag.\n * For detailed information about block blob level tiering\n * see [hot, cool, and archive access tiers](https://learn.microsoft.com/azure/storage/blobs/storage-blob-storage-tiers).\n * The operation will be authenticated and authorized\n * with specified credential. See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClient - The BlobClient.\n * @param tier -\n * @param options -\n */\n public async setBlobAccessTier(\n blobClient: BlobClient,\n tier: AccessTier,\n options?: BlobSetTierOptions,\n ): Promise<void>;\n\n public async setBlobAccessTier(\n urlOrBlobClient: string | BlobClient,\n credentialOrTier:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | AccessTier,\n tierOrOptions?: AccessTier | BlobSetTierOptions,\n options?: BlobSetTierOptions,\n ): Promise<void> {\n let url: string;\n let credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential;\n let tier: AccessTier;\n\n if (\n typeof urlOrBlobClient === \"string\" &&\n ((isNodeLike && credentialOrTier instanceof StorageSharedKeyCredential) ||\n credentialOrTier instanceof AnonymousCredential ||\n isTokenCredential(credentialOrTier))\n ) {\n // First overload\n url = urlOrBlobClient;\n credential = credentialOrTier as\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential;\n tier = tierOrOptions as AccessTier;\n } else if (urlOrBlobClient instanceof BlobClient) {\n // Second overload\n url = urlOrBlobClient.url;\n credential = urlOrBlobClient.credential;\n tier = credentialOrTier as AccessTier;\n options = tierOrOptions as BlobSetTierOptions;\n } else {\n throw new RangeError(\n \"Invalid arguments. Either url and credential, or BlobClient need be provided.\",\n );\n }\n\n if (!options) {\n options = {};\n }\n\n return tracingClient.withSpan(\n \"BatchSetTierRequest-addSubRequest\",\n options,\n async (updatedOptions) => {\n this.setBatchType(\"setAccessTier\");\n await this.addSubRequestInternal(\n {\n url: url,\n credential: credential,\n },\n async () => {\n await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier(\n tier,\n updatedOptions,\n );\n },\n );\n },\n );\n }\n}\n\n/**\n * Inner batch request class which is responsible for assembling and serializing sub requests.\n * See https://learn.microsoft.com/rest/api/storageservices/blob-batch#request-body for how requests are assembled.\n */\nclass InnerBatchRequest {\n private operationCount: number;\n private body: string;\n private subRequests: Map<number, BatchSubRequest>;\n private readonly boundary: string;\n private readonly subRequestPrefix: string;\n private readonly multipartContentType: string;\n private readonly batchRequestEnding: string;\n\n constructor() {\n this.operationCount = 0;\n this.body = \"\";\n\n const tempGuid = randomUUID();\n\n // batch_{batchid}\n this.boundary = `batch_${tempGuid}`;\n // --batch_{batchid}\n // Content-Type: application/http\n // Content-Transfer-Encoding: binary\n this.subRequestPrefix = `--${this.boundary}${HTTP_LINE_ENDING}${HeaderConstants.CONTENT_TYPE}: application/http${HTTP_LINE_ENDING}${HeaderConstants.CONTENT_TRANSFER_ENCODING}: binary`;\n // multipart/mixed; boundary=batch_{batchid}\n this.multipartContentType = `multipart/mixed; boundary=${this.boundary}`;\n // --batch_{batchid}--\n this.batchRequestEnding = `--${this.boundary}--`;\n\n this.subRequests = new Map();\n }\n\n /**\n * Create pipeline to assemble sub requests. The idea here is to use existing\n * credential and serialization/deserialization components, with additional policies to\n * filter unnecessary headers, assemble sub requests into request's body\n * and intercept request from going to wire.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n */\n public createPipeline(\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n ): Pipeline {\n const corePipeline = createEmptyPipeline();\n corePipeline.addPolicy(\n serializationPolicy({\n stringifyXML,\n serializerOptions: {\n xml: {\n xmlCharKey: \"#\",\n },\n },\n }),\n { phase: \"Serialize\" },\n );\n // Use batch header filter policy to exclude unnecessary headers\n corePipeline.addPolicy(batchHeaderFilterPolicy());\n // Use batch assemble policy to assemble request and intercept request from going to wire\n corePipeline.addPolicy(batchRequestAssemblePolicy(this), { afterPhase: \"Sign\" });\n if (isTokenCredential(credential)) {\n corePipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: StorageOAuthScopes,\n challengeCallbacks: { authorizeRequestOnChallenge: authorizeRequestOnTenantChallenge },\n }),\n { phase: \"Sign\" },\n );\n } else if (credential instanceof StorageSharedKeyCredential) {\n corePipeline.addPolicy(\n storageSharedKeyCredentialPolicy({\n accountName: credential.accountName,\n accountKey: (credential as any).accountKey,\n }),\n { phase: \"Sign\" },\n );\n }\n const pipeline = new Pipeline([]);\n // attach the v2 pipeline to this one\n (pipeline as any)._credential = credential;\n (pipeline as any)._corePipeline = corePipeline;\n\n return pipeline;\n }\n\n public appendSubRequestToBody(request: PipelineRequest) {\n // Start to assemble sub request\n this.body += [\n this.subRequestPrefix, // sub request constant prefix\n `${HeaderConstants.CONTENT_ID}: ${this.operationCount}`, // sub request's content ID\n \"\", // empty line after sub request's content ID\n `${request.method.toString()} ${getURLPathAndQuery(\n request.url,\n )} ${HTTP_VERSION_1_1}${HTTP_LINE_ENDING}`, // sub request start line with method\n ].join(HTTP_LINE_ENDING);\n\n for (const [name, value] of request.headers) {\n this.body += `${name}: ${value}${HTTP_LINE_ENDING}`;\n }\n\n this.body += HTTP_LINE_ENDING; // sub request's headers need be ending with an empty line\n // No body to assemble for current batch request support\n // End to assemble sub request\n }\n\n public preAddSubRequest(subRequest: BatchSubRequest) {\n if (this.operationCount >= BATCH_MAX_REQUEST) {\n throw new RangeError(`Cannot exceed ${BATCH_MAX_REQUEST} sub requests in a single batch`);\n }\n\n // Fast fail if url for sub request is invalid\n const path = getURLPath(subRequest.url);\n if (!path || path === \"\") {\n throw new RangeError(`Invalid url for sub request: '${subRequest.url}'`);\n }\n }\n\n public postAddSubRequest(subRequest: BatchSubRequest) {\n this.subRequests.set(this.operationCount, subRequest);\n this.operationCount++;\n }\n\n // Return the http request body with assembling the ending line to the sub request body.\n public getHttpRequestBody(): string {\n return `${this.body}${this.batchRequestEnding}${HTTP_LINE_ENDING}`;\n }\n\n public getMultipartContentType(): string {\n return this.multipartContentType;\n }\n\n public getSubRequests(): Map<number, BatchSubRequest> {\n return this.subRequests;\n }\n}\n\nfunction batchRequestAssemblePolicy(batchRequest: InnerBatchRequest): PipelinePolicy {\n return {\n name: \"batchRequestAssemblePolicy\",\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n batchRequest.appendSubRequestToBody(request);\n\n return {\n request,\n status: 200,\n headers: createHttpHeaders(),\n };\n },\n };\n}\n\nfunction batchHeaderFilterPolicy(): PipelinePolicy {\n return {\n name: \"batchHeaderFilterPolicy\",\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n let xMsHeaderName = \"\";\n\n for (const [name] of request.headers) {\n if (iEqual(name, HeaderConstants.X_MS_VERSION)) {\n xMsHeaderName = name;\n }\n }\n\n if (xMsHeaderName !== \"\") {\n request.headers.delete(xMsHeaderName); // The subrequests should not have the x-ms-version header.\n }\n\n return next(request);\n },\n };\n}\n"]}
|
@@ -27,7 +27,7 @@ export declare type BlobBatchSetBlobsAccessTierResponse = BlobBatchSubmitBatchRe
|
|
27
27
|
/**
|
28
28
|
* A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.
|
29
29
|
*
|
30
|
-
* @see https://learn.microsoft.com/
|
30
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/blob-batch
|
31
31
|
*/
|
32
32
|
export declare class BlobBatchClient {
|
33
33
|
private serviceOrContainerContext;
|
@@ -59,9 +59,9 @@ export declare class BlobBatchClient {
|
|
59
59
|
/**
|
60
60
|
* Create multiple delete operations to mark the specified blobs or snapshots for deletion.
|
61
61
|
* Note that in order to delete a blob, you must delete all of its snapshots.
|
62
|
-
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/
|
62
|
+
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).
|
63
63
|
* The operations will be authenticated and authorized with specified credential.
|
64
|
-
* See [blob batch authorization details](https://learn.microsoft.com/
|
64
|
+
* See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
65
65
|
*
|
66
66
|
* @param urls - The urls of the blob resources to delete.
|
67
67
|
* @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
|
@@ -71,9 +71,9 @@ export declare class BlobBatchClient {
|
|
71
71
|
/**
|
72
72
|
* Create multiple delete operations to mark the specified blobs or snapshots for deletion.
|
73
73
|
* Note that in order to delete a blob, you must delete all of its snapshots.
|
74
|
-
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/
|
74
|
+
* You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).
|
75
75
|
* The operation(subrequest) will be authenticated and authorized with specified credential.
|
76
|
-
* See [blob batch authorization details](https://learn.microsoft.com/
|
76
|
+
* See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
77
77
|
*
|
78
78
|
* @param blobClients - The BlobClients for the blobs to delete.
|
79
79
|
* @param options -
|
@@ -86,9 +86,9 @@ export declare class BlobBatchClient {
|
|
86
86
|
* storage only). A premium page blob's tier determines the allowed size, IOPS,
|
87
87
|
* and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive
|
88
88
|
* storage type. This operation does not update the blob's ETag.
|
89
|
-
* See [set blob tier details](https://learn.microsoft.com/
|
89
|
+
* See [set blob tier details](https://learn.microsoft.com/rest/api/storageservices/set-blob-tier).
|
90
90
|
* The operation(subrequest) will be authenticated and authorized
|
91
|
-
* with specified credential.See [blob batch authorization details](https://learn.microsoft.com/
|
91
|
+
* with specified credential.See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
92
92
|
*
|
93
93
|
* @param urls - The urls of the blob resource to delete.
|
94
94
|
* @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
|
@@ -103,9 +103,9 @@ export declare class BlobBatchClient {
|
|
103
103
|
* storage only). A premium page blob's tier determines the allowed size, IOPS,
|
104
104
|
* and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive
|
105
105
|
* storage type. This operation does not update the blob's ETag.
|
106
|
-
* See [set blob tier details](https://learn.microsoft.com/
|
106
|
+
* See [set blob tier details](https://learn.microsoft.com/rest/api/storageservices/set-blob-tier).
|
107
107
|
* The operation(subrequest) will be authenticated and authorized
|
108
|
-
* with specified credential.See [blob batch authorization details](https://learn.microsoft.com/
|
108
|
+
* with specified credential.See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).
|
109
109
|
*
|
110
110
|
* @param blobClients - The BlobClients for the blobs which should have a new tier set.
|
111
111
|
* @param tier -
|
@@ -171,7 +171,7 @@ export declare class BlobBatchClient {
|
|
171
171
|
* console.log(batchResp.subResponsesSucceededCount);
|
172
172
|
* ```
|
173
173
|
*
|
174
|
-
* @see https://learn.microsoft.com/
|
174
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/blob-batch
|
175
175
|
*
|
176
176
|
* @param batchRequest - A set of Delete or SetTier operations.
|
177
177
|
* @param options -
|
@@ -11,7 +11,7 @@ import { assertResponse, getURLPath } from "./utils/utils.common.js";
|
|
11
11
|
/**
|
12
12
|
* A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.
|
13
13
|
*
|
14
|
-
* @see https://learn.microsoft.com/
|
14
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/blob-batch
|
15
15
|
*/
|
16
16
|
export class BlobBatchClient {
|
17
17
|
constructor(url, credentialOrPipeline,
|
@@ -135,7 +135,7 @@ export class BlobBatchClient {
|
|
135
135
|
* console.log(batchResp.subResponsesSucceededCount);
|
136
136
|
* ```
|
137
137
|
*
|
138
|
-
* @see https://learn.microsoft.com/
|
138
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/blob-batch
|
139
139
|
*
|
140
140
|
* @param batchRequest - A set of Delete or SetTier operations.
|
141
141
|
* @param options -
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BlobBatchClient.js","sourceRoot":"","sources":["../../src/BlobBatchClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAyBrE;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA8B1B,YACE,GAA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BAAyB,CAAC,WAAW,CAC9C,cAAc,CAAC,gBAAgB,CAAC,EAChC,YAAY,CAAC,uBAAuB,EAAE,EACtC,gBAAgB,oBAEX,cAAc,EAEpB,CACF,CAAC;YAEF,gHAAgH;YAChH,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,CACjD,gBAAgB,EAChB,YAAY,CAAC,cAAc,EAAE,CAC9B,CAAC;YACF,MAAM,eAAe,GAAG,MAAM,mBAAmB,CAAC,kBAAkB,EAAE,CAAC;YAEvE,MAAM,GAAG,GAAiC;gBACxC,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,WAAW,EAAE,gBAAgB,CAAC,WAAW;gBACzC,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,eAAe,EAAE,gBAAgB,CAAC,eAAe;gBACjD,OAAO,EAAE,gBAAgB,CAAC,OAAO;gBACjC,YAAY,EAAE,eAAe,CAAC,YAAY;gBAC1C,0BAA0B,EAAE,eAAe,CAAC,0BAA0B;gBACtE,uBAAuB,EAAE,eAAe,CAAC,uBAAuB;aACjE,CAAC;YAEF,OAAO,GAAG,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AccessTier,\n ServiceSubmitBatchHeaders,\n ServiceSubmitBatchOptionalParamsModel,\n ServiceSubmitBatchResponseModel,\n} from \"./generatedModels.js\";\nimport type { ParsedBatchResponse } from \"./BatchResponse.js\";\nimport { BatchResponseParser } from \"./BatchResponseParser.js\";\nimport { utf8ByteLength } from \"./BatchUtils.js\";\nimport { BlobBatch } from \"./BlobBatch.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { Service, Container } from \"./generated/src/operationsInterfaces/index.js\";\nimport type { StorageSharedKeyCredential } from \"./credentials/StorageSharedKeyCredential.js\";\nimport { AnonymousCredential } from \"./credentials/AnonymousCredential.js\";\nimport type { BlobDeleteOptions, BlobClient, BlobSetTierOptions } from \"./Clients.js\";\nimport { StorageContextClient } from \"./StorageContextClient.js\";\nimport type { PipelineLike, StoragePipelineOptions } from \"./Pipeline.js\";\nimport { newPipeline, isPipelineLike, getCoreClientOptions } from \"./Pipeline.js\";\nimport type { WithResponse } from \"./utils/utils.common.js\";\nimport { assertResponse, getURLPath } from \"./utils/utils.common.js\";\n\n/**\n * Options to configure the Service - Submit Batch Optional Params.\n */\nexport interface BlobBatchSubmitBatchOptionalParams extends ServiceSubmitBatchOptionalParamsModel {}\n\n/**\n * Contains response data for blob batch operations.\n */\nexport declare type BlobBatchSubmitBatchResponse = WithResponse<\n ParsedBatchResponse & ServiceSubmitBatchHeaders,\n ServiceSubmitBatchHeaders\n>;\n\n/**\n * Contains response data for the {@link deleteBlobs} operation.\n */\nexport declare type BlobBatchDeleteBlobsResponse = BlobBatchSubmitBatchResponse;\n\n/**\n * Contains response data for the {@link setBlobsAccessTier} operation.\n */\nexport declare type BlobBatchSetBlobsAccessTierResponse = BlobBatchSubmitBatchResponse;\n\n/**\n * A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.\n *\n * @see https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch\n */\nexport class BlobBatchClient {\n private serviceOrContainerContext: Service | Container;\n\n /**\n * Creates an instance of BlobBatchClient.\n *\n * @param url - A url pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Options to configure the HTTP pipeline.\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: StoragePipelineOptions,\n );\n\n /**\n * Creates an instance of BlobBatchClient.\n *\n * @param url - A url pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: PipelineLike);\n constructor(\n url: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | PipelineLike,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: StoragePipelineOptions,\n ) {\n let pipeline: PipelineLike;\n if (isPipelineLike(credentialOrPipeline)) {\n pipeline = credentialOrPipeline;\n } else if (!credentialOrPipeline) {\n // no credential provided\n pipeline = newPipeline(new AnonymousCredential(), options);\n } else {\n pipeline = newPipeline(credentialOrPipeline, options);\n }\n\n const storageClientContext = new StorageContextClient(url, getCoreClientOptions(pipeline));\n\n const path = getURLPath(url);\n if (path && path !== \"/\") {\n // Container scoped.\n this.serviceOrContainerContext = storageClientContext.container;\n } else {\n this.serviceOrContainerContext = storageClientContext.service;\n }\n }\n\n /**\n * Creates a {@link BlobBatch}.\n * A BlobBatch represents an aggregated set of operations on blobs.\n */\n public createBatch(): BlobBatch {\n return new BlobBatch();\n }\n\n /**\n * Create multiple delete operations to mark the specified blobs or snapshots for deletion.\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob).\n * The operations will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param urls - The urls of the blob resources to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options -\n */\n public async deleteBlobs(\n urls: string[],\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse>;\n\n /**\n * Create multiple delete operations to mark the specified blobs or snapshots for deletion.\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob).\n * The operation(subrequest) will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClients - The BlobClients for the blobs to delete.\n * @param options -\n */\n public async deleteBlobs(\n blobClients: BlobClient[],\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse>;\n\n public async deleteBlobs(\n urlsOrBlobClients: string[] | BlobClient[],\n credentialOrOptions:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | BlobDeleteOptions\n | undefined,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse> {\n const batch = new BlobBatch();\n for (const urlOrBlobClient of urlsOrBlobClients) {\n if (typeof urlOrBlobClient === \"string\") {\n await batch.deleteBlob(urlOrBlobClient, credentialOrOptions as TokenCredential, options);\n } else {\n await batch.deleteBlob(urlOrBlobClient, credentialOrOptions as BlobDeleteOptions);\n }\n }\n return this.submitBatch(batch);\n }\n\n /**\n * Create multiple set tier operations to set the tier on a blob.\n * The operation is allowed on a page blob in a premium\n * storage account and on a block blob in a blob storage account (locally redundant\n * storage only). A premium page blob's tier determines the allowed size, IOPS,\n * and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive\n * storage type. This operation does not update the blob's ETag.\n * See [set blob tier details](https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-tier).\n * The operation(subrequest) will be authenticated and authorized\n * with specified credential.See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param urls - The urls of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param tier -\n * @param options -\n */\n public async setBlobsAccessTier(\n urls: string[],\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n tier: AccessTier,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse>;\n\n /**\n * Create multiple set tier operations to set the tier on a blob.\n * The operation is allowed on a page blob in a premium\n * storage account and on a block blob in a blob storage account (locally redundant\n * storage only). A premium page blob's tier determines the allowed size, IOPS,\n * and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive\n * storage type. This operation does not update the blob's ETag.\n * See [set blob tier details](https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-tier).\n * The operation(subrequest) will be authenticated and authorized\n * with specified credential.See [blob batch authorization details](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClients - The BlobClients for the blobs which should have a new tier set.\n * @param tier -\n * @param options -\n */\n public async setBlobsAccessTier(\n blobClients: BlobClient[],\n tier: AccessTier,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse>;\n\n public async setBlobsAccessTier(\n urlsOrBlobClients: string[] | BlobClient[],\n credentialOrTier:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | AccessTier,\n tierOrOptions?: AccessTier | BlobSetTierOptions,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse> {\n const batch = new BlobBatch();\n for (const urlOrBlobClient of urlsOrBlobClients) {\n if (typeof urlOrBlobClient === \"string\") {\n await batch.setBlobAccessTier(\n urlOrBlobClient,\n credentialOrTier as TokenCredential,\n tierOrOptions as AccessTier,\n options,\n );\n } else {\n await batch.setBlobAccessTier(\n urlOrBlobClient,\n credentialOrTier as AccessTier,\n tierOrOptions as BlobSetTierOptions,\n );\n }\n }\n return this.submitBatch(batch);\n }\n\n /**\n * Submit batch request which consists of multiple subrequests.\n *\n * Get `blobBatchClient` and other details before running the snippets.\n * `blobServiceClient.getBlobBatchClient()` gives the `blobBatchClient`\n *\n * Example usage:\n *\n * ```ts snippet:BlobBatchClientSubmitBatch\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobServiceClient, BlobBatch } from \"@azure/storage-blob\";\n *\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const blobServiceClient = new BlobServiceClient(\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n *\n * const containerName = \"<container name>\";\n * const containerClient = blobServiceClient.getContainerClient(containerName);\n * const blobBatchClient = containerClient.getBlobBatchClient();\n *\n * const batchRequest = new BlobBatch();\n * await batchRequest.deleteBlob(\"<blob-url-1>\", credential);\n * await batchRequest.deleteBlob(\"<blob-url-2>\", credential, {\n * deleteSnapshots: \"include\",\n * });\n * const batchResp = await blobBatchClient.submitBatch(batchRequest);\n * console.log(batchResp.subResponsesSucceededCount);\n * ```\n *\n * Example using a lease:\n *\n * ```ts snippet:BlobBatchClientSubmitBatchWithLease\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobServiceClient, BlobBatch } from \"@azure/storage-blob\";\n *\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const blobServiceClient = new BlobServiceClient(\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n *\n * const containerName = \"<container name>\";\n * const containerClient = blobServiceClient.getContainerClient(containerName);\n * const blobBatchClient = containerClient.getBlobBatchClient();\n * const blobClient = containerClient.getBlobClient(\"<blob name>\");\n *\n * const batchRequest = new BlobBatch();\n * await batchRequest.setBlobAccessTier(blobClient, \"Cool\");\n * await batchRequest.setBlobAccessTier(blobClient, \"Cool\", {\n * conditions: { leaseId: \"<lease-id>\" },\n * });\n * const batchResp = await blobBatchClient.submitBatch(batchRequest);\n * console.log(batchResp.subResponsesSucceededCount);\n * ```\n *\n * @see https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch\n *\n * @param batchRequest - A set of Delete or SetTier operations.\n * @param options -\n */\n public async submitBatch(\n batchRequest: BlobBatch,\n options: BlobBatchSubmitBatchOptionalParams = {},\n ): Promise<BlobBatchSubmitBatchResponse> {\n if (!batchRequest || batchRequest.getSubRequests().size === 0) {\n throw new RangeError(\"Batch request should contain one or more sub requests.\");\n }\n\n return tracingClient.withSpan(\n \"BlobBatchClient-submitBatch\",\n options,\n async (updatedOptions) => {\n const batchRequestBody = batchRequest.getHttpRequestBody();\n\n // ServiceSubmitBatchResponseModel and ContainerSubmitBatchResponse are compatible for now.\n const rawBatchResponse: ServiceSubmitBatchResponseModel = assertResponse(\n await this.serviceOrContainerContext.submitBatch(\n utf8ByteLength(batchRequestBody),\n batchRequest.getMultiPartContentType(),\n batchRequestBody,\n {\n ...updatedOptions,\n },\n ),\n );\n\n // Parse the sub responses result, if logic reaches here(i.e. the batch request succeeded with status code 202).\n const batchResponseParser = new BatchResponseParser(\n rawBatchResponse,\n batchRequest.getSubRequests(),\n );\n const responseSummary = await batchResponseParser.parseBatchResponse();\n\n const res: BlobBatchSubmitBatchResponse = {\n _response: rawBatchResponse._response,\n contentType: rawBatchResponse.contentType,\n errorCode: rawBatchResponse.errorCode,\n requestId: rawBatchResponse.requestId,\n clientRequestId: rawBatchResponse.clientRequestId,\n version: rawBatchResponse.version,\n subResponses: responseSummary.subResponses,\n subResponsesSucceededCount: responseSummary.subResponsesSucceededCount,\n subResponsesFailedCount: responseSummary.subResponsesFailedCount,\n };\n\n return res;\n },\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"BlobBatchClient.js","sourceRoot":"","sources":["../../src/BlobBatchClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAyBrE;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA8B1B,YACE,GAAW,EACX,oBAIgB;IAChB,mFAAmF;IACnF,gEAAgE;IAChE,OAAgC;QAEhC,IAAI,QAAsB,CAAC;QAC3B,IAAI,cAAc,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACzC,QAAQ,GAAG,oBAAoB,CAAC;QAClC,CAAC;aAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;YACjC,yBAAyB;YACzB,QAAQ,GAAG,WAAW,CAAC,IAAI,mBAAmB,EAAE,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN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C,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,WAAW,EAAE,gBAAgB,CAAC,WAAW;gBACzC,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,eAAe,EAAE,gBAAgB,CAAC,eAAe;gBACjD,OAAO,EAAE,gBAAgB,CAAC,OAAO;gBACjC,YAAY,EAAE,eAAe,CAAC,YAAY;gBAC1C,0BAA0B,EAAE,eAAe,CAAC,0BAA0B;gBACtE,uBAAuB,EAAE,eAAe,CAAC,uBAAuB;aACjE,CAAC;YAEF,OAAO,GAAG,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AccessTier,\n ServiceSubmitBatchHeaders,\n ServiceSubmitBatchOptionalParamsModel,\n ServiceSubmitBatchResponseModel,\n} from \"./generatedModels.js\";\nimport type { ParsedBatchResponse } from \"./BatchResponse.js\";\nimport { BatchResponseParser } from \"./BatchResponseParser.js\";\nimport { utf8ByteLength } from \"./BatchUtils.js\";\nimport { BlobBatch } from \"./BlobBatch.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { Service, Container } from \"./generated/src/operationsInterfaces/index.js\";\nimport type { StorageSharedKeyCredential } from \"./credentials/StorageSharedKeyCredential.js\";\nimport { AnonymousCredential } from \"./credentials/AnonymousCredential.js\";\nimport type { BlobDeleteOptions, BlobClient, BlobSetTierOptions } from \"./Clients.js\";\nimport { StorageContextClient } from \"./StorageContextClient.js\";\nimport type { PipelineLike, StoragePipelineOptions } from \"./Pipeline.js\";\nimport { newPipeline, isPipelineLike, getCoreClientOptions } from \"./Pipeline.js\";\nimport type { WithResponse } from \"./utils/utils.common.js\";\nimport { assertResponse, getURLPath } from \"./utils/utils.common.js\";\n\n/**\n * Options to configure the Service - Submit Batch Optional Params.\n */\nexport interface BlobBatchSubmitBatchOptionalParams extends ServiceSubmitBatchOptionalParamsModel {}\n\n/**\n * Contains response data for blob batch operations.\n */\nexport declare type BlobBatchSubmitBatchResponse = WithResponse<\n ParsedBatchResponse & ServiceSubmitBatchHeaders,\n ServiceSubmitBatchHeaders\n>;\n\n/**\n * Contains response data for the {@link deleteBlobs} operation.\n */\nexport declare type BlobBatchDeleteBlobsResponse = BlobBatchSubmitBatchResponse;\n\n/**\n * Contains response data for the {@link setBlobsAccessTier} operation.\n */\nexport declare type BlobBatchSetBlobsAccessTierResponse = BlobBatchSubmitBatchResponse;\n\n/**\n * A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.\n *\n * @see https://learn.microsoft.com/rest/api/storageservices/blob-batch\n */\nexport class BlobBatchClient {\n private serviceOrContainerContext: Service | Container;\n\n /**\n * Creates an instance of BlobBatchClient.\n *\n * @param url - A url pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options - Options to configure the HTTP pipeline.\n */\n constructor(\n url: string,\n credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: StoragePipelineOptions,\n );\n\n /**\n * Creates an instance of BlobBatchClient.\n *\n * @param url - A url pointing to Azure Storage blob service, such as\n * \"https://myaccount.blob.core.windows.net\". You can append a SAS\n * if using AnonymousCredential, such as \"https://myaccount.blob.core.windows.net?sasString\".\n * @param pipeline - Call newPipeline() to create a default\n * pipeline, or provide a customized pipeline.\n */\n constructor(url: string, pipeline: PipelineLike);\n constructor(\n url: string,\n credentialOrPipeline?:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | PipelineLike,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: StoragePipelineOptions,\n ) {\n let pipeline: PipelineLike;\n if (isPipelineLike(credentialOrPipeline)) {\n pipeline = credentialOrPipeline;\n } else if (!credentialOrPipeline) {\n // no credential provided\n pipeline = newPipeline(new AnonymousCredential(), options);\n } else {\n pipeline = newPipeline(credentialOrPipeline, options);\n }\n\n const storageClientContext = new StorageContextClient(url, getCoreClientOptions(pipeline));\n\n const path = getURLPath(url);\n if (path && path !== \"/\") {\n // Container scoped.\n this.serviceOrContainerContext = storageClientContext.container;\n } else {\n this.serviceOrContainerContext = storageClientContext.service;\n }\n }\n\n /**\n * Creates a {@link BlobBatch}.\n * A BlobBatch represents an aggregated set of operations on blobs.\n */\n public createBatch(): BlobBatch {\n return new BlobBatch();\n }\n\n /**\n * Create multiple delete operations to mark the specified blobs or snapshots for deletion.\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).\n * The operations will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param urls - The urls of the blob resources to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param options -\n */\n public async deleteBlobs(\n urls: string[],\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse>;\n\n /**\n * Create multiple delete operations to mark the specified blobs or snapshots for deletion.\n * Note that in order to delete a blob, you must delete all of its snapshots.\n * You can delete both at the same time. See [delete operation details](https://learn.microsoft.com/rest/api/storageservices/delete-blob).\n * The operation(subrequest) will be authenticated and authorized with specified credential.\n * See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClients - The BlobClients for the blobs to delete.\n * @param options -\n */\n public async deleteBlobs(\n blobClients: BlobClient[],\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse>;\n\n public async deleteBlobs(\n urlsOrBlobClients: string[] | BlobClient[],\n credentialOrOptions:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | BlobDeleteOptions\n | undefined,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobDeleteOptions,\n ): Promise<BlobBatchDeleteBlobsResponse> {\n const batch = new BlobBatch();\n for (const urlOrBlobClient of urlsOrBlobClients) {\n if (typeof urlOrBlobClient === \"string\") {\n await batch.deleteBlob(urlOrBlobClient, credentialOrOptions as TokenCredential, options);\n } else {\n await batch.deleteBlob(urlOrBlobClient, credentialOrOptions as BlobDeleteOptions);\n }\n }\n return this.submitBatch(batch);\n }\n\n /**\n * Create multiple set tier operations to set the tier on a blob.\n * The operation is allowed on a page blob in a premium\n * storage account and on a block blob in a blob storage account (locally redundant\n * storage only). A premium page blob's tier determines the allowed size, IOPS,\n * and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive\n * storage type. This operation does not update the blob's ETag.\n * See [set blob tier details](https://learn.microsoft.com/rest/api/storageservices/set-blob-tier).\n * The operation(subrequest) will be authenticated and authorized\n * with specified credential.See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param urls - The urls of the blob resource to delete.\n * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.\n * @param tier -\n * @param options -\n */\n public async setBlobsAccessTier(\n urls: string[],\n credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,\n tier: AccessTier,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse>;\n\n /**\n * Create multiple set tier operations to set the tier on a blob.\n * The operation is allowed on a page blob in a premium\n * storage account and on a block blob in a blob storage account (locally redundant\n * storage only). A premium page blob's tier determines the allowed size, IOPS,\n * and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive\n * storage type. This operation does not update the blob's ETag.\n * See [set blob tier details](https://learn.microsoft.com/rest/api/storageservices/set-blob-tier).\n * The operation(subrequest) will be authenticated and authorized\n * with specified credential.See [blob batch authorization details](https://learn.microsoft.com/rest/api/storageservices/blob-batch#authorization).\n *\n * @param blobClients - The BlobClients for the blobs which should have a new tier set.\n * @param tier -\n * @param options -\n */\n public async setBlobsAccessTier(\n blobClients: BlobClient[],\n tier: AccessTier,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse>;\n\n public async setBlobsAccessTier(\n urlsOrBlobClients: string[] | BlobClient[],\n credentialOrTier:\n | StorageSharedKeyCredential\n | AnonymousCredential\n | TokenCredential\n | AccessTier,\n tierOrOptions?: AccessTier | BlobSetTierOptions,\n // Legacy, no fix for eslint error without breaking. Disable it for this interface.\n /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/\n options?: BlobSetTierOptions,\n ): Promise<BlobBatchSetBlobsAccessTierResponse> {\n const batch = new BlobBatch();\n for (const urlOrBlobClient of urlsOrBlobClients) {\n if (typeof urlOrBlobClient === \"string\") {\n await batch.setBlobAccessTier(\n urlOrBlobClient,\n credentialOrTier as TokenCredential,\n tierOrOptions as AccessTier,\n options,\n );\n } else {\n await batch.setBlobAccessTier(\n urlOrBlobClient,\n credentialOrTier as AccessTier,\n tierOrOptions as BlobSetTierOptions,\n );\n }\n }\n return this.submitBatch(batch);\n }\n\n /**\n * Submit batch request which consists of multiple subrequests.\n *\n * Get `blobBatchClient` and other details before running the snippets.\n * `blobServiceClient.getBlobBatchClient()` gives the `blobBatchClient`\n *\n * Example usage:\n *\n * ```ts snippet:BlobBatchClientSubmitBatch\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobServiceClient, BlobBatch } from \"@azure/storage-blob\";\n *\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const blobServiceClient = new BlobServiceClient(\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n *\n * const containerName = \"<container name>\";\n * const containerClient = blobServiceClient.getContainerClient(containerName);\n * const blobBatchClient = containerClient.getBlobBatchClient();\n *\n * const batchRequest = new BlobBatch();\n * await batchRequest.deleteBlob(\"<blob-url-1>\", credential);\n * await batchRequest.deleteBlob(\"<blob-url-2>\", credential, {\n * deleteSnapshots: \"include\",\n * });\n * const batchResp = await blobBatchClient.submitBatch(batchRequest);\n * console.log(batchResp.subResponsesSucceededCount);\n * ```\n *\n * Example using a lease:\n *\n * ```ts snippet:BlobBatchClientSubmitBatchWithLease\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { BlobServiceClient, BlobBatch } from \"@azure/storage-blob\";\n *\n * const account = \"<account>\";\n * const credential = new DefaultAzureCredential();\n * const blobServiceClient = new BlobServiceClient(\n * `https://${account}.blob.core.windows.net`,\n * credential,\n * );\n *\n * const containerName = \"<container name>\";\n * const containerClient = blobServiceClient.getContainerClient(containerName);\n * const blobBatchClient = containerClient.getBlobBatchClient();\n * const blobClient = containerClient.getBlobClient(\"<blob name>\");\n *\n * const batchRequest = new BlobBatch();\n * await batchRequest.setBlobAccessTier(blobClient, \"Cool\");\n * await batchRequest.setBlobAccessTier(blobClient, \"Cool\", {\n * conditions: { leaseId: \"<lease-id>\" },\n * });\n * const batchResp = await blobBatchClient.submitBatch(batchRequest);\n * console.log(batchResp.subResponsesSucceededCount);\n * ```\n *\n * @see https://learn.microsoft.com/rest/api/storageservices/blob-batch\n *\n * @param batchRequest - A set of Delete or SetTier operations.\n * @param options -\n */\n public async submitBatch(\n batchRequest: BlobBatch,\n options: BlobBatchSubmitBatchOptionalParams = {},\n ): Promise<BlobBatchSubmitBatchResponse> {\n if (!batchRequest || batchRequest.getSubRequests().size === 0) {\n throw new RangeError(\"Batch request should contain one or more sub requests.\");\n }\n\n return tracingClient.withSpan(\n \"BlobBatchClient-submitBatch\",\n options,\n async (updatedOptions) => {\n const batchRequestBody = batchRequest.getHttpRequestBody();\n\n // ServiceSubmitBatchResponseModel and ContainerSubmitBatchResponse are compatible for now.\n const rawBatchResponse: ServiceSubmitBatchResponseModel = assertResponse(\n await this.serviceOrContainerContext.submitBatch(\n utf8ByteLength(batchRequestBody),\n batchRequest.getMultiPartContentType(),\n batchRequestBody,\n {\n ...updatedOptions,\n },\n ),\n );\n\n // Parse the sub responses result, if logic reaches here(i.e. the batch request succeeded with status code 202).\n const batchResponseParser = new BatchResponseParser(\n rawBatchResponse,\n batchRequest.getSubRequests(),\n );\n const responseSummary = await batchResponseParser.parseBatchResponse();\n\n const res: BlobBatchSubmitBatchResponse = {\n _response: rawBatchResponse._response,\n contentType: rawBatchResponse.contentType,\n errorCode: rawBatchResponse.errorCode,\n requestId: rawBatchResponse.requestId,\n clientRequestId: rawBatchResponse.clientRequestId,\n version: rawBatchResponse.version,\n subResponses: responseSummary.subResponses,\n subResponsesSucceededCount: responseSummary.subResponsesSucceededCount,\n subResponsesFailedCount: responseSummary.subResponsesFailedCount,\n };\n\n return res;\n },\n );\n }\n}\n"]}
|
@@ -102,9 +102,9 @@ export declare class BlobLeaseClient {
|
|
102
102
|
* Establishes and manages a lock on a container for delete operations, or on a blob
|
103
103
|
* for write and delete operations.
|
104
104
|
* The lock duration can be 15 to 60 seconds, or can be infinite.
|
105
|
-
* @see https://learn.microsoft.com/
|
105
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
106
106
|
* and
|
107
|
-
* @see https://learn.microsoft.com/
|
107
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
108
108
|
*
|
109
109
|
* @param duration - Must be between 15 to 60 seconds, or infinite (-1)
|
110
110
|
* @param options - option to configure lease management operations.
|
@@ -113,9 +113,9 @@ export declare class BlobLeaseClient {
|
|
113
113
|
acquireLease(duration: number, options?: LeaseOperationOptions): Promise<LeaseOperationResponse>;
|
114
114
|
/**
|
115
115
|
* To change the ID of the lease.
|
116
|
-
* @see https://learn.microsoft.com/
|
116
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
117
117
|
* and
|
118
|
-
* @see https://learn.microsoft.com/
|
118
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
119
119
|
*
|
120
120
|
* @param proposedLeaseId - the proposed new lease Id.
|
121
121
|
* @param options - option to configure lease management operations.
|
@@ -125,9 +125,9 @@ export declare class BlobLeaseClient {
|
|
125
125
|
/**
|
126
126
|
* To free the lease if it is no longer needed so that another client may
|
127
127
|
* immediately acquire a lease against the container or the blob.
|
128
|
-
* @see https://learn.microsoft.com/
|
128
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
129
129
|
* and
|
130
|
-
* @see https://learn.microsoft.com/
|
130
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
131
131
|
*
|
132
132
|
* @param options - option to configure lease management operations.
|
133
133
|
* @returns Response data for release lease operation.
|
@@ -135,9 +135,9 @@ export declare class BlobLeaseClient {
|
|
135
135
|
releaseLease(options?: LeaseOperationOptions): Promise<LeaseOperationResponse>;
|
136
136
|
/**
|
137
137
|
* To renew the lease.
|
138
|
-
* @see https://learn.microsoft.com/
|
138
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
139
139
|
* and
|
140
|
-
* @see https://learn.microsoft.com/
|
140
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
141
141
|
*
|
142
142
|
* @param options - Optional option to configure lease management operations.
|
143
143
|
* @returns Response data for renew lease operation.
|
@@ -146,9 +146,9 @@ export declare class BlobLeaseClient {
|
|
146
146
|
/**
|
147
147
|
* To end the lease but ensure that another client cannot acquire a new lease
|
148
148
|
* until the current lease period has expired.
|
149
|
-
* @see https://learn.microsoft.com/
|
149
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
150
150
|
* and
|
151
|
-
* @see https://learn.microsoft.com/
|
151
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
152
152
|
*
|
153
153
|
* @param breakPeriod - Break period
|
154
154
|
* @param options - Optional options to configure lease management operations.
|
@@ -49,9 +49,9 @@ export class BlobLeaseClient {
|
|
49
49
|
* Establishes and manages a lock on a container for delete operations, or on a blob
|
50
50
|
* for write and delete operations.
|
51
51
|
* The lock duration can be 15 to 60 seconds, or can be infinite.
|
52
|
-
* @see https://learn.microsoft.com/
|
52
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
53
53
|
* and
|
54
|
-
* @see https://learn.microsoft.com/
|
54
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
55
55
|
*
|
56
56
|
* @param duration - Must be between 15 to 60 seconds, or infinite (-1)
|
57
57
|
* @param options - option to configure lease management operations.
|
@@ -78,9 +78,9 @@ export class BlobLeaseClient {
|
|
78
78
|
}
|
79
79
|
/**
|
80
80
|
* To change the ID of the lease.
|
81
|
-
* @see https://learn.microsoft.com/
|
81
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
82
82
|
* and
|
83
|
-
* @see https://learn.microsoft.com/
|
83
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
84
84
|
*
|
85
85
|
* @param proposedLeaseId - the proposed new lease Id.
|
86
86
|
* @param options - option to configure lease management operations.
|
@@ -108,9 +108,9 @@ export class BlobLeaseClient {
|
|
108
108
|
/**
|
109
109
|
* To free the lease if it is no longer needed so that another client may
|
110
110
|
* immediately acquire a lease against the container or the blob.
|
111
|
-
* @see https://learn.microsoft.com/
|
111
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
112
112
|
* and
|
113
|
-
* @see https://learn.microsoft.com/
|
113
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
114
114
|
*
|
115
115
|
* @param options - option to configure lease management operations.
|
116
116
|
* @returns Response data for release lease operation.
|
@@ -134,9 +134,9 @@ export class BlobLeaseClient {
|
|
134
134
|
}
|
135
135
|
/**
|
136
136
|
* To renew the lease.
|
137
|
-
* @see https://learn.microsoft.com/
|
137
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
138
138
|
* and
|
139
|
-
* @see https://learn.microsoft.com/
|
139
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
140
140
|
*
|
141
141
|
* @param options - Optional option to configure lease management operations.
|
142
142
|
* @returns Response data for renew lease operation.
|
@@ -161,9 +161,9 @@ export class BlobLeaseClient {
|
|
161
161
|
/**
|
162
162
|
* To end the lease but ensure that another client cannot acquire a new lease
|
163
163
|
* until the current lease period has expired.
|
164
|
-
* @see https://learn.microsoft.com/
|
164
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-container
|
165
165
|
* and
|
166
|
-
* @see https://learn.microsoft.com/
|
166
|
+
* @see https://learn.microsoft.com/rest/api/storageservices/lease-blob
|
167
167
|
*
|
168
168
|
* @param breakPeriod - Break period
|
169
169
|
* @param options - Optional options to configure lease management operations.
|