[storage-blob] Upgrade to core-tracing 1.0 (#24548)
This commit is contained in:
Родитель
8258aebdf8
Коммит
74d52a8cca
|
@ -139,7 +139,7 @@
|
|||
"@azure/core-lro": "^2.2.0",
|
||||
"@azure/core-paging": "^1.1.1",
|
||||
"@azure/core-rest-pipeline": "^1.10.1",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/core-tracing": "^1.0.0",
|
||||
"@azure/core-util": "^1.1.1",
|
||||
"@azure/core-xml": "^1.3.2",
|
||||
"@azure/logger": "^1.0.0",
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
SendRequest,
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
import { BlobClient, BlobDeleteOptions, BlobSetTierOptions } from "./Clients";
|
||||
import { AccessTier } from "./generatedModels";
|
||||
|
@ -29,7 +28,7 @@ import {
|
|||
StorageOAuthScopes,
|
||||
} from "./utils/constants";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { tracingClient } from "./utils/tracing";
|
||||
import { authorizeRequestOnTenantChallenge, serializationPolicy } from "@azure/core-client";
|
||||
import { storageSharedKeyCredentialPolicy } from "./policies/StorageSharedKeyCredentialPolicyV2";
|
||||
import { pathParameterWorkaroundPolicy } from "./policies/PathParameterWorkaroundPolicy";
|
||||
|
@ -185,9 +184,7 @@ export class BlobBatch {
|
|||
options = {};
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("BatchDeleteRequest-addSubRequest", options);
|
||||
|
||||
try {
|
||||
tracingClient.withSpan("BatchDeleteRequest-addSubRequest", options, async (updatedOptions) => {
|
||||
this.setBatchType("delete");
|
||||
await this.addSubRequestInternal(
|
||||
{
|
||||
|
@ -200,15 +197,7 @@ export class BlobBatch {
|
|||
);
|
||||
}
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,31 +289,25 @@ export class BlobBatch {
|
|||
options = {};
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("BatchSetTierRequest-addSubRequest", options);
|
||||
|
||||
try {
|
||||
this.setBatchType("setAccessTier");
|
||||
await this.addSubRequestInternal(
|
||||
{
|
||||
url: url,
|
||||
credential: credential,
|
||||
},
|
||||
async () => {
|
||||
await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier(
|
||||
tier,
|
||||
updatedOptions
|
||||
);
|
||||
}
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BatchSetTierRequest-addSubRequest",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
this.setBatchType("setAccessTier");
|
||||
await this.addSubRequestInternal(
|
||||
{
|
||||
url: url,
|
||||
credential: credential,
|
||||
},
|
||||
async () => {
|
||||
await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier(
|
||||
tier,
|
||||
updatedOptions
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ import { ParsedBatchResponse } from "./BatchResponse";
|
|||
import { BatchResponseParser } from "./BatchResponseParser";
|
||||
import { utf8ByteLength } from "./BatchUtils";
|
||||
import { BlobBatch } from "./BlobBatch";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { tracingClient } from "./utils/tracing";
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { Service, Container } from "./generated/src/operationsInterfaces";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
|
@ -308,50 +307,45 @@ export class BlobBatchClient {
|
|||
throw new RangeError("Batch request should contain one or more sub requests.");
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("BlobBatchClient-submitBatch", options);
|
||||
try {
|
||||
const batchRequestBody = batchRequest.getHttpRequestBody();
|
||||
return tracingClient.withSpan(
|
||||
"BlobBatchClient-submitBatch",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const batchRequestBody = batchRequest.getHttpRequestBody();
|
||||
|
||||
// ServiceSubmitBatchResponseModel and ContainerSubmitBatchResponse are compatible for now.
|
||||
const rawBatchResponse: ServiceSubmitBatchResponseModel = assertResponse(
|
||||
await this.serviceOrContainerContext.submitBatch(
|
||||
utf8ByteLength(batchRequestBody),
|
||||
batchRequest.getMultiPartContentType(),
|
||||
batchRequestBody,
|
||||
{
|
||||
...updatedOptions,
|
||||
}
|
||||
)
|
||||
);
|
||||
// ServiceSubmitBatchResponseModel and ContainerSubmitBatchResponse are compatible for now.
|
||||
const rawBatchResponse: ServiceSubmitBatchResponseModel = assertResponse(
|
||||
await this.serviceOrContainerContext.submitBatch(
|
||||
utf8ByteLength(batchRequestBody),
|
||||
batchRequest.getMultiPartContentType(),
|
||||
batchRequestBody,
|
||||
{
|
||||
...updatedOptions,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Parse the sub responses result, if logic reaches here(i.e. the batch request succeeded with status code 202).
|
||||
const batchResponseParser = new BatchResponseParser(
|
||||
rawBatchResponse,
|
||||
batchRequest.getSubRequests()
|
||||
);
|
||||
const responseSummary = await batchResponseParser.parseBatchResponse();
|
||||
// Parse the sub responses result, if logic reaches here(i.e. the batch request succeeded with status code 202).
|
||||
const batchResponseParser = new BatchResponseParser(
|
||||
rawBatchResponse,
|
||||
batchRequest.getSubRequests()
|
||||
);
|
||||
const responseSummary = await batchResponseParser.parseBatchResponse();
|
||||
|
||||
const res: BlobBatchSubmitBatchResponse = {
|
||||
_response: rawBatchResponse._response,
|
||||
contentType: rawBatchResponse.contentType,
|
||||
errorCode: rawBatchResponse.errorCode,
|
||||
requestId: rawBatchResponse.requestId,
|
||||
clientRequestId: rawBatchResponse.clientRequestId,
|
||||
version: rawBatchResponse.version,
|
||||
subResponses: responseSummary.subResponses,
|
||||
subResponsesSucceededCount: responseSummary.subResponsesSucceededCount,
|
||||
subResponsesFailedCount: responseSummary.subResponsesFailedCount,
|
||||
};
|
||||
const res: BlobBatchSubmitBatchResponse = {
|
||||
_response: rawBatchResponse._response,
|
||||
contentType: rawBatchResponse.contentType,
|
||||
errorCode: rawBatchResponse.errorCode,
|
||||
requestId: rawBatchResponse.requestId,
|
||||
clientRequestId: rawBatchResponse.clientRequestId,
|
||||
version: rawBatchResponse.version,
|
||||
subResponses: responseSummary.subResponses,
|
||||
subResponsesSucceededCount: responseSummary.subResponsesSucceededCount,
|
||||
subResponsesFailedCount: responseSummary.subResponsesFailedCount,
|
||||
};
|
||||
|
||||
return res;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,19 @@
|
|||
import { v4 as generateUuid } from "uuid";
|
||||
import { ContainerBreakLeaseOptionalParams } from "./generatedModels";
|
||||
import { AbortSignalLike } from "@azure/abort-controller";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { Blob as StorageBlob, Container } from "./generated/src/operationsInterfaces";
|
||||
import { ModifiedAccessConditions } from "./models";
|
||||
import { CommonOptions } from "./StorageClient";
|
||||
import { ETagNone } from "./utils/constants";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { tracingClient } from "./utils/tracing";
|
||||
import { BlobClient } from "./Clients";
|
||||
import { ContainerClient } from "./ContainerClient";
|
||||
import { assertResponse, WithResponse } from "./utils/utils.common";
|
||||
import {
|
||||
ContainerAcquireLeaseHeaders,
|
||||
ContainerBreakLeaseHeaders,
|
||||
ContainerReleaseLeaseHeaders,
|
||||
} from "./generated/src";
|
||||
|
||||
/**
|
||||
* The details for a specific lease.
|
||||
|
@ -150,8 +154,6 @@ export class BlobLeaseClient {
|
|||
duration: number,
|
||||
options: LeaseOperationOptions = {}
|
||||
): Promise<LeaseOperationResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobLeaseClient-acquireLease", options);
|
||||
|
||||
if (
|
||||
this._isContainer &&
|
||||
((options.conditions?.ifMatch && options.conditions?.ifMatch !== ETagNone) ||
|
||||
|
@ -162,29 +164,24 @@ export class BlobLeaseClient {
|
|||
"The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable."
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return assertResponse(
|
||||
await this._containerOrBlobOperation.acquireLease({
|
||||
abortSignal: options.abortSignal,
|
||||
duration,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
proposedLeaseId: this._leaseId,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobLeaseClient-acquireLease",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ContainerAcquireLeaseHeaders, ContainerAcquireLeaseHeaders>(
|
||||
await this._containerOrBlobOperation.acquireLease({
|
||||
abortSignal: options.abortSignal,
|
||||
duration,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
proposedLeaseId: this._leaseId,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,8 +198,6 @@ export class BlobLeaseClient {
|
|||
proposedLeaseId: string,
|
||||
options: LeaseOperationOptions = {}
|
||||
): Promise<LeaseOperationResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobLeaseClient-changeLease", options);
|
||||
|
||||
if (
|
||||
this._isContainer &&
|
||||
((options.conditions?.ifMatch && options.conditions?.ifMatch !== ETagNone) ||
|
||||
|
@ -214,28 +209,24 @@ export class BlobLeaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = assertResponse<Lease, Lease>(
|
||||
await this._containerOrBlobOperation.changeLease(this._leaseId, proposedLeaseId, {
|
||||
abortSignal: options.abortSignal,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
this._leaseId = proposedLeaseId;
|
||||
return response;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobLeaseClient-changeLease",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<Lease, Lease>(
|
||||
await this._containerOrBlobOperation.changeLease(this._leaseId, proposedLeaseId, {
|
||||
abortSignal: options.abortSignal,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
this._leaseId = proposedLeaseId;
|
||||
return response;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,8 +240,6 @@ export class BlobLeaseClient {
|
|||
* @returns Response data for release lease operation.
|
||||
*/
|
||||
public async releaseLease(options: LeaseOperationOptions = {}): Promise<LeaseOperationResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobLeaseClient-releaseLease", options);
|
||||
|
||||
if (
|
||||
this._isContainer &&
|
||||
((options.conditions?.ifMatch && options.conditions?.ifMatch !== ETagNone) ||
|
||||
|
@ -261,27 +250,22 @@ export class BlobLeaseClient {
|
|||
"The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable."
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return assertResponse(
|
||||
await this._containerOrBlobOperation.releaseLease(this._leaseId, {
|
||||
abortSignal: options.abortSignal,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobLeaseClient-releaseLease",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ContainerReleaseLeaseHeaders, ContainerReleaseLeaseHeaders>(
|
||||
await this._containerOrBlobOperation.releaseLease(this._leaseId, {
|
||||
abortSignal: options.abortSignal,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
ifTags: options.conditions?.tagConditions,
|
||||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,8 +278,6 @@ export class BlobLeaseClient {
|
|||
* @returns Response data for renew lease operation.
|
||||
*/
|
||||
public async renewLease(options: LeaseOperationOptions = {}): Promise<Lease> {
|
||||
const { span, updatedOptions } = createSpan("BlobLeaseClient-renewLease", options);
|
||||
|
||||
if (
|
||||
this._isContainer &&
|
||||
((options.conditions?.ifMatch && options.conditions?.ifMatch !== ETagNone) ||
|
||||
|
@ -306,9 +288,8 @@ export class BlobLeaseClient {
|
|||
"The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable."
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return await this._containerOrBlobOperation.renewLease(this._leaseId, {
|
||||
return tracingClient.withSpan("BlobLeaseClient-renewLease", options, async (updatedOptions) => {
|
||||
return this._containerOrBlobOperation.renewLease(this._leaseId, {
|
||||
abortSignal: options.abortSignal,
|
||||
modifiedAccessConditions: {
|
||||
...options.conditions,
|
||||
|
@ -316,15 +297,7 @@ export class BlobLeaseClient {
|
|||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
});
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,8 +315,6 @@ export class BlobLeaseClient {
|
|||
breakPeriod: number,
|
||||
options: LeaseOperationOptions = {}
|
||||
): Promise<LeaseOperationResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobLeaseClient-breakLease", options);
|
||||
|
||||
if (
|
||||
this._isContainer &&
|
||||
((options.conditions?.ifMatch && options.conditions?.ifMatch !== ETagNone) ||
|
||||
|
@ -355,7 +326,7 @@ export class BlobLeaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return tracingClient.withSpan("BlobLeaseClient-breakLease", options, async (updatedOptions) => {
|
||||
const operationOptions: ContainerBreakLeaseOptionalParams = {
|
||||
abortSignal: options.abortSignal,
|
||||
breakPeriod,
|
||||
|
@ -365,15 +336,9 @@ export class BlobLeaseClient {
|
|||
},
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
};
|
||||
return assertResponse(await this._containerOrBlobOperation.breakLease(operationOptions));
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return assertResponse<ContainerBreakLeaseHeaders, ContainerBreakLeaseHeaders>(
|
||||
await this._containerOrBlobOperation.breakLease(operationOptions)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import { TokenCredential, isTokenCredential } from "@azure/core-auth";
|
||||
import { getDefaultProxySettings } from "@azure/core-rest-pipeline";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { AbortSignalLike } from "@azure/abort-controller";
|
||||
import {
|
||||
ServiceGetUserDelegationKeyHeaders,
|
||||
|
@ -24,6 +23,9 @@ import {
|
|||
LeaseAccessConditions,
|
||||
FilterBlobSegment,
|
||||
FilterBlobItem,
|
||||
ServiceGetPropertiesResponseInternal,
|
||||
ServiceGetStatisticsResponseInternal,
|
||||
ServiceListContainersSegmentResponseInternal,
|
||||
} from "./generatedModels";
|
||||
import { Service } from "./generated/src/operationsInterfaces";
|
||||
import { newPipeline, StoragePipelineOptions, PipelineLike, isPipelineLike } from "./Pipeline";
|
||||
|
@ -41,10 +43,9 @@ import {
|
|||
} from "./utils/utils.common";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
import "@azure/core-paging";
|
||||
import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging";
|
||||
import { truncatedISO8061Date, assertResponse } from "./utils/utils.common";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { tracingClient } from "./utils/tracing";
|
||||
import { BlobBatchClient } from "./BlobBatchClient";
|
||||
import { CommonOptions, StorageClient } from "./StorageClient";
|
||||
import { AccountSASPermissions } from "./sas/AccountSASPermissions";
|
||||
|
@ -57,7 +58,12 @@ import {
|
|||
ContainerRestoreHeaders,
|
||||
ListContainersIncludeType,
|
||||
ServiceFilterBlobsResponse,
|
||||
ServiceGetAccountInfoHeaders,
|
||||
ServiceGetPropertiesHeaders,
|
||||
ServiceGetStatisticsHeaders,
|
||||
ServiceGetUserDelegationKeyResponse as ServiceGetUserDelegationKeyResponseModel,
|
||||
ServiceListContainersSegmentHeaders,
|
||||
ServiceSetPropertiesHeaders,
|
||||
} from "./generated/src";
|
||||
|
||||
/**
|
||||
|
@ -491,23 +497,18 @@ export class BlobServiceClient extends StorageClient {
|
|||
containerClient: ContainerClient;
|
||||
containerCreateResponse: ContainerCreateResponse;
|
||||
}> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-createContainer", options);
|
||||
try {
|
||||
const containerClient = this.getContainerClient(containerName);
|
||||
const containerCreateResponse = await containerClient.create(updatedOptions);
|
||||
return {
|
||||
containerClient,
|
||||
containerCreateResponse,
|
||||
};
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-createContainer",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const containerClient = this.getContainerClient(containerName);
|
||||
const containerCreateResponse = await containerClient.create(updatedOptions);
|
||||
return {
|
||||
containerClient,
|
||||
containerCreateResponse,
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -521,19 +522,14 @@ export class BlobServiceClient extends StorageClient {
|
|||
containerName: string,
|
||||
options: ContainerDeleteMethodOptions = {}
|
||||
): Promise<ContainerDeleteResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-deleteContainer", options);
|
||||
try {
|
||||
const containerClient = this.getContainerClient(containerName);
|
||||
return await containerClient.delete(updatedOptions);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-deleteContainer",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const containerClient = this.getContainerClient(containerName);
|
||||
return containerClient.delete(updatedOptions);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,33 +549,28 @@ export class BlobServiceClient extends StorageClient {
|
|||
containerClient: ContainerClient;
|
||||
containerUndeleteResponse: ContainerUndeleteResponse;
|
||||
}> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-undeleteContainer", options);
|
||||
try {
|
||||
const containerClient = this.getContainerClient(
|
||||
options.destinationContainerName || deletedContainerName
|
||||
);
|
||||
// Hack to access a protected member.
|
||||
const containerContext = containerClient["storageClientContext"].container;
|
||||
const containerUndeleteResponse = assertResponse<
|
||||
ContainerRestoreHeaders,
|
||||
ContainerRestoreHeaders
|
||||
>(
|
||||
await containerContext.restore({
|
||||
deletedContainerName,
|
||||
deletedContainerVersion,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
return { containerClient, containerUndeleteResponse };
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-undeleteContainer",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const containerClient = this.getContainerClient(
|
||||
options.destinationContainerName || deletedContainerName
|
||||
);
|
||||
// Hack to access a protected member.
|
||||
const containerContext = containerClient["storageClientContext"].container;
|
||||
const containerUndeleteResponse = assertResponse<
|
||||
ContainerRestoreHeaders,
|
||||
ContainerRestoreHeaders
|
||||
>(
|
||||
await containerContext.restore({
|
||||
deletedContainerName,
|
||||
deletedContainerVersion,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
return { containerClient, containerUndeleteResponse };
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -599,30 +590,25 @@ export class BlobServiceClient extends StorageClient {
|
|||
containerClient: ContainerClient;
|
||||
containerRenameResponse: ContainerRenameResponse;
|
||||
}> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-renameContainer", options);
|
||||
try {
|
||||
const containerClient = this.getContainerClient(destinationContainerName);
|
||||
// Hack to access a protected member.
|
||||
const containerContext = containerClient["storageClientContext"].container;
|
||||
const containerRenameResponse = assertResponse<
|
||||
ContainerRenameHeaders,
|
||||
ContainerRenameHeaders
|
||||
>(
|
||||
await containerContext.rename(sourceContainerName, {
|
||||
...updatedOptions,
|
||||
sourceLeaseId: options.sourceCondition?.leaseId,
|
||||
})
|
||||
);
|
||||
return { containerClient, containerRenameResponse };
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-renameContainer",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const containerClient = this.getContainerClient(destinationContainerName);
|
||||
// Hack to access a protected member.
|
||||
const containerContext = containerClient["storageClientContext"].container;
|
||||
const containerRenameResponse = assertResponse<
|
||||
ContainerRenameHeaders,
|
||||
ContainerRenameHeaders
|
||||
>(
|
||||
await containerContext.rename(sourceContainerName, {
|
||||
...updatedOptions,
|
||||
sourceLeaseId: options.sourceCondition?.leaseId,
|
||||
})
|
||||
);
|
||||
return { containerClient, containerRenameResponse };
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -636,23 +622,18 @@ export class BlobServiceClient extends StorageClient {
|
|||
public async getProperties(
|
||||
options: ServiceGetPropertiesOptions = {}
|
||||
): Promise<ServiceGetPropertiesResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-getProperties", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.serviceContext.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-getProperties",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ServiceGetPropertiesResponseInternal, ServiceGetPropertiesHeaders>(
|
||||
await this.serviceContext.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -668,23 +649,18 @@ export class BlobServiceClient extends StorageClient {
|
|||
properties: BlobServiceProperties,
|
||||
options: ServiceSetPropertiesOptions = {}
|
||||
): Promise<ServiceSetPropertiesResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-setProperties", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.serviceContext.setProperties(properties, {
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-setProperties",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ServiceSetPropertiesHeaders, ServiceSetPropertiesHeaders>(
|
||||
await this.serviceContext.setProperties(properties, {
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -699,23 +675,18 @@ export class BlobServiceClient extends StorageClient {
|
|||
public async getStatistics(
|
||||
options: ServiceGetStatisticsOptions = {}
|
||||
): Promise<ServiceGetStatisticsResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-getStatistics", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.serviceContext.getStatistics({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-getStatistics",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ServiceGetStatisticsResponseInternal, ServiceGetStatisticsHeaders>(
|
||||
await this.serviceContext.getStatistics({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -731,23 +702,18 @@ export class BlobServiceClient extends StorageClient {
|
|||
public async getAccountInfo(
|
||||
options: ServiceGetAccountInfoOptions = {}
|
||||
): Promise<ServiceGetAccountInfoResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-getAccountInfo", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.serviceContext.getAccountInfo({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-getAccountInfo",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ServiceGetAccountInfoHeaders, ServiceGetAccountInfoHeaders>(
|
||||
await this.serviceContext.getAccountInfo({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -768,27 +734,24 @@ export class BlobServiceClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ServiceListContainersSegmentOptions = {}
|
||||
): Promise<ServiceListContainersSegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-listContainersSegment", options);
|
||||
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.serviceContext.listContainersSegment({
|
||||
abortSignal: options.abortSignal,
|
||||
marker,
|
||||
...options,
|
||||
include: typeof options.include === "string" ? [options.include] : options.include,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-listContainersSegment",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<
|
||||
ServiceListContainersSegmentResponseInternal,
|
||||
ServiceListContainersSegmentHeaders
|
||||
>(
|
||||
await this.serviceContext.listContainersSegment({
|
||||
abortSignal: options.abortSignal,
|
||||
marker,
|
||||
...options,
|
||||
include: typeof options.include === "string" ? [options.include] : options.include,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -814,47 +777,38 @@ export class BlobServiceClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ServiceFindBlobsByTagsSegmentOptions = {}
|
||||
): Promise<ServiceFindBlobsByTagsSegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan(
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-findBlobsByTagsSegment",
|
||||
options
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ServiceFilterBlobsResponse,
|
||||
ServiceFilterBlobsHeaders,
|
||||
FilterBlobSegmentModel
|
||||
>(
|
||||
await this.serviceContext.filterBlobs({
|
||||
abortSignal: options.abortSignal,
|
||||
where: tagFilterSqlExpression,
|
||||
marker,
|
||||
maxPageSize: options.maxPageSize,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
const wrappedResponse: ServiceFindBlobsByTagsSegmentResponse = {
|
||||
...response,
|
||||
_response: response._response, // _response is made non-enumerable
|
||||
blobs: response.blobs.map((blob) => {
|
||||
let tagValue = "";
|
||||
if (blob.tags?.blobTagSet.length === 1) {
|
||||
tagValue = blob.tags.blobTagSet[0].value;
|
||||
}
|
||||
return { ...blob, tags: toTags(blob.tags), tagValue };
|
||||
}),
|
||||
};
|
||||
return wrappedResponse;
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ServiceFilterBlobsResponse,
|
||||
ServiceFilterBlobsHeaders,
|
||||
FilterBlobSegmentModel
|
||||
>(
|
||||
await this.serviceContext.filterBlobs({
|
||||
abortSignal: options.abortSignal,
|
||||
where: tagFilterSqlExpression,
|
||||
marker,
|
||||
maxPageSize: options.maxPageSize,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
const wrappedResponse: ServiceFindBlobsByTagsSegmentResponse = {
|
||||
...response,
|
||||
_response: response._response, // _response is made non-enumerable
|
||||
blobs: response.blobs.map((blob) => {
|
||||
let tagValue = "";
|
||||
if (blob.tags?.blobTagSet.length === 1) {
|
||||
tagValue = blob.tags.blobTagSet[0].value;
|
||||
}
|
||||
return { ...blob, tags: toTags(blob.tags), tagValue };
|
||||
}),
|
||||
};
|
||||
return wrappedResponse;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1208,55 +1162,50 @@ export class BlobServiceClient extends StorageClient {
|
|||
expiresOn: Date,
|
||||
options: ServiceGetUserDelegationKeyOptions = {}
|
||||
): Promise<ServiceGetUserDelegationKeyResponse> {
|
||||
const { span, updatedOptions } = createSpan("BlobServiceClient-getUserDelegationKey", options);
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ServiceGetUserDelegationKeyResponseModel,
|
||||
ServiceGetUserDelegationKeyHeaders,
|
||||
UserDelegationKeyModel
|
||||
>(
|
||||
await this.serviceContext.getUserDelegationKey(
|
||||
{
|
||||
startsOn: truncatedISO8061Date(startsOn, false),
|
||||
expiresOn: truncatedISO8061Date(expiresOn, false),
|
||||
},
|
||||
{
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
}
|
||||
)
|
||||
);
|
||||
return tracingClient.withSpan(
|
||||
"BlobServiceClient-getUserDelegationKey",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ServiceGetUserDelegationKeyResponseModel,
|
||||
ServiceGetUserDelegationKeyHeaders,
|
||||
UserDelegationKeyModel
|
||||
>(
|
||||
await this.serviceContext.getUserDelegationKey(
|
||||
{
|
||||
startsOn: truncatedISO8061Date(startsOn, false),
|
||||
expiresOn: truncatedISO8061Date(expiresOn, false),
|
||||
},
|
||||
{
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const userDelegationKey = {
|
||||
signedObjectId: response.signedObjectId,
|
||||
signedTenantId: response.signedTenantId,
|
||||
signedStartsOn: new Date(response.signedStartsOn),
|
||||
signedExpiresOn: new Date(response.signedExpiresOn),
|
||||
signedService: response.signedService,
|
||||
signedVersion: response.signedVersion,
|
||||
value: response.value,
|
||||
};
|
||||
const userDelegationKey = {
|
||||
signedObjectId: response.signedObjectId,
|
||||
signedTenantId: response.signedTenantId,
|
||||
signedStartsOn: new Date(response.signedStartsOn),
|
||||
signedExpiresOn: new Date(response.signedExpiresOn),
|
||||
signedService: response.signedService,
|
||||
signedVersion: response.signedVersion,
|
||||
value: response.value,
|
||||
};
|
||||
|
||||
const res: ServiceGetUserDelegationKeyResponse = {
|
||||
_response: response._response,
|
||||
requestId: response.requestId,
|
||||
clientRequestId: response.clientRequestId,
|
||||
version: response.version,
|
||||
date: response.date,
|
||||
errorCode: response.errorCode,
|
||||
...userDelegationKey,
|
||||
};
|
||||
const res: ServiceGetUserDelegationKeyResponse = {
|
||||
_response: response._response,
|
||||
requestId: response.requestId,
|
||||
clientRequestId: response.clientRequestId,
|
||||
version: response.version,
|
||||
date: response.date,
|
||||
errorCode: response.errorCode,
|
||||
...userDelegationKey,
|
||||
};
|
||||
|
||||
return res;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -8,7 +8,6 @@ import {
|
|||
import { isNode } from "@azure/core-util";
|
||||
import { TokenCredential, isTokenCredential } from "@azure/core-auth";
|
||||
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
|
||||
import { SpanStatusCode } from "@azure/core-tracing";
|
||||
import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
||||
import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
||||
import { Container } from "./generated/src/operationsInterfaces";
|
||||
|
@ -47,7 +46,7 @@ import {
|
|||
} from "./models";
|
||||
import { newPipeline, PipelineLike, isPipelineLike, StoragePipelineOptions } from "./Pipeline";
|
||||
import { CommonOptions, StorageClient } from "./StorageClient";
|
||||
import { createSpan } from "./utils/tracing";
|
||||
import { tracingClient } from "./utils/tracing";
|
||||
import {
|
||||
appendToURLPath,
|
||||
appendToURLQuery,
|
||||
|
@ -77,7 +76,12 @@ import {
|
|||
} from "./Clients";
|
||||
import { BlobBatchClient } from "./BlobBatchClient";
|
||||
import {
|
||||
ContainerCreateHeaders,
|
||||
ListBlobsIncludeItem,
|
||||
ContainerGetPropertiesHeaders,
|
||||
ContainerDeleteHeaders,
|
||||
ContainerSetMetadataHeaders,
|
||||
ContainerSetAccessPolicyHeaders,
|
||||
ListBlobsFlatSegmentResponse as ListBlobsFlatSegmentResponseInternal,
|
||||
ListBlobsHierarchySegmentResponse as ListBlobsHierarchySegmentResponseInternal,
|
||||
ContainerListBlobHierarchySegmentResponse as ContainerListBlobHierarchySegmentResponseModel,
|
||||
|
@ -731,24 +735,11 @@ export class ContainerClient extends StorageClient {
|
|||
* ```
|
||||
*/
|
||||
public async create(options: ContainerCreateOptions = {}): Promise<ContainerCreateResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-create", options);
|
||||
try {
|
||||
// Spread operator in destructuring assignments,
|
||||
// this will filter out unwanted properties from the response object into result object
|
||||
return assertResponse(
|
||||
await this.containerContext.create({
|
||||
...updatedOptions,
|
||||
})
|
||||
return tracingClient.withSpan("ContainerClient-create", options, async (updatedOptions) => {
|
||||
return assertResponse<ContainerCreateHeaders, ContainerCreateHeaders>(
|
||||
await this.containerContext.create(updatedOptions)
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -762,36 +753,30 @@ export class ContainerClient extends StorageClient {
|
|||
public async createIfNotExists(
|
||||
options: ContainerCreateOptions = {}
|
||||
): Promise<ContainerCreateIfNotExistsResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-createIfNotExists", options);
|
||||
try {
|
||||
const res = assertResponse(await this.create(updatedOptions));
|
||||
return {
|
||||
succeeded: true,
|
||||
...res,
|
||||
_response: res._response, // _response is made non-enumerable
|
||||
};
|
||||
} catch (e: any) {
|
||||
if (e.details?.errorCode === "ContainerAlreadyExists") {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message:
|
||||
"Expected exception when creating a container only if it does not already exist.",
|
||||
});
|
||||
return {
|
||||
succeeded: false,
|
||||
...e.response?.parsedHeaders,
|
||||
_response: e.response,
|
||||
};
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-createIfNotExists",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
try {
|
||||
const res = await this.create(updatedOptions);
|
||||
return {
|
||||
succeeded: true,
|
||||
...res,
|
||||
_response: res._response, // _response is made non-enumerable
|
||||
};
|
||||
} catch (e: any) {
|
||||
if (e.details?.errorCode === "ContainerAlreadyExists") {
|
||||
return {
|
||||
succeeded: false,
|
||||
...e.response?.parsedHeaders,
|
||||
_response: e.response,
|
||||
};
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -804,29 +789,20 @@ export class ContainerClient extends StorageClient {
|
|||
* @param options -
|
||||
*/
|
||||
public async exists(options: ContainerExistsOptions = {}): Promise<boolean> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-exists", options);
|
||||
try {
|
||||
await this.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
});
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
if (e.statusCode === 404) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: "Expected exception when checking container existence",
|
||||
return tracingClient.withSpan("ContainerClient-exists", options, async (updatedOptions) => {
|
||||
try {
|
||||
await this.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
});
|
||||
return false;
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
if (e.statusCode === 404) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -895,24 +871,19 @@ export class ContainerClient extends StorageClient {
|
|||
options.conditions = {};
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-getProperties", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.containerContext.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
...options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-getProperties",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ContainerGetPropertiesHeaders, ContainerGetPropertiesHeaders>(
|
||||
await this.containerContext.getProperties({
|
||||
abortSignal: options.abortSignal,
|
||||
...options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -929,9 +900,8 @@ export class ContainerClient extends StorageClient {
|
|||
options.conditions = {};
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-delete", options);
|
||||
try {
|
||||
return assertResponse(
|
||||
return tracingClient.withSpan("ContainerClient-delete", options, async (updatedOptions) => {
|
||||
return assertResponse<ContainerDeleteHeaders, ContainerDeleteHeaders>(
|
||||
await this.containerContext.delete({
|
||||
abortSignal: options.abortSignal,
|
||||
leaseAccessConditions: options.conditions,
|
||||
|
@ -939,15 +909,7 @@ export class ContainerClient extends StorageClient {
|
|||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -960,35 +922,29 @@ export class ContainerClient extends StorageClient {
|
|||
public async deleteIfExists(
|
||||
options: ContainerDeleteMethodOptions = {}
|
||||
): Promise<ContainerDeleteIfExistsResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-deleteIfExists", options);
|
||||
|
||||
try {
|
||||
const res = await this.delete(updatedOptions);
|
||||
return {
|
||||
succeeded: true,
|
||||
...res,
|
||||
_response: res._response, // _response is made non-enumerable
|
||||
};
|
||||
} catch (e: any) {
|
||||
if (e.details?.errorCode === "ContainerNotFound") {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: "Expected exception when deleting a container only if it exists.",
|
||||
});
|
||||
return {
|
||||
succeeded: false,
|
||||
...e.response?.parsedHeaders,
|
||||
_response: e.response,
|
||||
};
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-deleteIfExists",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
try {
|
||||
const res = await this.delete(updatedOptions);
|
||||
return {
|
||||
succeeded: true,
|
||||
...res,
|
||||
_response: res._response,
|
||||
};
|
||||
} catch (e: any) {
|
||||
if (e.details?.errorCode === "ContainerNotFound") {
|
||||
return {
|
||||
succeeded: false,
|
||||
...e.response?.parsedHeaders,
|
||||
_response: e.response,
|
||||
};
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1017,27 +973,21 @@ export class ContainerClient extends StorageClient {
|
|||
);
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-setMetadata", options);
|
||||
|
||||
try {
|
||||
return assertResponse(
|
||||
await this.containerContext.setMetadata({
|
||||
abortSignal: options.abortSignal,
|
||||
leaseAccessConditions: options.conditions,
|
||||
metadata,
|
||||
modifiedAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-setMetadata",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
return assertResponse<ContainerSetMetadataHeaders, ContainerSetMetadataHeaders>(
|
||||
await this.containerContext.setMetadata({
|
||||
abortSignal: options.abortSignal,
|
||||
leaseAccessConditions: options.conditions,
|
||||
metadata,
|
||||
modifiedAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1058,66 +1008,60 @@ export class ContainerClient extends StorageClient {
|
|||
options.conditions = {};
|
||||
}
|
||||
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-getAccessPolicy", options);
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-getAccessPolicy",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ContainerGetAccessPolicyResponseModel,
|
||||
ContainerGetAccessPolicyHeaders,
|
||||
SignedIdentifierModel
|
||||
>(
|
||||
await this.containerContext.getAccessPolicy({
|
||||
abortSignal: options.abortSignal,
|
||||
leaseAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ContainerGetAccessPolicyResponseModel,
|
||||
ContainerGetAccessPolicyHeaders,
|
||||
SignedIdentifierModel
|
||||
>(
|
||||
await this.containerContext.getAccessPolicy({
|
||||
abortSignal: options.abortSignal,
|
||||
leaseAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
const res: ContainerGetAccessPolicyResponse = {
|
||||
_response: response._response,
|
||||
blobPublicAccess: response.blobPublicAccess,
|
||||
date: response.date,
|
||||
etag: response.etag,
|
||||
errorCode: response.errorCode,
|
||||
lastModified: response.lastModified,
|
||||
requestId: response.requestId,
|
||||
clientRequestId: response.clientRequestId,
|
||||
signedIdentifiers: [],
|
||||
version: response.version,
|
||||
};
|
||||
|
||||
const res: ContainerGetAccessPolicyResponse = {
|
||||
_response: response._response,
|
||||
blobPublicAccess: response.blobPublicAccess,
|
||||
date: response.date,
|
||||
etag: response.etag,
|
||||
errorCode: response.errorCode,
|
||||
lastModified: response.lastModified,
|
||||
requestId: response.requestId,
|
||||
clientRequestId: response.clientRequestId,
|
||||
signedIdentifiers: [],
|
||||
version: response.version,
|
||||
};
|
||||
for (const identifier of response) {
|
||||
let accessPolicy: any = undefined;
|
||||
if (identifier.accessPolicy) {
|
||||
accessPolicy = {
|
||||
permissions: identifier.accessPolicy.permissions,
|
||||
};
|
||||
|
||||
for (const identifier of response) {
|
||||
let accessPolicy: any = undefined;
|
||||
if (identifier.accessPolicy) {
|
||||
accessPolicy = {
|
||||
permissions: identifier.accessPolicy.permissions,
|
||||
};
|
||||
if (identifier.accessPolicy.expiresOn) {
|
||||
accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
|
||||
}
|
||||
|
||||
if (identifier.accessPolicy.expiresOn) {
|
||||
accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
|
||||
if (identifier.accessPolicy.startsOn) {
|
||||
accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier.accessPolicy.startsOn) {
|
||||
accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
|
||||
}
|
||||
res.signedIdentifiers.push({
|
||||
accessPolicy,
|
||||
id: identifier.id,
|
||||
});
|
||||
}
|
||||
|
||||
res.signedIdentifiers.push({
|
||||
accessPolicy,
|
||||
id: identifier.id,
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
return res;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1143,43 +1087,38 @@ export class ContainerClient extends StorageClient {
|
|||
options: ContainerSetAccessPolicyOptions = {}
|
||||
): Promise<ContainerSetAccessPolicyResponse> {
|
||||
options.conditions = options.conditions || {};
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-setAccessPolicy", options);
|
||||
try {
|
||||
const acl: SignedIdentifierModel[] = [];
|
||||
for (const identifier of containerAcl || []) {
|
||||
acl.push({
|
||||
accessPolicy: {
|
||||
expiresOn: identifier.accessPolicy.expiresOn
|
||||
? truncatedISO8061Date(identifier.accessPolicy.expiresOn)
|
||||
: "",
|
||||
permissions: identifier.accessPolicy.permissions,
|
||||
startsOn: identifier.accessPolicy.startsOn
|
||||
? truncatedISO8061Date(identifier.accessPolicy.startsOn)
|
||||
: "",
|
||||
},
|
||||
id: identifier.id,
|
||||
});
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-setAccessPolicy",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const acl: SignedIdentifierModel[] = [];
|
||||
for (const identifier of containerAcl || []) {
|
||||
acl.push({
|
||||
accessPolicy: {
|
||||
expiresOn: identifier.accessPolicy.expiresOn
|
||||
? truncatedISO8061Date(identifier.accessPolicy.expiresOn)
|
||||
: "",
|
||||
permissions: identifier.accessPolicy.permissions,
|
||||
startsOn: identifier.accessPolicy.startsOn
|
||||
? truncatedISO8061Date(identifier.accessPolicy.startsOn)
|
||||
: "",
|
||||
},
|
||||
id: identifier.id,
|
||||
});
|
||||
}
|
||||
|
||||
return assertResponse(
|
||||
await this.containerContext.setAccessPolicy({
|
||||
abortSignal: options.abortSignal,
|
||||
access,
|
||||
containerAcl: acl,
|
||||
leaseAccessConditions: options.conditions,
|
||||
modifiedAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return assertResponse<ContainerSetAccessPolicyHeaders, ContainerSetAccessPolicyHeaders>(
|
||||
await this.containerContext.setAccessPolicy({
|
||||
abortSignal: options.abortSignal,
|
||||
access,
|
||||
containerAcl: acl,
|
||||
leaseAccessConditions: options.conditions,
|
||||
modifiedAccessConditions: options.conditions,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1220,23 +1159,18 @@ export class ContainerClient extends StorageClient {
|
|||
contentLength: number,
|
||||
options: BlockBlobUploadOptions = {}
|
||||
): Promise<{ blockBlobClient: BlockBlobClient; response: BlockBlobUploadResponse }> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-uploadBlockBlob", options);
|
||||
try {
|
||||
const blockBlobClient = this.getBlockBlobClient(blobName);
|
||||
const response = await blockBlobClient.upload(body, contentLength, updatedOptions);
|
||||
return {
|
||||
blockBlobClient,
|
||||
response,
|
||||
};
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-uploadBlockBlob",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const blockBlobClient = this.getBlockBlobClient(blobName);
|
||||
const response = await blockBlobClient.upload(body, contentLength, updatedOptions);
|
||||
return {
|
||||
blockBlobClient,
|
||||
response,
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1254,22 +1188,13 @@ export class ContainerClient extends StorageClient {
|
|||
blobName: string,
|
||||
options: ContainerDeleteBlobOptions = {}
|
||||
): Promise<BlobDeleteResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-deleteBlob", options);
|
||||
try {
|
||||
return tracingClient.withSpan("ContainerClient-deleteBlob", options, async (updatedOptions) => {
|
||||
let blobClient = this.getBlobClient(blobName);
|
||||
if (options.versionId) {
|
||||
blobClient = blobClient.withVersion(options.versionId);
|
||||
}
|
||||
return await blobClient.delete(updatedOptions);
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
return blobClient.delete(updatedOptions);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1286,51 +1211,46 @@ export class ContainerClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ContainerListBlobsSegmentOptions = {}
|
||||
): Promise<ContainerListBlobFlatSegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-listBlobFlatSegment", options);
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ListBlobsFlatSegmentResponseInternal,
|
||||
ContainerListBlobFlatSegmentHeaders,
|
||||
ListBlobsFlatSegmentResponseInternal
|
||||
>(
|
||||
await this.containerContext.listBlobFlatSegment({
|
||||
marker,
|
||||
...options,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-listBlobFlatSegment",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ListBlobsFlatSegmentResponseInternal,
|
||||
ContainerListBlobFlatSegmentHeaders,
|
||||
ListBlobsFlatSegmentResponseInternal
|
||||
>(
|
||||
await this.containerContext.listBlobFlatSegment({
|
||||
marker,
|
||||
...options,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
const wrappedResponse: ContainerListBlobFlatSegmentResponse = {
|
||||
...response,
|
||||
_response: {
|
||||
...response._response,
|
||||
parsedBody: ConvertInternalResponseOfListBlobFlat(response._response.parsedBody),
|
||||
}, // _response is made non-enumerable
|
||||
segment: {
|
||||
...response.segment,
|
||||
blobItems: response.segment.blobItems.map((blobItemInternal) => {
|
||||
const blobItem: BlobItem = {
|
||||
...blobItemInternal,
|
||||
name: BlobNameToString(blobItemInternal.name),
|
||||
tags: toTags(blobItemInternal.blobTags),
|
||||
objectReplicationSourceProperties: parseObjectReplicationRecord(
|
||||
blobItemInternal.objectReplicationMetadata
|
||||
),
|
||||
};
|
||||
return blobItem;
|
||||
}),
|
||||
},
|
||||
};
|
||||
return wrappedResponse;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
const wrappedResponse: ContainerListBlobFlatSegmentResponse = {
|
||||
...response,
|
||||
_response: {
|
||||
...response._response,
|
||||
parsedBody: ConvertInternalResponseOfListBlobFlat(response._response.parsedBody),
|
||||
}, // _response is made non-enumerable
|
||||
segment: {
|
||||
...response.segment,
|
||||
blobItems: response.segment.blobItems.map((blobItemInternal) => {
|
||||
const blobItem: BlobItem = {
|
||||
...blobItemInternal,
|
||||
name: BlobNameToString(blobItemInternal.name),
|
||||
tags: toTags(blobItemInternal.blobTags),
|
||||
objectReplicationSourceProperties: parseObjectReplicationRecord(
|
||||
blobItemInternal.objectReplicationMetadata
|
||||
),
|
||||
};
|
||||
return blobItem;
|
||||
}),
|
||||
},
|
||||
};
|
||||
return wrappedResponse;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1349,60 +1269,52 @@ export class ContainerClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ContainerListBlobsSegmentOptions = {}
|
||||
): Promise<ContainerListBlobHierarchySegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan(
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-listBlobHierarchySegment",
|
||||
options
|
||||
);
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ContainerListBlobHierarchySegmentResponseModel,
|
||||
ContainerListBlobHierarchySegmentHeaders,
|
||||
ListBlobsHierarchySegmentResponseInternal
|
||||
>(
|
||||
await this.containerContext.listBlobHierarchySegment(delimiter, {
|
||||
marker,
|
||||
...options,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ContainerListBlobHierarchySegmentResponseModel,
|
||||
ContainerListBlobHierarchySegmentHeaders,
|
||||
ListBlobsHierarchySegmentResponseInternal
|
||||
>(
|
||||
await this.containerContext.listBlobHierarchySegment(delimiter, {
|
||||
marker,
|
||||
...options,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
const wrappedResponse: ContainerListBlobHierarchySegmentResponse = {
|
||||
...response,
|
||||
_response: {
|
||||
...response._response,
|
||||
parsedBody: ConvertInternalResponseOfListBlobHierarchy(response._response.parsedBody),
|
||||
}, // _response is made non-enumerable
|
||||
segment: {
|
||||
...response.segment,
|
||||
blobItems: response.segment.blobItems.map((blobItemInternal) => {
|
||||
const blobItem: BlobItem = {
|
||||
...blobItemInternal,
|
||||
name: BlobNameToString(blobItemInternal.name),
|
||||
tags: toTags(blobItemInternal.blobTags),
|
||||
objectReplicationSourceProperties: parseObjectReplicationRecord(
|
||||
blobItemInternal.objectReplicationMetadata
|
||||
),
|
||||
};
|
||||
return blobItem;
|
||||
}),
|
||||
blobPrefixes: response.segment.blobPrefixes?.map((blobPrefixInternal) => {
|
||||
const blobPrefix: BlobPrefix = {
|
||||
name: BlobNameToString(blobPrefixInternal.name),
|
||||
};
|
||||
return blobPrefix;
|
||||
}),
|
||||
},
|
||||
};
|
||||
return wrappedResponse;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
const wrappedResponse: ContainerListBlobHierarchySegmentResponse = {
|
||||
...response,
|
||||
_response: {
|
||||
...response._response,
|
||||
parsedBody: ConvertInternalResponseOfListBlobHierarchy(response._response.parsedBody),
|
||||
}, // _response is made non-enumerable
|
||||
segment: {
|
||||
...response.segment,
|
||||
blobItems: response.segment.blobItems.map((blobItemInternal) => {
|
||||
const blobItem: BlobItem = {
|
||||
...blobItemInternal,
|
||||
name: BlobNameToString(blobItemInternal.name),
|
||||
tags: toTags(blobItemInternal.blobTags),
|
||||
objectReplicationSourceProperties: parseObjectReplicationRecord(
|
||||
blobItemInternal.objectReplicationMetadata
|
||||
),
|
||||
};
|
||||
return blobItem;
|
||||
}),
|
||||
blobPrefixes: response.segment.blobPrefixes?.map((blobPrefixInternal) => {
|
||||
const blobPrefix: BlobPrefix = {
|
||||
name: BlobNameToString(blobPrefixInternal.name),
|
||||
};
|
||||
return blobPrefix;
|
||||
}),
|
||||
},
|
||||
};
|
||||
return wrappedResponse;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1825,44 +1737,38 @@ export class ContainerClient extends StorageClient {
|
|||
marker?: string,
|
||||
options: ContainerFindBlobsByTagsSegmentOptions = {}
|
||||
): Promise<ContainerFindBlobsByTagsSegmentResponse> {
|
||||
const { span, updatedOptions } = createSpan("ContainerClient-findBlobsByTagsSegment", options);
|
||||
return tracingClient.withSpan(
|
||||
"ContainerClient-findBlobsByTagsSegment",
|
||||
options,
|
||||
async (updatedOptions) => {
|
||||
const response = assertResponse<
|
||||
ContainerFilterBlobsResponse,
|
||||
ContainerFilterBlobsHeaders,
|
||||
FilterBlobSegmentModel
|
||||
>(
|
||||
await this.containerContext.filterBlobs({
|
||||
abortSignal: options.abortSignal,
|
||||
where: tagFilterSqlExpression,
|
||||
marker,
|
||||
maxPageSize: options.maxPageSize,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
const response = assertResponse<
|
||||
ContainerFilterBlobsResponse,
|
||||
ContainerFilterBlobsHeaders,
|
||||
FilterBlobSegmentModel
|
||||
>(
|
||||
await this.containerContext.filterBlobs({
|
||||
abortSignal: options.abortSignal,
|
||||
where: tagFilterSqlExpression,
|
||||
marker,
|
||||
maxPageSize: options.maxPageSize,
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
})
|
||||
);
|
||||
|
||||
const wrappedResponse: ContainerFindBlobsByTagsSegmentResponse = {
|
||||
...response,
|
||||
_response: response._response, // _response is made non-enumerable
|
||||
blobs: response.blobs.map((blob) => {
|
||||
let tagValue = "";
|
||||
if (blob.tags?.blobTagSet.length === 1) {
|
||||
tagValue = blob.tags.blobTagSet[0].value;
|
||||
}
|
||||
return { ...blob, tags: toTags(blob.tags), tagValue };
|
||||
}),
|
||||
};
|
||||
return wrappedResponse;
|
||||
} catch (e: any) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: e.message,
|
||||
});
|
||||
throw e;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
const wrappedResponse: ContainerFindBlobsByTagsSegmentResponse = {
|
||||
...response,
|
||||
_response: response._response, // _response is made non-enumerable
|
||||
blobs: response.blobs.map((blob) => {
|
||||
let tagValue = "";
|
||||
if (blob.tags?.blobTagSet.length === 1) {
|
||||
tagValue = blob.tags.blobTagSet[0].value;
|
||||
}
|
||||
return { ...blob, tags: toTags(blob.tags), tagValue };
|
||||
}),
|
||||
};
|
||||
return wrappedResponse;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { createSpanFunction } from "@azure/core-tracing";
|
||||
import { createTracingClient } from "@azure/core-tracing";
|
||||
import { SDK_VERSION } from "./constants";
|
||||
|
||||
/**
|
||||
* Creates a span using the global tracer.
|
||||
* @internal
|
||||
*/
|
||||
export const createSpan = createSpanFunction({
|
||||
packagePrefix: "Azure.Storage.Blob",
|
||||
export const tracingClient = createTracingClient({
|
||||
packageName: "@azure/storage-blob",
|
||||
packageVersion: SDK_VERSION,
|
||||
namespace: "Microsoft.Storage",
|
||||
});
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { assert } from "chai";
|
||||
import * as fs from "fs";
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { SpanGraph, setTracer } from "@azure/test-utils";
|
||||
import { assert } from "@azure/test-utils";
|
||||
import {
|
||||
bodyToString,
|
||||
getBSU,
|
||||
|
@ -28,7 +27,6 @@ import {
|
|||
} from "../src";
|
||||
import { Test_CPK_INFO } from "./utils/fakeTestSecrets";
|
||||
import { base64encode } from "../src/utils/utils.common";
|
||||
import { context, setSpan } from "@azure/core-tracing";
|
||||
import { Context } from "mocha";
|
||||
|
||||
describe("BlobClient", () => {
|
||||
|
@ -777,44 +775,10 @@ describe("BlobClient", () => {
|
|||
});
|
||||
|
||||
it("download with default parameters and tracing", async function (this: Context) {
|
||||
const tracer = setTracer();
|
||||
|
||||
const rootSpan = tracer.startSpan("root");
|
||||
|
||||
const result = await blobClient.download(undefined, undefined, {
|
||||
tracingOptions: {
|
||||
tracingContext: setSpan(context.active(), rootSpan),
|
||||
},
|
||||
});
|
||||
assert.deepStrictEqual(await bodyToString(result, content.length), content);
|
||||
|
||||
rootSpan.end();
|
||||
|
||||
const rootSpans = tracer.getRootSpans();
|
||||
assert.strictEqual(rootSpans.length, 1, "Should only have one root span.");
|
||||
assert.strictEqual(rootSpan, rootSpans[0], "The root span should match what was passed in.");
|
||||
|
||||
const expectedGraph: SpanGraph = {
|
||||
roots: [
|
||||
{
|
||||
name: rootSpan.name,
|
||||
children: [
|
||||
{
|
||||
name: "Azure.Storage.Blob.BlobClient-download",
|
||||
children: [
|
||||
/* {
|
||||
name: "HTTP GET",
|
||||
children: [],
|
||||
},*/
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
assert.deepStrictEqual(tracer.getSpanGraph(rootSpan.spanContext().traceId), expectedGraph);
|
||||
assert.strictEqual(tracer.getActiveSpans().length, 0, "All spans should have had end called");
|
||||
await assert.supportsTracing(
|
||||
(options) => blobClient.download(undefined, undefined, options),
|
||||
["BlobClient-download"]
|
||||
);
|
||||
});
|
||||
|
||||
it("exists returns true on an existing blob", async () => {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import { assert } from "chai";
|
||||
import { TestTracer, SpanGraph, setTracer } from "@azure/test-utils";
|
||||
import {
|
||||
base64encode,
|
||||
bodyToString,
|
||||
|
@ -13,15 +11,16 @@ import {
|
|||
sleep,
|
||||
} from "./utils";
|
||||
import { record, Recorder } from "@azure-tools/test-recorder";
|
||||
import { getYieldedValue } from "@azure/test-utils";
|
||||
import { getYieldedValue, assert } from "@azure/test-utils";
|
||||
import {
|
||||
ContainerClient,
|
||||
BlockBlobTier,
|
||||
ContainerListBlobHierarchySegmentResponse,
|
||||
BlobServiceClient,
|
||||
BlockBlobClient,
|
||||
BlobHTTPHeaders,
|
||||
} from "../src";
|
||||
import { Test_CPK_INFO } from "./utils/fakeTestSecrets";
|
||||
import { context, setSpan } from "@azure/core-tracing";
|
||||
import { Context } from "mocha";
|
||||
import { Tags } from "../src/models";
|
||||
|
||||
|
@ -804,65 +803,36 @@ describe("ContainerClient", () => {
|
|||
});
|
||||
|
||||
it("uploadBlockBlob and deleteBlob with tracing", async function (this: Context) {
|
||||
const tracer = new TestTracer();
|
||||
setTracer(tracer);
|
||||
const rootSpan = tracer.startSpan("root");
|
||||
const body: string = recorder.getUniqueName("randomstring");
|
||||
const options = {
|
||||
const blobHeaders: BlobHTTPHeaders = {
|
||||
blobCacheControl: "blobCacheControl",
|
||||
blobContentDisposition: "blobContentDisposition",
|
||||
blobContentEncoding: "blobContentEncoding",
|
||||
blobContentLanguage: "blobContentLanguage",
|
||||
blobContentType: "blobContentType",
|
||||
metadata: {
|
||||
keya: "vala",
|
||||
keyb: "valb",
|
||||
},
|
||||
};
|
||||
const blobName: string = recorder.getUniqueName("blob");
|
||||
const { blockBlobClient } = await containerClient.uploadBlockBlob(blobName, body, body.length, {
|
||||
blobHTTPHeaders: options,
|
||||
metadata: options.metadata,
|
||||
tracingOptions: {
|
||||
tracingContext: setSpan(context.active(), rootSpan),
|
||||
let blockBlobClient: BlockBlobClient | undefined;
|
||||
await assert.supportsTracing(
|
||||
async function (options) {
|
||||
const result = await containerClient.uploadBlockBlob(blobName, body, body.length, {
|
||||
blobHTTPHeaders: blobHeaders,
|
||||
metadata: {
|
||||
keya: "vala",
|
||||
keyb: "valb",
|
||||
},
|
||||
tracingOptions: options.tracingOptions,
|
||||
});
|
||||
blockBlobClient = result.blockBlobClient;
|
||||
},
|
||||
});
|
||||
|
||||
rootSpan.end();
|
||||
|
||||
const rootSpans = tracer.getRootSpans();
|
||||
assert.strictEqual(rootSpans.length, 1, "Should only have one root span.");
|
||||
assert.strictEqual(rootSpan, rootSpans[0], "The root span should match what was passed in.");
|
||||
|
||||
const expectedGraph: SpanGraph = {
|
||||
roots: [
|
||||
{
|
||||
name: rootSpan.name,
|
||||
children: [
|
||||
{
|
||||
name: "Azure.Storage.Blob.ContainerClient-uploadBlockBlob",
|
||||
children: [
|
||||
{
|
||||
name: "Azure.Storage.Blob.BlockBlobClient-upload",
|
||||
children: [
|
||||
/* {
|
||||
name: "HTTP PUT",
|
||||
children: [],
|
||||
},*/
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
assert.deepStrictEqual(tracer.getSpanGraph(rootSpan.spanContext().traceId), expectedGraph);
|
||||
assert.strictEqual(tracer.getActiveSpans().length, 0, "All spans should have had end called");
|
||||
["ContainerClient-uploadBlockBlob"]
|
||||
);
|
||||
|
||||
await containerClient.deleteBlob(blobName);
|
||||
try {
|
||||
if (!blockBlobClient) {
|
||||
assert.fail("Expected to receive a block blob client for created blob");
|
||||
}
|
||||
await blockBlobClient.getProperties();
|
||||
assert.fail(
|
||||
"Expecting an error in getting properties from a deleted block blob but didn't get one."
|
||||
|
|
|
@ -82,15 +82,15 @@ describe("DataLakeFileSystemClient", () => {
|
|||
{
|
||||
name: "Azure.Storage.DataLake.DataLakeFileSystemClient-setMetadata",
|
||||
children: [
|
||||
{
|
||||
/* {
|
||||
name: "Azure.Storage.Blob.ContainerClient-setMetadata",
|
||||
children: [
|
||||
/* {
|
||||
{
|
||||
name: "HTTP PUT",
|
||||
children: [],
|
||||
},*/
|
||||
},
|
||||
],
|
||||
},
|
||||
},*/
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -759,15 +759,15 @@ describe("DataLakePathClient", () => {
|
|||
{
|
||||
name: "Azure.Storage.DataLake.DataLakeFileClient-read",
|
||||
children: [
|
||||
{
|
||||
/* {
|
||||
name: "Azure.Storage.Blob.BlobClient-download",
|
||||
children: [
|
||||
/* {
|
||||
{
|
||||
name: "HTTP GET",
|
||||
children: [],
|
||||
},*/
|
||||
},
|
||||
],
|
||||
},
|
||||
},*/
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
Загрузка…
Ссылка в новой задаче