From 25cfd0bec3e3a5872a9e21eb3b2fa2e5b8e45969 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 17:43:45 +0800 Subject: [PATCH 01/12] [storage-blob] add CreateIfNotExists and DeleteIfExists for Container and Blob --- sdk/storage/storage-blob/CHANGELOG.md | 4 + .../storage-blob/review/storage-blob.api.md | 25 + sdk/storage/storage-blob/src/Clients.ts | 621 +++++++++++++----- .../test/appendblobclient.spec.ts | 5 + .../storage-blob/test/blobclient.spec.ts | 7 + .../storage-blob/test/containerclient.spec.ts | 24 + .../storage-blob/test/pageblobclient.spec.ts | 5 + 7 files changed, 537 insertions(+), 154 deletions(-) diff --git a/sdk/storage/storage-blob/CHANGELOG.md b/sdk/storage/storage-blob/CHANGELOG.md index 88ab22f6117e..583dac04db8e 100644 --- a/sdk/storage/storage-blob/CHANGELOG.md +++ b/sdk/storage/storage-blob/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 12.2.0 (unreleased) + +- Added CreateIfNotExists and DeleteIfNotExists convenience methods for Blobs and Containers. + ## 12.1.2 (2020.05) - Fix data corruption failure error [issue #6411](https://github.com/Azure/azure-sdk-for-js/issues/6411) when downloading compressed files. [PR #7993](https://github.com/Azure/azure-sdk-for-js/pull/7993) diff --git a/sdk/storage/storage-blob/review/storage-blob.api.md b/sdk/storage/storage-blob/review/storage-blob.api.md index 10c05ece2200..6ac8910bcc56 100644 --- a/sdk/storage/storage-blob/review/storage-blob.api.md +++ b/sdk/storage/storage-blob/review/storage-blob.api.md @@ -179,6 +179,7 @@ export class AppendBlobClient extends BlobClient { appendBlock(body: HttpRequestBody, contentLength: number, options?: AppendBlobAppendBlockOptions): Promise; appendBlockFromURL(sourceURL: string, sourceOffset: number, count: number, options?: AppendBlobAppendBlockFromURLOptions): Promise; create(options?: AppendBlobCreateOptions): Promise; + createIfNotExists(options?: AppendBlobCreateIfNotExistsOptions): Promise; withSnapshot(snapshot: string): AppendBlobClient; } @@ -198,6 +199,15 @@ export interface AppendBlobCreateHeaders { version?: string; } +// @public +export interface AppendBlobCreateIfNotExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; + blobHTTPHeaders?: BlobHTTPHeaders; + customerProvidedKey?: CpkInfo; + encryptionScope?: string; + metadata?: Metadata; +} + // @public export interface AppendBlobCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -361,6 +371,7 @@ export class BlobClient extends StorageClient { get containerName(): string; createSnapshot(options?: BlobCreateSnapshotOptions): Promise; delete(options?: BlobDeleteOptions): Promise; + deleteIfExists(options?: BlobDeleteOptions): Promise; download(offset?: number, count?: number, options?: BlobDownloadOptions): Promise; downloadToBuffer(offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise; downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise; @@ -1236,8 +1247,10 @@ export class ContainerClient extends StorageClient { constructor(url: string, pipeline: Pipeline); get containerName(): string; create(options?: ContainerCreateOptions): Promise; + createIfNotExists(options?: ContainerCreateOptions): Promise; delete(options?: ContainerDeleteMethodOptions): Promise; deleteBlob(blobName: string, options?: BlobDeleteOptions): Promise; + deleteIfExists(options?: ContainerDeleteMethodOptions): Promise; exists(options?: ContainerExistsOptions): Promise; getAccessPolicy(options?: ContainerGetAccessPolicyOptions): Promise; getAppendBlobClient(blobName: string): AppendBlobClient; @@ -1791,6 +1804,7 @@ export class PageBlobClient extends BlobClient { constructor(url: string, pipeline: Pipeline); clearPages(offset?: number, count?: number, options?: PageBlobClearPagesOptions): Promise; create(size: number, options?: PageBlobCreateOptions): Promise; + createIfNotExists(size: number, options?: PageBlobCreateIfNotExistsOptions): Promise; getPageRanges(offset?: number, count?: number, options?: PageBlobGetPageRangesOptions): Promise; getPageRangesDiff(offset: number, count: number, prevSnapshot: string, options?: PageBlobGetPageRangesDiffOptions): Promise; getPageRangesDiffForManagedDisks(offset: number, count: number, prevSnapshotUrl: string, options?: PageBlobGetPageRangesDiffOptions): Promise; @@ -1839,6 +1853,17 @@ export interface PageBlobCreateHeaders { version?: string; } +// @public +export interface PageBlobCreateIfNotExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; + blobHTTPHeaders?: BlobHTTPHeaders; + blobSequenceNumber?: number; + customerProvidedKey?: CpkInfo; + encryptionScope?: string; + metadata?: Metadata; + tier?: PremiumPageBlobTier | string; +} + // @public export interface PageBlobCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; diff --git a/sdk/storage/storage-blob/src/Clients.ts b/sdk/storage/storage-blob/src/Clients.ts index 54ffcdb2bf6f..f90e6bade06a 100644 --- a/sdk/storage/storage-blob/src/Clients.ts +++ b/sdk/storage/storage-blob/src/Clients.ts @@ -7,7 +7,7 @@ import { TokenCredential, isTokenCredential, getDefaultProxySettings, - URLBuilder + URLBuilder, } from "@azure/core-http"; import { CanonicalCode } from "@opentelemetry/api"; import { @@ -29,7 +29,7 @@ import { BlobAbortCopyFromURLResponse, BlobCopyFromURLResponse, BlobSetTierResponse, - ContainerEncryptionScope + ContainerEncryptionScope, } from "./generatedModels"; import { AbortSignalLike } from "@azure/abort-controller"; import { BlobDownloadResponse } from "./BlobDownloadResponse"; @@ -41,19 +41,19 @@ import { ensureCpkIfSpecified, BlockBlobTier, PremiumPageBlobTier, - toAccessTier + toAccessTier, } from "./models"; import { newPipeline, StoragePipelineOptions, Pipeline } from "./Pipeline"; import { DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, URLConstants, DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES, - DEFAULT_BLOCK_BUFFER_SIZE_BYTES + DEFAULT_BLOCK_BUFFER_SIZE_BYTES, } from "./utils/constants"; import { setURLParameter, extractConnectionStringParts, - appendToURLPath + appendToURLPath, } from "./utils/utils.common"; import { fsStat, readStreamToLocalFile, streamToBuffer } from "./utils/utils.node"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; @@ -64,7 +64,7 @@ import { HttpRequestBody } from "@azure/core-http"; import { AppendBlobCreateResponse, AppendBlobAppendBlockFromUrlResponse, - AppendBlobAppendBlockResponse + AppendBlobAppendBlockResponse, } from "./generatedModels"; import { AppendBlob } from "./generated/src/operations"; import { AppendBlobRequestConditions } from "./models"; @@ -78,7 +78,7 @@ import { BlockBlobStageBlockFromURLResponse, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, - BlockListType + BlockListType, } from "./generatedModels"; import { BlockBlob } from "./generated/src/operations"; import { Range } from "./Range"; @@ -86,7 +86,8 @@ import { generateBlockID } from "./utils/utils.common"; import { BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES, BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES, - BLOCK_BLOB_MAX_BLOCKS + BLOCK_BLOB_MAX_BLOCKS, + ETagAny, } from "./utils/constants"; import { BufferScheduler } from "./utils/BufferScheduler"; import { Readable } from "stream"; @@ -98,19 +99,19 @@ import { PageBlobResizeResponse, SequenceNumberActionType, PageBlobUpdateSequenceNumberResponse, - PageBlobCopyIncrementalResponse + PageBlobCopyIncrementalResponse, } from "./generatedModels"; import { PageBlob } from "./generated/src/operations"; import { PageBlobRequestConditions } from "./models"; import { PageBlobGetPageRangesDiffResponse, PageBlobGetPageRangesResponse, - rangeResponseFromModel + rangeResponseFromModel, } from "./PageBlobRangeResponse"; import { BlobBeginCopyFromUrlPoller, BlobBeginCopyFromUrlPollState, - CopyPollerBlobClient + CopyPollerBlobClient, } from "./pollers/BlobStartCopyFromUrlPoller"; import { PollerLike, PollOperationState } from "@azure/core-lro"; import { ContainerBreakLeaseOptionalParams } from "./generatedModels"; @@ -128,7 +129,7 @@ import { ContainerListBlobFlatSegmentResponse, ContainerListBlobHierarchySegmentResponse, BlobItem, - BlobPrefix + BlobPrefix, } from "./generatedModels"; import { Container } from "./generated/src/operations"; import { ETagNone } from "./utils/constants"; @@ -1020,7 +1021,7 @@ export class BlobClient extends StorageClient { super(url, pipeline); ({ blobName: this._name, - containerName: this._containerName + containerName: this._containerName, } = this.getBlobAndContainerNamesFromUrl()); this.blobContext = new StorageBlob(this.storageClientContext); } @@ -1156,7 +1157,7 @@ export class BlobClient extends StorageClient { rangeGetContentCRC64: options.rangeGetContentCrc64, snapshot: options.snapshot, cpkInfo: options.customerProvidedKey, - spanOptions + spanOptions, }); // Return browser response immediately @@ -1191,16 +1192,16 @@ export class BlobClient extends StorageClient { ifMatch: options.conditions!.ifMatch || res.etag, ifModifiedSince: options.conditions!.ifModifiedSince, ifNoneMatch: options.conditions!.ifNoneMatch, - ifUnmodifiedSince: options.conditions!.ifUnmodifiedSince + ifUnmodifiedSince: options.conditions!.ifUnmodifiedSince, }, range: rangeToString({ count: offset + res.contentLength! - start, - offset: start + offset: start, }), rangeGetContentMD5: options.rangeGetContentMD5, rangeGetContentCRC64: options.rangeGetContentCrc64, snapshot: options.snapshot, - cpkInfo: options.customerProvidedKey + cpkInfo: options.customerProvidedKey, }; // Debug purpose only @@ -1213,7 +1214,7 @@ export class BlobClient extends StorageClient { return ( await this.blobContext.download({ abortSignal: options.abortSignal, - ...updatedOptions + ...updatedOptions, }) ).readableStreamBody!; }, @@ -1222,13 +1223,13 @@ export class BlobClient extends StorageClient { { abortSignal: options.abortSignal, maxRetryRequests: options.maxRetryRequests, - onProgress: options.onProgress + onProgress: options.onProgress, } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1256,21 +1257,21 @@ export class BlobClient extends StorageClient { customerProvidedKey: options.customerProvidedKey, tracingOptions: { ...options.tracingOptions, - spanOptions - } + spanOptions, + }, }); return true; } catch (e) { if (e.statusCode === 404) { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when checking blob existence" + message: "Expected exception when checking blob existence", }); return false; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1304,12 +1305,12 @@ export class BlobClient extends StorageClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1337,12 +1338,48 @@ export class BlobClient extends StorageClient { deleteSnapshots: options.deleteSnapshots, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Marks the specified blob or snapshot for deletion if it exists. The blob is later deleted + * during garbage collection. Note that in order to delete a blob, you must delete + * all of its snapshots. You can delete both at the same time with the Delete + * Blob operation. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob + * + * @param {BlobDeleteOptions} [options] Optional options to Blob Delete operation. + * @returns {Promise} Returns null if the blob/snapshot does not exist. + * @memberof BlobClient + */ + public async deleteIfExists(options: BlobDeleteOptions = {}): Promise { + const { span, spanOptions } = createSpan("BlobClient-deleteIfExists", options.tracingOptions); + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { + if (e.details?.errorCode === "BlobNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting blob or snapshot only if it exists.", + }); + return null; + } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1365,12 +1402,12 @@ export class BlobClient extends StorageClient { try { return await this.blobContext.undelete({ abortSignal: options.abortSignal, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1406,12 +1443,12 @@ export class BlobClient extends StorageClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1447,12 +1484,12 @@ export class BlobClient extends StorageClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1493,12 +1530,12 @@ export class BlobClient extends StorageClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1587,7 +1624,7 @@ export class BlobClient extends StorageClient { const client: CopyPollerBlobClient = { abortCopyFromURL: (...args) => this.abortCopyFromURL(...args), getProperties: (...args) => this.getProperties(...args), - startCopyFromURL: (...args) => this.startCopyFromURL(...args) + startCopyFromURL: (...args) => this.startCopyFromURL(...args), }; const poller = new BlobBeginCopyFromUrlPoller({ blobClient: client, @@ -1595,7 +1632,7 @@ export class BlobClient extends StorageClient { intervalInMs: options.intervalInMs, onProgress: options.onProgress, resumeFrom: options.resumeFrom, - startCopyFromURLOptions: options + startCopyFromURLOptions: options, }); // Trigger the startCopyFromURL call by calling poll. @@ -1624,12 +1661,12 @@ export class BlobClient extends StorageClient { return await this.blobContext.abortCopyFromURL(copyId, { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1665,15 +1702,15 @@ export class BlobClient extends StorageClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, }, sourceContentMD5: options.sourceContentMD5, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1704,12 +1741,12 @@ export class BlobClient extends StorageClient { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, rehydratePriority: options.rehydratePriority, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1815,8 +1852,8 @@ export class BlobClient extends StorageClient { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions - } + spanOptions, + }, }); count = response.contentLength! - offset; if (count < 0) { @@ -1858,8 +1895,8 @@ export class BlobClient extends StorageClient { maxRetryRequests: options.maxRetryRequestsPerBlock, tracingOptions: { ...options.tracingOptions, - spanOptions - } + spanOptions, + }, }); const stream = response.readableStreamBody!; await streamToBuffer(stream, buffer!, off - offset, chunkEnd - offset); @@ -1877,7 +1914,7 @@ export class BlobClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -1914,8 +1951,8 @@ export class BlobClient extends StorageClient { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions - } + spanOptions, + }, }); if (response.readableStreamBody) { await readStreamToLocalFile(response.readableStreamBody, filePath); @@ -1927,7 +1964,7 @@ export class BlobClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -2017,16 +2054,16 @@ export class BlobClient extends StorageClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, }, rehydratePriority: options.rehydratePriority, tier: toAccessTier(options.tier), - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -2091,6 +2128,54 @@ export interface AppendBlobCreateOptions extends CommonOptions { encryptionScope?: string; } +/** + * Options to configure {@link AppendBlobClient.createIfNotExists} operation. + * + * @export + * @interface AppendBlobCreateIfNotExistsOptions + */ +export interface AppendBlobCreateIfNotExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof AppendBlobCreateIfNotExistsOptions + */ + abortSignal?: AbortSignalLike; + /** + * HTTP headers to set when creating append blobs. + * + * @type {BlobHTTPHeaders} + * @memberof AppendBlobCreateIfNotExistsOptions + */ + blobHTTPHeaders?: BlobHTTPHeaders; + /** + * A collection of key-value string pair to associate with the blob when creating append blobs. + * + * @type {Metadata} + * @memberof AppendBlobCreateIfNotExistsOptions + */ + metadata?: Metadata; + /** + * Customer Provided Key Info. + * + * @type {CpkInfo} + * @memberof AppendBlobCreateIfNotExistsOptions + */ + customerProvidedKey?: CpkInfo; + /** + * Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to + * encrypt the data provided in the request. If not specified, encryption is performed with the + * default account encryption scope. For more information, see Encryption at Rest for Azure + * Storage Services. + * + * @type {string} + * @memberof AppendBlobCreateIfNotExistsOptions + */ + encryptionScope?: string; +} + /** * Options to configure the {@link AppendBlobClient.appendBlock} operation. * @@ -2442,12 +2527,53 @@ export class AppendBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Creates a 0-length append blob. Call AppendBlock to append data to an append blob. + * If the blob with the same name already exists, the content of the existing blob will remain unchanged. + * @see https://docs.microsoft.com/rest/api/storageservices/put-blob + * + * @param {AppendBlobCreateIfNotExistsOptions} [options] + * @returns {Promise} If the blob does not already exist, an AppendBlobCreateResponse. Otherwise, null. + * @memberof AppendBlobClient + */ + public async createIfNotExists( + options: AppendBlobCreateIfNotExistsOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "AppendBlobClient-createIfNotExists", + options.tracingOptions + ); + const conditions = { ifNoneMatch: ETagAny }; + try { + return await this.create({ + ...options, + conditions, + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { + if (e.details?.errorCode === "BlobAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating blob only if it does not already exist.", + }); + return null; + } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -2503,12 +2629,12 @@ export class AppendBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -2559,16 +2685,16 @@ export class AppendBlobClient extends BlobClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3269,12 +3395,12 @@ export class BlockBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3311,12 +3437,12 @@ export class BlockBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3367,12 +3493,12 @@ export class BlockBlobClient extends BlobClient { sourceRange: offset === 0 && !count ? undefined : rangeToString({ offset, count }), cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3415,13 +3541,13 @@ export class BlockBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions + spanOptions, } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3452,7 +3578,7 @@ export class BlockBlobClient extends BlobClient { const res = await this.blockBlobContext.getBlockList(listType, { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions + spanOptions, }); if (!res.committedBlocks) { @@ -3467,7 +3593,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3512,7 +3638,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3589,7 +3715,7 @@ export class BlockBlobClient extends BlobClient { if (size <= options.maxSingleShotSize) { return await this.upload(blobFactory(0, size), size, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } @@ -3618,14 +3744,14 @@ export class BlockBlobClient extends BlobClient { abortSignal: options.abortSignal, conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); // Update progress after block is successfully uploaded to server, in case of block trying // TODO: Hook with convenience layer progress event in finer level transferProgress += contentLength; if (options.onProgress) { options.onProgress!({ - loadedBytes: transferProgress + loadedBytes: transferProgress, }); } } @@ -3635,12 +3761,12 @@ export class BlockBlobClient extends BlobClient { return this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3674,7 +3800,7 @@ export class BlockBlobClient extends BlobClient { fs.createReadStream(filePath, { autoClose: true, end: count ? offset + count - 1 : Infinity, - start: offset + start: offset, }), size, { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } @@ -3682,7 +3808,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3743,7 +3869,7 @@ export class BlockBlobClient extends BlobClient { await this.stageBlock(blockID, buffer, buffer.length, { conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); // Update progress after block is successfully uploaded to server, in case of block trying @@ -3762,12 +3888,12 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3847,7 +3973,7 @@ export class BlockBlobClient extends BlobClient { if (size <= options.maxSingleShotSize) { return await this.upload(() => streamFactory(0), size, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } @@ -3880,7 +4006,7 @@ export class BlockBlobClient extends BlobClient { abortSignal: options.abortSignal, conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, } ); // Update progress after block is successfully uploaded to server, in case of block trying @@ -3895,12 +4021,12 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -3980,6 +4106,70 @@ export interface PageBlobCreateOptions extends CommonOptions { tier?: PremiumPageBlobTier | string; } +/** + * Options to configure the {@link PageBlobClient.createIfNotExists} operation. + * + * @export + * @interface PageBlobCreateIfNotExistsOptions + */ +export interface PageBlobCreateIfNotExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof PageBlobCreateIfNotExistsOptions + */ + abortSignal?: AbortSignalLike; + /** + * A user-controlled value that can be used to track requests. + * The value must be between 0 and 2^63 - 1. The default value is 0. + * + * @type {number} + * @memberof PageBlobCreateIfNotExistsOptions + */ + blobSequenceNumber?: number; + /** + * HTTP headers to set when creating a page blob. + * + * @type {BlobHTTPHeaders} + * @memberof PageBlobCreateIfNotExistsOptions + */ + blobHTTPHeaders?: BlobHTTPHeaders; + /** + * A collection of key-value string pair to associate with the blob when creating append blobs. + * + * @type {Metadata} + * @memberof PageBlobCreateIfNotExistsOptions + */ + metadata?: Metadata; + /** + * Customer Provided Key Info. + * + * @type {CpkInfo} + * @memberof PageBlobCreateIfNotExistsOptions + */ + customerProvidedKey?: CpkInfo; + /** + * Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to + * encrypt the data provided in the request. If not specified, encryption is performed with the + * default account encryption scope. For more information, see Encryption at Rest for Azure + * Storage Services. + * + * @type {string} + * @memberof PageBlobCreateIfNotExistsOptions + */ + encryptionScope?: string; + /** + * Access tier. + * More Details - https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers + * + * @type {PremiumPageBlobTier | string} + * @memberof PageBlobCreateIfNotExistsOptions + */ + tier?: PremiumPageBlobTier | string; +} + /** * Options to configure the {@link PageBlobClient.uploadPages} operation. * @@ -4500,12 +4690,56 @@ export class PageBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions + spanOptions, + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Creates a page blob of the specified length. Call uploadPages to upload data + * data to a page blob. If the blob with the same name already exists, the content + * of the existing blob will remain unchanged. + * @see https://docs.microsoft.com/rest/api/storageservices/put-blob + * + * @param {number} size size of the page blob. + * @param {PageBlobCreateIfNotExistsOptions} [options] + * @returns {Promise} If the blob does not already exist, an PageBlobCreateResponse. Otherwise, null. + * @memberof PageBlobClient + */ + public async createIfNotExists( + size: number, + options: PageBlobCreateIfNotExistsOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "PageBlobClient-createIfNotExists", + options.tracingOptions + ); + try { + const conditions = { ifNoneMatch: ETagAny }; + return await this.create(size, { + ...options, + conditions, + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { + if (e.details?.errorCode === "BlobAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating blob only if it does not already exist.", + }); + return null; + } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4545,12 +4779,12 @@ export class PageBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4602,17 +4836,17 @@ export class PageBlobClient extends BlobClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4646,12 +4880,12 @@ export class PageBlobClient extends BlobClient { sequenceNumberAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4686,13 +4920,13 @@ export class PageBlobClient extends BlobClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, range: rangeToString({ offset, count }), - spanOptions + spanOptions, }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4731,13 +4965,13 @@ export class PageBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, prevsnapshot: prevSnapshot, range: rangeToString({ offset, count }), - spanOptions + spanOptions, }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4776,13 +5010,13 @@ export class PageBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, prevSnapshotUrl, range: rangeToString({ offset, count }), - spanOptions + spanOptions, }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4811,12 +5045,12 @@ export class PageBlobClient extends BlobClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, encryptionScope: options.encryptionScope, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4850,12 +5084,12 @@ export class PageBlobClient extends BlobClient { blobSequenceNumber: sequenceNumber, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -4889,12 +5123,12 @@ export class PageBlobClient extends BlobClient { return await this.pageBlobContext.copyIncremental(copySource, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5078,12 +5312,12 @@ export class BlobLeaseClient { duration, modifiedAccessConditions: options.conditions, proposedLeaseId: this._leaseId, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5114,7 +5348,7 @@ export class BlobLeaseClient { { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, } ); this._leaseId = proposedLeaseId; @@ -5122,7 +5356,7 @@ export class BlobLeaseClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5150,12 +5384,12 @@ export class BlobLeaseClient { return await this._containerOrBlobOperation.releaseLease(this._leaseId, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5179,12 +5413,12 @@ export class BlobLeaseClient { return await this._containerOrBlobOperation.renewLease(this._leaseId, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5215,13 +5449,13 @@ export class BlobLeaseClient { abortSignal: options.abortSignal, breakPeriod, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }; return await this._containerOrBlobOperation.breakLease(operationOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5854,12 +6088,51 @@ export class ContainerClient extends StorageClient { // this will filter out unwanted properties from the response object into result object return await this.containerContext.create({ ...options, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Creates a new container under the specified account. If the container with + * the same name already exists, it is not changed. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-container + * + * @param {ContainerCreateOptions} [options] + * @returns {Promise} If the container with the same name does not already exist, a ContainerCreateResponse. Otherwise, null. + * @memberof ContainerClient + */ + public async createIfNotExists( + options: ContainerCreateOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "ContainerClient-createIfNotExists", + options.tracingOptions + ); + try { + return await this.create({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions }, + }); + } catch (e) { + if (e.details?.errorCode === "ContainerAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating container only if it does not already exist.", + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message, }); throw e; } finally { @@ -5883,20 +6156,20 @@ export class ContainerClient extends StorageClient { try { await this.getProperties({ abortSignal: options.abortSignal, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); return true; } catch (e) { if (e.statusCode === 404) { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when checking container existence" + message: "Expected exception when checking container existence", }); return false; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -5995,12 +6268,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.getProperties({ abortSignal: options.abortSignal, ...options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6041,12 +6314,52 @@ export class ContainerClient extends StorageClient { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Marks the specified container for deletion if it exists. The container and any blobs + * contained within it are later deleted during garbage collection. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container + * + * @param {ContainerDeleteMethodOptions} [options] Options to Container Delete operation. + * @returns {Promise} Returns null if the container does not exist. + * @memberof ContainerClient + */ + public async deleteIfExists( + options: ContainerDeleteMethodOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "ContainerClient-deleteIfExists", + options.tracingOptions + ); + + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { + if (e.details?.errorCode === "ContainerNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting container only if it exists.", + }); + return null; + } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6095,12 +6408,12 @@ export class ContainerClient extends StorageClient { leaseAccessConditions: options.conditions, metadata, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6137,7 +6450,7 @@ export class ContainerClient extends StorageClient { const response = await this.containerContext.getAccessPolicy({ abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions + spanOptions, }); const res: ContainerGetAccessPolicyResponse = { @@ -6150,14 +6463,14 @@ export class ContainerClient extends StorageClient { requestId: response.requestId, clientRequestId: response.clientRequestId, signedIdentifiers: [], - version: response.version + version: response.version, }; for (const identifier of response) { let accessPolicy: any = undefined; if (identifier.accessPolicy) { accessPolicy = { - permissions: identifier.accessPolicy.permissions + permissions: identifier.accessPolicy.permissions, }; if (identifier.accessPolicy.expiresOn) { @@ -6171,7 +6484,7 @@ export class ContainerClient extends StorageClient { res.signedIdentifiers.push({ accessPolicy, - id: identifier.id + id: identifier.id, }); } @@ -6179,7 +6492,7 @@ export class ContainerClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6227,9 +6540,9 @@ export class ContainerClient extends StorageClient { permissions: identifier.accessPolicy.permissions, startsOn: identifier.accessPolicy.startsOn ? truncatedISO8061Date(identifier.accessPolicy.startsOn) - : "" + : "", }, - id: identifier.id + id: identifier.id, }); } @@ -6239,12 +6552,12 @@ export class ContainerClient extends StorageClient { containerAcl: acl, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6300,16 +6613,16 @@ export class ContainerClient extends StorageClient { const blockBlobClient = this.getBlockBlobClient(blobName); const response = await blockBlobClient.upload(body, contentLength, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); return { blockBlobClient, - response + response, }; } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6338,12 +6651,12 @@ export class ContainerClient extends StorageClient { const blobClient = this.getBlobClient(blobName); return await blobClient.delete({ ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, spanOptions }, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6375,12 +6688,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.listBlobFlatSegment({ marker, ...options, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6414,12 +6727,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.listBlobHierarchySegment(delimiter, { marker, ...options, - spanOptions + spanOptions, }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message + message: e.message, }); throw e; } finally { @@ -6569,7 +6882,7 @@ export class ContainerClient extends StorageClient { const updatedOptions: ContainerListBlobsSegmentOptions = { ...options, - ...(include.length > 0 ? { include: include } : {}) + ...(include.length > 0 ? { include: include } : {}), }; // AsyncIterableIterator to iterate over blobs @@ -6593,9 +6906,9 @@ export class ContainerClient extends StorageClient { byPage: (settings: PageSettings = {}) => { return this.listSegments(settings.continuationToken, { maxPageSize: settings.maxPageSize, - ...updatedOptions + ...updatedOptions, }); - } + }, }; } @@ -6774,7 +7087,7 @@ export class ContainerClient extends StorageClient { const updatedOptions: ContainerListBlobsSegmentOptions = { ...options, - ...(include.length > 0 ? { include: include } : {}) + ...(include.length > 0 ? { include: include } : {}), }; // AsyncIterableIterator to iterate over blob prefixes and blobs const iter = this.listItemsByHierarchy(delimiter, updatedOptions); @@ -6797,9 +7110,9 @@ export class ContainerClient extends StorageClient { byPage: (settings: PageSettings = {}) => { return this.listHierarchySegments(delimiter, settings.continuationToken, { maxPageSize: settings.maxPageSize, - ...updatedOptions + ...updatedOptions, }); - } + }, }; } diff --git a/sdk/storage/storage-blob/test/appendblobclient.spec.ts b/sdk/storage/storage-blob/test/appendblobclient.spec.ts index 0c7ea31b632c..2f8b41e00a9d 100644 --- a/sdk/storage/storage-blob/test/appendblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/appendblobclient.spec.ts @@ -64,6 +64,11 @@ describe("AppendBlobClient", () => { assert.equal(properties.metadata!.key2, options.metadata.key2); }); + it("createIfNotExists", async () => { + await appendBlobClient.createIfNotExists(); + await appendBlobClient.createIfNotExists(); + }); + it("appendBlock", async () => { await appendBlobClient.create(); diff --git a/sdk/storage/storage-blob/test/blobclient.spec.ts b/sdk/storage/storage-blob/test/blobclient.spec.ts index 0ba700f1af4c..cd475ea424d6 100644 --- a/sdk/storage/storage-blob/test/blobclient.spec.ts +++ b/sdk/storage/storage-blob/test/blobclient.spec.ts @@ -173,6 +173,13 @@ describe("BlobClient", () => { await blobClient.delete(); }); + it("deleteIfExists", async () => { + const blobName2 = recorder.getUniqueName("blob2"); + const blobClient2 = containerClient.getBlobClient(blobName2); + // delete a non-existent blob + await blobClient2.deleteIfExists(); + }); + // The following code illustrates deleting a snapshot after creating one it("delete snapshot", async () => { const result = await blobClient.createSnapshot(); diff --git a/sdk/storage/storage-blob/test/containerclient.spec.ts b/sdk/storage/storage-blob/test/containerclient.spec.ts index 6311258395dd..572c219d87ca 100644 --- a/sdk/storage/storage-blob/test/containerclient.spec.ts +++ b/sdk/storage/storage-blob/test/containerclient.spec.ts @@ -65,6 +65,30 @@ describe("ContainerClient", () => { assert.ok(result.clientRequestId); // As default pipeline involves UniqueRequestIDPolicy }); + it("createIfNotExists", async () => { + const res = await containerClient.createIfNotExists(); + assert.equal(res, null); + + const containerName2 = recorder.getUniqueName("container2"); + const containerClient2 = blobServiceClient.getContainerClient(containerName2); + const createRes = await containerClient2.createIfNotExists(); + assert.notEqual(createRes, null); + await containerClient2.delete(); + }); + + it("deleteIfExists", async () => { + const containerName2 = recorder.getUniqueName("container2"); + const containerClient2 = blobServiceClient.getContainerClient(containerName2); + await containerClient2.create(); + const res = await containerClient2.deleteIfExists(); + assert.notEqual(null, res); + + const containerName3 = recorder.getUniqueName("container3"); + const containerClient3 = blobServiceClient.getContainerClient(containerName3); + const res2 = await containerClient3.deleteIfExists(); + assert.equal(null, res2); + }); + it("create with default parameters", (done) => { // create() with default parameters has been tested in beforeEach done(); diff --git a/sdk/storage/storage-blob/test/pageblobclient.spec.ts b/sdk/storage/storage-blob/test/pageblobclient.spec.ts index 043c83f0c9c5..452624738b07 100644 --- a/sdk/storage/storage-blob/test/pageblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/pageblobclient.spec.ts @@ -98,6 +98,11 @@ describe("PageBlobClient", () => { } }); + it("createIfNotExists", async () => { + await pageBlobClient.createIfNotExists(512); + await pageBlobClient.createIfNotExists(512); + }); + it("uploadPages", async () => { await pageBlobClient.create(1024); From 26274c8be94df48facc9bf078bcf8bdaee8f9901 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 17:47:52 +0800 Subject: [PATCH 02/12] [storage-flie-share] add CreateIfNotExists and DeleteIfExists --- sdk/storage/storage-file-share/CHANGELOG.md | 5 ++ sdk/storage/storage-file-share/package.json | 1 + .../storage-file-share/src/ShareClient.ts | 75 ++++++++++++++++++ .../src/ShareDirectoryClient.ts | 78 +++++++++++++++++++ .../storage-file-share/src/ShareFileClient.ts | 46 +++++++++++ .../test/directoryclient.spec.ts | 16 ++++ .../test/fileclient.spec.ts | 6 ++ .../test/shareclient.spec.ts | 18 +++++ 8 files changed, 245 insertions(+) diff --git a/sdk/storage/storage-file-share/CHANGELOG.md b/sdk/storage/storage-file-share/CHANGELOG.md index f6f3c7f1b115..247b87bd0e07 100644 --- a/sdk/storage/storage-file-share/CHANGELOG.md +++ b/sdk/storage/storage-file-share/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History +## 12.2.0 (unreleased) + +- Added `DeleteIfExists()` to `ShareClient`, `ShareDirectoryClient`, and `ShareFileClient`. +- Added `CreateIfNotExists()` to `ShareClient` and `ShareDirectoryClient`. + ## 12.1.2 (2020.05) - Fix data corruption failure error [issue #6411](https://github.com/Azure/azure-sdk-for-js/issues/6411) when downloading compressed files. [PR #7993](https://github.com/Azure/azure-sdk-for-js/pull/7993) diff --git a/sdk/storage/storage-file-share/package.json b/sdk/storage/storage-file-share/package.json index 5b5318726dcf..55492a3ef32c 100644 --- a/sdk/storage/storage-file-share/package.json +++ b/sdk/storage/storage-file-share/package.json @@ -44,6 +44,7 @@ "execute:ts-samples": "node ../../../common/scripts/run-samples.js samples/typescript/dist/samples/typescript/src/", "execute:samples": "npm run build:samples && npm run execute:js-samples && npm run execute:ts-samples", "format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "format-input": "prettier --write --config ../../.prettierrc.json", "integration-test:browser": "karma start --single-run", "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/*.spec.js dist-esm/test/node/*.spec.js", "integration-test": "npm run integration-test:node && npm run integration-test:browser", diff --git a/sdk/storage/storage-file-share/src/ShareClient.ts b/sdk/storage/storage-file-share/src/ShareClient.ts index 80fe5d1eb1bf..caf1fcfa113a 100644 --- a/sdk/storage/storage-file-share/src/ShareClient.ts +++ b/sdk/storage/storage-file-share/src/ShareClient.ts @@ -504,6 +504,45 @@ export class ShareClient extends StorageClient { } } + /** + * Creates a new share under the specified account. If the share with + * the same name already exists, it is not changed and the operation returns null. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-share + * + * @param {ShareCreateOptions} [options] + * @returns {Promise} If the share already exists, returns null. + * @memberof ShareClient + */ + public async createIfNotExists( + options: ShareCreateOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "ShareClient-createIfNotExists", + options.tracingOptions + ); + try { + return await this.create({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "ShareAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating share only if it doesn't already exist." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Creates a {@link ShareDirectoryClient} object. * @@ -743,6 +782,42 @@ export class ShareClient extends StorageClient { } } + /** + * Marks the specified share for deletion if it exists. The share and any directories or files + * contained within it are later deleted during garbage collection. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-share + * + * @param {ShareDeleteMethodOptions} [options] + * @returns {Promise} Return null if the share does not exist. + * @memberof ShareClient + */ + public async deletIfExists( + options: ShareDeleteMethodOptions = {} + ): Promise { + const { span, spanOptions } = createSpan("ShareClient-deletIfExists", options.tracingOptions); + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "ShareNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting share only if it exists." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Sets one or more user-defined name-value pairs for the specified share. * diff --git a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts index a774b2c61afd..9896ccd4d34d 100644 --- a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts +++ b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts @@ -494,6 +494,45 @@ export class ShareDirectoryClient extends StorageClient { } } + /** + * Creates a new directory under the specified share or parent directory if it does not already exists. + * If the directory already exists, it is not modified and this operation returns null. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-directory + * + * @param {DirectoryCreateOptions} [options] + * @returns {Promise} Returns null if the directory with the same name already exists. + * @memberof ShareDirectoryClient + */ + public async createIfNotExists( + options: DirectoryCreateOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "ShareDirectoryClient-createIfNotExists", + options.tracingOptions + ); + try { + return await this.create({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "ResourceAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating directory only if it does not already exist." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Sets properties on the directory. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-directory-properties @@ -805,6 +844,45 @@ export class ShareDirectoryClient extends StorageClient { } } + /** + * Removes the specified empty directory if it exists. Note that the directory must be empty before it can be + * deleted. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory + * + * @param {DirectoryDeleteOptions} [options] + * @returns {Promise} Returns null if the directory doesn't exists. + * @memberof ShareDirectoryClient + */ + public async deleteIfExists( + options: DirectoryDeleteOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "ShareDirectoryClient-deleteIfExists", + options.tracingOptions + ); + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "ResourceNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting directory only if it exists." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Updates user defined metadata for the specified directory. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-directory-metadata diff --git a/sdk/storage/storage-file-share/src/ShareFileClient.ts b/sdk/storage/storage-file-share/src/ShareFileClient.ts index 7bd59daabe4a..a60599940371 100644 --- a/sdk/storage/storage-file-share/src/ShareFileClient.ts +++ b/sdk/storage/storage-file-share/src/ShareFileClient.ts @@ -1306,6 +1306,52 @@ export class ShareFileClient extends StorageClient { } } + /** + * Removes the file from the storage account if it exists. + * When a file is successfully deleted, it is immediately removed from the storage + * account's index and is no longer accessible to clients. The file's data is later + * removed from the service during garbage collection. + * + * Delete File will fail with status code 409 (Conflict) and error code SharingViolation + * if the file is open on an SMB client. + * + * Delete File is not supported on a share snapshot, which is a read-only copy of + * a share. An attempt to perform this operation on a share snapshot will fail with 400 (InvalidQueryParameterValue) + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2 + * + * @param {FileDeleteOptions} [options] + * @returns {Promise} Return null if the file does not exist. + * @memberof ShareFileClient + */ + public async deleteIfExists(options: FileDeleteOptions = {}): Promise { + const { span, spanOptions } = createSpan( + "ShareFileClient-deleteIfExists", + options.tracingOptions + ); + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "ResourceNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting file only if it exists." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Sets HTTP headers on the file. * diff --git a/sdk/storage/storage-file-share/test/directoryclient.spec.ts b/sdk/storage/storage-file-share/test/directoryclient.spec.ts index ab64c27d6de8..cad5f12b61a9 100644 --- a/sdk/storage/storage-file-share/test/directoryclient.spec.ts +++ b/sdk/storage/storage-file-share/test/directoryclient.spec.ts @@ -152,6 +152,22 @@ describe("DirectoryClient", () => { assert.ok(result.fileParentId!); }); + it("createIfNotExists", async () => { + await dirClient.createIfNotExists(); + + const dirClient2 = shareClient.getDirectoryClient(recorder.getUniqueName(dirName)); + await dirClient2.createIfNotExists(); + await dirClient2.delete(); + }); + + it("deleteIfExists", async () => { + const dirClient2 = shareClient.getDirectoryClient(recorder.getUniqueName(dirName)); + await dirClient2.deleteIfExists(); + + await dirClient2.create(); + await dirClient2.deleteIfExists(); + }); + it("setProperties with default parameters", async () => { await dirClient.setProperties(); diff --git a/sdk/storage/storage-file-share/test/fileclient.spec.ts b/sdk/storage/storage-file-share/test/fileclient.spec.ts index f81b20af17ba..d9a394cbbdfe 100644 --- a/sdk/storage/storage-file-share/test/fileclient.spec.ts +++ b/sdk/storage/storage-file-share/test/fileclient.spec.ts @@ -288,6 +288,12 @@ describe("FileClient", () => { await fileClient.delete(); }); + it("deleteIfExists", async () => { + await fileClient.deleteIfExists(); + await fileClient.create(content.length); + await fileClient.deleteIfExists(); + }); + it("startCopyFromURL", async () => { recorder.skip("browser"); await fileClient.create(1024); diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index a8d2c6577f16..76cc22f5550c 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -59,11 +59,29 @@ describe("ShareClient", () => { assert.deepEqual(result.metadata, metadata); }); + it("createIfNotExists", async () => { + const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); + const res = await shareClient2.createIfNotExists(); + assert.notEqual(null, res); + const res2 = await shareClient2.createIfNotExists(); + assert.equal(null, res2); + await shareClient2.delete(); + }); + it("delete", (done) => { // delete() with default parameters has been tested in afterEach done(); }); + it("deletIfExists", async () => { + const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); + await shareClient2.create(); + await shareClient2.deletIfExists(); + + const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); + await shareClient3.deletIfExists(); + }); + it("setQuota", async () => { const quotaInGB = 20; await shareClient.setQuota(quotaInGB); From 452587ec4451b65d8a03ebc0c2ed746376fa54a6 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 17:48:51 +0800 Subject: [PATCH 03/12] restore package.json --- sdk/storage/storage-file-share/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/storage/storage-file-share/package.json b/sdk/storage/storage-file-share/package.json index 55492a3ef32c..5b5318726dcf 100644 --- a/sdk/storage/storage-file-share/package.json +++ b/sdk/storage/storage-file-share/package.json @@ -44,7 +44,6 @@ "execute:ts-samples": "node ../../../common/scripts/run-samples.js samples/typescript/dist/samples/typescript/src/", "execute:samples": "npm run build:samples && npm run execute:js-samples && npm run execute:ts-samples", "format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", - "format-input": "prettier --write --config ../../.prettierrc.json", "integration-test:browser": "karma start --single-run", "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/*.spec.js dist-esm/test/node/*.spec.js", "integration-test": "npm run integration-test:node && npm run integration-test:browser", From 64ef820fe4893ac9e8581d1389dbbbd430d77c8b Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 19:01:25 +0800 Subject: [PATCH 04/12] [storage-queue] add createIfNotExists and deleteIfExists --- sdk/storage/storage-blob/CHANGELOG.md | 3 +- sdk/storage/storage-blob/src/Clients.ts | 11 +- sdk/storage/storage-file-share/CHANGELOG.md | 4 +- .../storage-file-share/src/ShareClient.ts | 34 +-- .../src/ShareDirectoryClient.ts | 6 +- .../storage-file-share/src/ShareFileClient.ts | 2 +- sdk/storage/storage-queue/CHANGELOG.md | 4 + sdk/storage/storage-queue/src/QueueClient.ts | 255 +++++++++++++----- .../storage-queue/test/queueclient.spec.ts | 28 +- 9 files changed, 253 insertions(+), 94 deletions(-) diff --git a/sdk/storage/storage-blob/CHANGELOG.md b/sdk/storage/storage-blob/CHANGELOG.md index 583dac04db8e..5aa89d2fd7d6 100644 --- a/sdk/storage/storage-blob/CHANGELOG.md +++ b/sdk/storage/storage-blob/CHANGELOG.md @@ -2,7 +2,8 @@ ## 12.2.0 (unreleased) -- Added CreateIfNotExists and DeleteIfNotExists convenience methods for Blobs and Containers. +- Added convenience method `createIfNotExists` for `ContainerClient`, `AppendBlobClient` and `PageBlobClient`. +- Added convenience method `deleteIfExists` for `ContainerClient` and `BlobClients`. ## 12.1.2 (2020.05) diff --git a/sdk/storage/storage-blob/src/Clients.ts b/sdk/storage/storage-blob/src/Clients.ts index f90e6bade06a..4df1d4a88da8 100644 --- a/sdk/storage/storage-blob/src/Clients.ts +++ b/sdk/storage/storage-blob/src/Clients.ts @@ -1373,7 +1373,7 @@ export class BlobClient extends StorageClient { if (e.details?.errorCode === "BlobNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting blob or snapshot only if it exists.", + message: "Expected exception when deleting a blob or snapshot only if it exists.", }); return null; } @@ -2567,7 +2567,7 @@ export class AppendBlobClient extends BlobClient { if (e.details?.errorCode === "BlobAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating blob only if it does not already exist.", + message: "Expected exception when creating a blob only if it does not already exist.", }); return null; } @@ -4733,7 +4733,7 @@ export class PageBlobClient extends BlobClient { if (e.details?.errorCode === "BlobAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating blob only if it does not already exist.", + message: "Expected exception when creating a blob only if it does not already exist.", }); return null; } @@ -6126,7 +6126,8 @@ export class ContainerClient extends StorageClient { if (e.details?.errorCode === "ContainerAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating container only if it does not already exist.", + message: + "Expected exception when creating a container only if it does not already exist.", }); return null; } @@ -6353,7 +6354,7 @@ export class ContainerClient extends StorageClient { if (e.details?.errorCode === "ContainerNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting container only if it exists.", + message: "Expected exception when deleting a container only if it exists.", }); return null; } diff --git a/sdk/storage/storage-file-share/CHANGELOG.md b/sdk/storage/storage-file-share/CHANGELOG.md index 247b87bd0e07..a73bebe9cbdc 100644 --- a/sdk/storage/storage-file-share/CHANGELOG.md +++ b/sdk/storage/storage-file-share/CHANGELOG.md @@ -2,8 +2,8 @@ ## 12.2.0 (unreleased) -- Added `DeleteIfExists()` to `ShareClient`, `ShareDirectoryClient`, and `ShareFileClient`. -- Added `CreateIfNotExists()` to `ShareClient` and `ShareDirectoryClient`. +- Added `deleteIfExists()` to `ShareClient`, `ShareDirectoryClient`, and `ShareFileClient`. +- Added `createIfNotExists()` to `ShareClient` and `ShareDirectoryClient`. ## 12.1.2 (2020.05) diff --git a/sdk/storage/storage-file-share/src/ShareClient.ts b/sdk/storage/storage-file-share/src/ShareClient.ts index caf1fcfa113a..0833131ed949 100644 --- a/sdk/storage/storage-file-share/src/ShareClient.ts +++ b/sdk/storage/storage-file-share/src/ShareClient.ts @@ -241,24 +241,24 @@ export interface SignedIdentifier { export declare type ShareGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ShareGetAccessPolicyHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: ShareGetAccessPolicyHeaders; /** - * The underlying HTTP response. + * The response body as text (string format) */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ShareGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignedIdentifierModel[]; - }; + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; }; +}; /** * Options to configure the {@link ShareClient.createSnapshot} operation. @@ -529,7 +529,7 @@ export class ShareClient extends StorageClient { if (e.details?.errorCode === "ShareAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating share only if it doesn't already exist." + message: "Expected exception when creating a share only if it doesn't already exist." }); return null; } @@ -804,7 +804,7 @@ export class ShareClient extends StorageClient { if (e.details?.errorCode === "ShareNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting share only if it exists." + message: "Expected exception when deleting a share only if it exists." }); return null; } diff --git a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts index 9896ccd4d34d..2653804ac59f 100644 --- a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts +++ b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts @@ -68,7 +68,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti export interface DirectoryProperties extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -519,7 +519,7 @@ export class ShareDirectoryClient extends StorageClient { if (e.details?.errorCode === "ResourceAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating directory only if it does not already exist." + message: "Expected exception when creating a directory only if it does not already exist." }); return null; } @@ -869,7 +869,7 @@ export class ShareDirectoryClient extends StorageClient { if (e.details?.errorCode === "ResourceNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting directory only if it exists." + message: "Expected exception when deleting a directory only if it exists." }); return null; } diff --git a/sdk/storage/storage-file-share/src/ShareFileClient.ts b/sdk/storage/storage-file-share/src/ShareFileClient.ts index a60599940371..f8c8d673421c 100644 --- a/sdk/storage/storage-file-share/src/ShareFileClient.ts +++ b/sdk/storage/storage-file-share/src/ShareFileClient.ts @@ -1338,7 +1338,7 @@ export class ShareFileClient extends StorageClient { if (e.details?.errorCode === "ResourceNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting file only if it exists." + message: "Expected exception when deleting a file only if it exists." }); return null; } diff --git a/sdk/storage/storage-queue/CHANGELOG.md b/sdk/storage/storage-queue/CHANGELOG.md index 2461684c430f..0e916b50126d 100644 --- a/sdk/storage/storage-queue/CHANGELOG.md +++ b/sdk/storage/storage-queue/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 12.1.0 (unreleased) + +- Added `exists`, `createIfNotExists` and `deleteIfExists` to `QueueClient`. + ## 12.0.5 (2020.05) - Fix un-handled TypeError [issue #8499](https://github.com/Azure/azure-sdk-for-js/issues/8499) in Electron applications. [PR #8568](https://github.com/Azure/azure-sdk-for-js/pull/8568) diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index 16afad4189b4..f374e30e895b 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -71,6 +71,23 @@ export interface QueueCreateOptions extends CommonOptions { metadata?: Metadata; } +/** + * Options to configure {@link QueueClient.exists} operation + * + * @export + * @interface QueueExistsOptions + */ +export interface QueueExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof QueueExistsOptions + */ + abortSignal?: AbortSignalLike; +} + /** * Options to configure {@link QueueClient.getProperties} operation * @@ -193,24 +210,24 @@ export interface SignedIdentifier { export declare type QueueGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & QueueGetAccessPolicyHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: QueueGetAccessPolicyHeaders; /** - * The underlying HTTP response. + * The response body as text (string format) */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: QueueGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignedIdentifierModel[]; - }; + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; }; +}; /** * Options to configure {@link QueueClient.clearMessages} operation @@ -236,7 +253,7 @@ export interface QueueClearMessagesOptions extends CommonOptions { * @interface QueueSendMessageOptions * @extends {MessagesEnqueueOptionalParams} */ -export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions {} +export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions { } /** * Options to configure {@link QueueClient.receiveMessages} operation @@ -245,7 +262,7 @@ export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, * @interface QueueReceiveMessageOptions * @extends {MessagesDequeueOptionalParams} */ -export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions {} +export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions { } /** * Options to configure {@link QueueClient.peekMessages} operation @@ -254,7 +271,7 @@ export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParam * @interface QueuePeekMessagesOptions * @extends {MessagesPeekOptionalParams} */ -export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions {} +export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions { } /** * Contains the response data for the {@link QueueClient.sendMessage} operation. @@ -286,24 +303,24 @@ export declare type QueueSendMessageResponse = { */ nextVisibleOn: Date; } & MessagesEnqueueHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesEnqueueHeaders; /** - * The underlying HTTP response. + * The response body as text (string format) */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesEnqueueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: EnqueuedMessage[]; - }; + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: EnqueuedMessage[]; }; +}; /** * The object returned in the `receivedMessageItems` array when calling {@link QueueClient.receiveMessages}. @@ -318,24 +335,24 @@ export declare type ReceivedMessageItem = DequeuedMessageItem; export declare type QueueReceiveMessageResponse = { receivedMessageItems: ReceivedMessageItem[]; } & MessagesDequeueHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesDequeueHeaders; /** - * The underlying HTTP response. + * The response body as text (string format) */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesDequeueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: ReceivedMessageItem[]; - }; + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: ReceivedMessageItem[]; }; +}; /** * Contains the response data for the {@link QueueClient.peekMessages} operation. @@ -343,24 +360,24 @@ export declare type QueueReceiveMessageResponse = { export declare type QueuePeekMessagesResponse = { peekedMessageItems: PeekedMessageItem[]; } & MessagesPeekHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesPeekHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: PeekedMessageItem[]; - }; + parsedHeaders: MessagesPeekHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: PeekedMessageItem[]; }; +}; /** * Options to configure the {@link QueueClient.deleteMessage} operation @@ -608,6 +625,81 @@ export class QueueClient extends StorageClient { } } + /** + * Creates a new queue under the specified account if it doesn't already exist. + * If the queue already exists, it is not changed. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-queue4 + * + * @param {QueueCreateOptions} [options] + * @returns {Promise} Returns null if the queue already exists. + * @memberof QueueClient + */ + public async createIfNotExists(options: QueueCreateOptions = {}): Promise { + const { span, spanOptions } = createSpan("QueueClient-createIfNotExists", options.tracingOptions); + try { + const response = await this.create({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + + // When a queue with the specified name already exists, the Queue service checks the metadata associated with the existing queue. + // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned. + // If the existing metadata does not match, the operation fails and status code 409 (Conflict) is returned. + if (response._response.status == 204) { + return null; + } + return response; + } catch (e) { + if (e.details?.errorCode === "QueueAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating a queue only if it does not already exist." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Deletes the specified queue permanently if it exists. + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-queue3 + * + * @param {QueueDeleteOptions} [options] + * @returns {Promise} Returns null if the queue doesn't exists. + * @memberof QueueClient + */ + public async deleteIfExists(options: QueueDeleteOptions = {}): Promise { + const { span, spanOptions } = createSpan("QueueClient-deleteIfExists", options.tracingOptions); + try { + return await this.delete({ + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "QueueNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting a queue only if it exists." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Deletes the specified queue permanently. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-queue3 @@ -643,6 +735,43 @@ export class QueueClient extends StorageClient { } } + /** + * Returns true if the specified queue exists; false otherwise. + * + * NOTE: use this function with care since an existing queue might be deleted by other clients or + * applications. Vice versa new queues might be added by other clients or applications after this + * function completes. + * + * @param {QueueExistsOptions} [options] options to Exists operation. + * @returns {Promise} + * @memberof QueueClient + */ + public async exists(options: QueueExistsOptions = {}): Promise { + const { span, spanOptions } = createSpan("QueueClient-exists", options.tracingOptions); + try { + await this.getProperties({ + abortSignal: options.abortSignal, + tracingOptions: { ...options.tracingOptions, spanOptions } + }); + return true; + } catch (e) { + if (e.statusCode === 404) { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when checking queue existence" + }); + return false; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Gets all user-defined metadata and system properties for the specified * queue. Metadata is associated with the queue as name-values pairs. diff --git a/sdk/storage/storage-queue/test/queueclient.spec.ts b/sdk/storage/storage-queue/test/queueclient.spec.ts index b4c39aa6f3de..d322e6281fdb 100644 --- a/sdk/storage/storage-queue/test/queueclient.spec.ts +++ b/sdk/storage/storage-queue/test/queueclient.spec.ts @@ -15,7 +15,7 @@ describe("QueueClient", () => { let recorder: Recorder; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); queueServiceClient = getQSU(); queueName = recorder.getUniqueName("queue"); @@ -23,7 +23,7 @@ describe("QueueClient", () => { await queueClient.create(); }); - afterEach(async function() { + afterEach(async function () { await queueClient.delete(); recorder.stop(); }); @@ -96,6 +96,30 @@ describe("QueueClient", () => { ); }); + it("exists", async () => { + assert.ok(await queueClient.exists()); + + const qClient = queueServiceClient.getQueueClient(recorder.getUniqueName(queueName)); + assert.ok(!(await qClient.exists())); + }); + + it("createIfNotExists", async () => { + const res = await queueClient.createIfNotExists(); + assert.equal(null, res); + + const metadata = { key: "value" }; + const res2 = await queueClient.createIfNotExists({ metadata }); + assert.equal(null, res2); + }); + + it("deleteIfExists", async () => { + const qClient = queueServiceClient.getQueueClient(recorder.getUniqueName(queueName)); + await qClient.deleteIfExists(); + + await qClient.create(); + await qClient.deleteIfExists(); + }); + it("delete", (done) => { // delete() with default parameters has been tested in afterEach done(); From 5c898a5f0848eba58e63f386a08e444bb19536c9 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 20:13:07 +0800 Subject: [PATCH 05/12] add exists for storage-file-share --- sdk/storage/storage-file-share/CHANGELOG.md | 2 +- .../review/storage-file-share.api.md | 23 +++++++ .../storage-file-share/src/ShareClient.ts | 54 +++++++++++++++ .../src/ShareDirectoryClient.ts | 67 +++++++++++++++++-- .../storage-file-share/src/ShareFileClient.ts | 67 +++++++++++++++++-- .../test/directoryclient.spec.ts | 10 ++- .../test/fileclient.spec.ts | 14 ++-- .../test/shareclient.spec.ts | 11 ++- 8 files changed, 229 insertions(+), 19 deletions(-) diff --git a/sdk/storage/storage-file-share/CHANGELOG.md b/sdk/storage/storage-file-share/CHANGELOG.md index a73bebe9cbdc..4f0836c5ac19 100644 --- a/sdk/storage/storage-file-share/CHANGELOG.md +++ b/sdk/storage/storage-file-share/CHANGELOG.md @@ -2,7 +2,7 @@ ## 12.2.0 (unreleased) -- Added `deleteIfExists()` to `ShareClient`, `ShareDirectoryClient`, and `ShareFileClient`. +- Added `exists` and `deleteIfExists()` to `ShareClient`, `ShareDirectoryClient`, and `ShareFileClient`. - Added `createIfNotExists()` to `ShareClient` and `ShareDirectoryClient`. ## 12.1.2 (2020.05) diff --git a/sdk/storage/storage-file-share/review/storage-file-share.api.md b/sdk/storage/storage-file-share/review/storage-file-share.api.md index fa73a6f94ae3..cece10fa0e5b 100644 --- a/sdk/storage/storage-file-share/review/storage-file-share.api.md +++ b/sdk/storage/storage-file-share/review/storage-file-share.api.md @@ -207,6 +207,11 @@ export type DirectoryDeleteResponse = DirectoryDeleteHeaders & { }; }; +// @public +export interface DirectoryExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; +} + // @public export interface DirectoryForceCloseHandlesHeaders { date?: Date; @@ -580,6 +585,11 @@ export interface FileDownloadToBufferOptions extends CommonOptions { rangeSize?: number; } +// @public +export interface FileExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; +} + // @public export interface FileForceCloseHandlesHeaders { date?: Date; @@ -1286,11 +1296,14 @@ export class ShareClient extends StorageClient { fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse; }>; + createIfNotExists(options?: ShareCreateOptions): Promise; createPermission(filePermission: string, options?: ShareCreatePermissionOptions): Promise; createSnapshot(options?: ShareCreateSnapshotOptions): Promise; delete(options?: ShareDeleteMethodOptions): Promise; deleteDirectory(directoryName: string, options?: DirectoryDeleteOptions): Promise; deleteFile(fileName: string, options?: FileDeleteOptions): Promise; + deletIfExists(options?: ShareDeleteMethodOptions): Promise; + exists(options?: ShareExistsOptions): Promise; getAccessPolicy(options?: ShareGetAccessPolicyOptions): Promise; getDirectoryClient(directoryName: string): ShareDirectoryClient; getPermission(filePermissionKey: string, options?: ShareGetPermissionOptions): Promise; @@ -1411,13 +1424,16 @@ export class ShareDirectoryClient extends StorageClient { fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse; }>; + createIfNotExists(options?: DirectoryCreateOptions): Promise; createSubdirectory(directoryName: string, options?: DirectoryCreateOptions): Promise<{ directoryClient: ShareDirectoryClient; directoryCreateResponse: DirectoryCreateResponse; }>; delete(options?: DirectoryDeleteOptions): Promise; deleteFile(fileName: string, options?: FileDeleteOptions): Promise; + deleteIfExists(options?: DirectoryDeleteOptions): Promise; deleteSubdirectory(directoryName: string, options?: DirectoryDeleteOptions): Promise; + exists(options?: DirectoryExistsOptions): Promise; forceCloseAllHandles(options?: DirectoryForceCloseHandlesSegmentOptions): Promise; forceCloseHandle(handleId: string, options?: DirectoryForceCloseHandlesOptions): Promise; getDirectoryClient(subDirectoryName: string): ShareDirectoryClient; @@ -1436,6 +1452,11 @@ export class ShareDirectoryClient extends StorageClient { get shareName(): string; } +// @public +export interface ShareExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; +} + // @public export class ShareFileClient extends StorageClient { constructor(url: string, credential?: Credential, options?: StoragePipelineOptions); @@ -1444,10 +1465,12 @@ export class ShareFileClient extends StorageClient { clearRange(offset: number, contentLength: number, options?: FileClearRangeOptions): Promise; create(size: number, options?: FileCreateOptions): Promise; delete(options?: FileDeleteOptions): Promise; + deleteIfExists(options?: FileDeleteOptions): Promise; download(offset?: number, count?: number, options?: FileDownloadOptions): Promise; downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise; downloadToBuffer(offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise; downloadToFile(filePath: string, offset?: number, count?: number, options?: FileDownloadOptions): Promise; + exists(options?: FileExistsOptions): Promise; forceCloseAllHandles(options?: FileForceCloseHandlesOptions): Promise; forceCloseHandle(handleId: string, options?: FileForceCloseHandlesOptions): Promise; getProperties(options?: FileGetPropertiesOptions): Promise; diff --git a/sdk/storage/storage-file-share/src/ShareClient.ts b/sdk/storage/storage-file-share/src/ShareClient.ts index 0833131ed949..0c8dc71a8317 100644 --- a/sdk/storage/storage-file-share/src/ShareClient.ts +++ b/sdk/storage/storage-file-share/src/ShareClient.ts @@ -156,6 +156,23 @@ export interface ShareGetAccessPolicyOptions extends CommonOptions { abortSignal?: AbortSignalLike; } +/** + * Options to configure the {@link ShareClient.exists} operation. + * + * @export + * @interface ShareExistsOptions + */ +export interface ShareExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof ShareExistsOptions + */ + abortSignal?: AbortSignalLike; +} + /** * Options to configure the {@link ShareClient.getProperties} operation. * @@ -722,6 +739,43 @@ export class ShareClient extends StorageClient { } } + /** + * Returns true if the Azrue share resource represented by this client exists; false otherwise. + * + * NOTE: use this function with care since an existing share might be deleted by other clients or + * applications. Vice versa new shares might be added by other clients or applications after this + * function completes. + * + * @param {ShareExistsOptions} [options] options to Exists operation. + * @returns {Promise} + * @memberof ShareClient + */ + public async exists(options: ShareExistsOptions = {}): Promise { + const { span, spanOptions } = createSpan("ShareClient-exists", options.tracingOptions); + try { + await this.getProperties({ + abortSignal: options.abortSignal, + tracingOptions: { ...options.tracingOptions, spanOptions } + }); + return true; + } catch (e) { + if (e.statusCode === 404) { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when checking share existence" + }); + return false; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns all user-defined metadata and system properties for the specified * share. diff --git a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts index 2653804ac59f..39e67d748854 100644 --- a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts +++ b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts @@ -54,7 +54,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof DirectoryCreateOptions */ abortSignal?: AbortSignalLike; /** @@ -95,7 +95,7 @@ interface DirectoryListFilesAndDirectoriesSegmentOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof DirectoryListFilesAndDirectoriesSegmentOptions */ abortSignal?: AbortSignalLike; /** @@ -155,7 +155,24 @@ export interface DirectoryDeleteOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof DirectoryDeleteOptions + */ + abortSignal?: AbortSignalLike; +} + +/** + * Options to configure the {@link ShareDirectoryClient.exists} operation. + * + * @export + * @interface DirectoryExistsOptions + */ +export interface DirectoryExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof DirectoryExistsOptions */ abortSignal?: AbortSignalLike; } @@ -172,7 +189,7 @@ export interface DirectoryGetPropertiesOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof DirectoryGetPropertiesOptions */ abortSignal?: AbortSignalLike; } @@ -189,7 +206,7 @@ export interface DirectorySetMetadataOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof DirectorySetMetadataOptions */ abortSignal?: AbortSignalLike; } @@ -784,6 +801,46 @@ export class ShareDirectoryClient extends StorageClient { ); } + /** + * Returns true if the specified directory exists; false otherwise. + * + * NOTE: use this function with care since an existing directory might be deleted by other clients or + * applications. Vice versa new directories might be added by other clients or applications after this + * function completes. + * + * @param {DirectoryExistsOptions} [options] options to Exists operation. + * @returns {Promise} + * @memberof ShareDirectoryClient + */ + public async exists(options: DirectoryExistsOptions = {}): Promise { + const { span, spanOptions } = createSpan("ShareDirectoryClient-exists", options.tracingOptions); + try { + await this.getProperties({ + abortSignal: options.abortSignal, + tracingOptions: { + ...options.tracingOptions, + spanOptions + } + }); + return true; + } catch (e) { + if (e.statusCode === 404) { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when checking directory existence" + }); + return false; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns all system properties for the specified directory, and can also be used to check the * existence of a directory. The data returned does not include the files in the directory or any diff --git a/sdk/storage/storage-file-share/src/ShareFileClient.ts b/sdk/storage/storage-file-share/src/ShareFileClient.ts index f8c8d673421c..179097b56e11 100644 --- a/sdk/storage/storage-file-share/src/ShareFileClient.ts +++ b/sdk/storage/storage-file-share/src/ShareFileClient.ts @@ -76,7 +76,7 @@ export interface FileCreateOptions extends FileAndDirectoryCreateCommonOptions, * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof FileCreateOptions */ abortSignal?: AbortSignalLike; /** @@ -170,7 +170,7 @@ export interface FileDownloadOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof FileDownloadOptions */ abortSignal?: AbortSignalLike; /** @@ -227,7 +227,7 @@ export interface FileUploadRangeOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof FileUploadRangeOptions */ abortSignal?: AbortSignalLike; /** @@ -331,7 +331,7 @@ export interface FileGetRangeListOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof FileGetRangeListOptions */ abortSignal?: AbortSignalLike; /** @@ -350,6 +350,23 @@ export interface FileGetRangeListOptions extends CommonOptions { leaseAccessConditions?: LeaseAccessConditions; } +/** + * Options to configure the {@link ShareFileClient.exists} operation. + * + * @export + * @interface FileExistsOptions + */ +export interface FileExistsOptions extends CommonOptions { + /** + * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. + * For example, use the @azure/abort-controller to create an `AbortSignal`. + * + * @type {AbortSignalLike} + * @memberof FileExistsOptions + */ + abortSignal?: AbortSignalLike; +} + /** * Options to configure the {@link ShareFileClient.getProperties} operation. * @@ -362,7 +379,7 @@ export interface FileGetPropertiesOptions extends CommonOptions { * For example, use the @azure/abort-controller to create an `AbortSignal`. * * @type {AbortSignalLike} - * @memberof AppendBlobCreateOptions + * @memberof FileGetPropertiesOptions */ abortSignal?: AbortSignalLike; /** @@ -1191,6 +1208,46 @@ export class ShareFileClient extends StorageClient { } } + /** + * Returns true if the specified file exists; false otherwise. + * + * NOTE: use this function with care since an existing file might be deleted by other clients or + * applications. Vice versa new files might be added by other clients or applications after this + * function completes. + * + * @param {FileExistsOptions} [options] options to Exists operation. + * @returns {Promise} + * @memberof ShareFileClient + */ + public async exists(options: FileExistsOptions = {}): Promise { + const { span, spanOptions } = createSpan("ShareFileClient-exists", options.tracingOptions); + try { + await this.getProperties({ + abortSignal: options.abortSignal, + tracingOptions: { + ...options.tracingOptions, + spanOptions + } + }); + return true; + } catch (e) { + if (e.statusCode === 404) { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when checking file existence" + }); + return false; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns all user-defined metadata, standard HTTP properties, and system properties * for the file. It does not return the content of the file. diff --git a/sdk/storage/storage-file-share/test/directoryclient.spec.ts b/sdk/storage/storage-file-share/test/directoryclient.spec.ts index cad5f12b61a9..8e88963770ef 100644 --- a/sdk/storage/storage-file-share/test/directoryclient.spec.ts +++ b/sdk/storage/storage-file-share/test/directoryclient.spec.ts @@ -28,7 +28,7 @@ describe("DirectoryClient", () => { fullDirAttributes.notContentIndexed = true; fullDirAttributes.noScrubData = true; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); const serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -49,7 +49,7 @@ describe("DirectoryClient", () => { assert.ok(defaultDirCreateResp.filePermissionKey!); }); - afterEach(async function() { + afterEach(async function () { await shareClient.delete(); recorder.stop(); }); @@ -168,6 +168,12 @@ describe("DirectoryClient", () => { await dirClient2.deleteIfExists(); }); + it("exists", async () => { + assert.ok(await dirClient.exists()); + const dirClient2 = shareClient.getDirectoryClient(recorder.getUniqueName(dirName)); + assert.ok(!(await dirClient2.exists())); + }); + it("setProperties with default parameters", async () => { await dirClient.setProperties(); diff --git a/sdk/storage/storage-file-share/test/fileclient.spec.ts b/sdk/storage/storage-file-share/test/fileclient.spec.ts index d9a394cbbdfe..7b85b45b79fc 100644 --- a/sdk/storage/storage-file-share/test/fileclient.spec.ts +++ b/sdk/storage/storage-file-share/test/fileclient.spec.ts @@ -40,7 +40,7 @@ describe("FileClient", () => { fullFileAttributes.notContentIndexed = true; fullFileAttributes.noScrubData = true; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); const serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -56,7 +56,7 @@ describe("FileClient", () => { fileClient = dirClient.getFileClient(fileName); }); - afterEach(async function() { + afterEach(async function () { if (!this.currentTest?.isPending()) { await shareClient.delete(); recorder.stop(); @@ -294,6 +294,12 @@ describe("FileClient", () => { await fileClient.deleteIfExists(); }); + it("exists", async () => { + assert.ok(!(await fileClient.exists())); + await fileClient.create(content.length); + assert.ok(await fileClient.exists()); + }); + it("startCopyFromURL", async () => { recorder.skip("browser"); await fileClient.create(1024); @@ -539,7 +545,7 @@ describe("FileClient", () => { await fileClient.create(content.length); await fileClient.uploadRange(content, 0, content.length); const result = await fileClient.download(0, undefined, { - onProgress: () => {} + onProgress: () => { } }); assert.deepStrictEqual(await bodyToString(result), content); }); @@ -576,7 +582,7 @@ describe("FileClient", () => { const rs = result.readableStreamBody!; // tslint:disable-next-line:no-empty - rs.on("data", () => {}); + rs.on("data", () => { }); rs.on("end", resolve); rs.on("error", reject); } else { diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index 76cc22f5550c..6404a8306242 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -12,7 +12,7 @@ describe("ShareClient", () => { let recorder: Recorder; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -20,7 +20,7 @@ describe("ShareClient", () => { await shareClient.create(); }); - afterEach(async function() { + afterEach(async function () { await shareClient.delete(); recorder.stop(); }); @@ -37,6 +37,13 @@ describe("ShareClient", () => { assert.deepEqual(result.metadata, metadata); }); + it("exists", async () => { + assert.ok(await shareClient.exists()); + + const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); + assert.ok(!(await shareClient2.exists())); + }); + it("getProperties", async () => { const result = await shareClient.getProperties(); assert.ok(result.etag!.length > 0); From 29f2ce4c1a8c0fb05194cea89b89043da3eb9df7 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 17 May 2020 22:08:57 +0800 Subject: [PATCH 06/12] add createIfNotExists and deleteIfExists for storage-file-datalake --- .../storage-file-datalake/CHANGELOG.md | 4 + .../review/storage-file-datalake.api.md | 30 +++ .../src/DataLakeFileSystemClient.ts | 62 +++++ .../storage-file-datalake/src/clients.ts | 214 +++++++++++++++++- .../storage-file-datalake/src/models.ts | 32 ++- .../src/utils/constants.ts | 2 + .../test/filesystemclient.spec.ts | 25 +- .../test/pathclient.spec.ts | 24 +- 8 files changed, 377 insertions(+), 16 deletions(-) diff --git a/sdk/storage/storage-file-datalake/CHANGELOG.md b/sdk/storage/storage-file-datalake/CHANGELOG.md index 6e753ac3f0e1..9008fb2429f1 100644 --- a/sdk/storage/storage-file-datalake/CHANGELOG.md +++ b/sdk/storage/storage-file-datalake/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 12.1.0 (unreleased) + +- Added convenience methods `createIfNotExists`, `deleteIfExists` to `DataLakeFileSystemClient`, `DataLakePathClient`, `DataLakeDirectoryClient`, and `DataLakeFileClient`. + ## 12.0.1 (2020.05) - Fix data corruption failure error [issue #6411](https://github.com/Azure/azure-sdk-for-js/issues/6411) when downloading compressed files. [PR #7993](https://github.com/Azure/azure-sdk-for-js/pull/7993) diff --git a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md index 063b97d97cd8..3f8105dedf27 100644 --- a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md +++ b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md @@ -133,6 +133,8 @@ export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: Reque export class DataLakeDirectoryClient extends DataLakePathClient { create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; create(options?: DirectoryCreateOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; + createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise; getFileClient(fileName: string): DataLakeFileClient; getSubdirectoryClient(subdirectoryName: string): DataLakeDirectoryClient; } @@ -144,6 +146,8 @@ export class DataLakeFileClient extends DataLakePathClient { append(body: HttpRequestBody, offset: number, length: number, options?: FileAppendOptions): Promise; create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; create(options?: FileCreateOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; + createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise; flush(position: number, options?: FileFlushOptions): Promise; read(offset?: number, count?: number, options?: FileReadOptions): Promise; readToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileReadToBufferOptions): Promise; @@ -161,7 +165,9 @@ export class DataLakeFileSystemClient extends StorageClient { constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); constructor(url: string, pipeline: Pipeline); create(options?: FileSystemCreateOptions): Promise; + createIfNotExists(options?: FileSystemCreateOptions): Promise; delete(options?: FileSystemDeleteOptions): Promise; + deleteIfExists(options?: FileSystemDeleteOptions): Promise; exists(options?: FileSystemExistsOptions): Promise; getAccessPolicy(options?: FileSystemGetAccessPolicyOptions): Promise; getDataLakeLeaseClient(proposeLeaseId?: string): DataLakeLeaseClient; @@ -198,7 +204,9 @@ export class DataLakePathClient extends StorageClient { constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); constructor(url: string, pipeline: Pipeline); create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; delete(recursive?: boolean, options?: PathDeleteOptions): Promise; + deleteIfExists(recursive?: boolean, options?: PathDeleteOptions): Promise; exists(options?: PathExistsOptions): Promise; get fileSystemName(): string; getAccessControl(options?: PathGetAccessControlOptions): Promise; @@ -260,6 +268,10 @@ export class DataLakeServiceClient extends StorageClient { export { deserializationPolicy } +// @public (undocumented) +export interface DirectoryCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { +} + // @public export interface DirectoryCreateOptions extends PathCreateOptions { } @@ -280,6 +292,10 @@ export interface FileAppendOptions extends CommonOptions { transactionalContentMD5?: Uint8Array; } +// @public (undocumented) +export interface FileCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { +} + // @public (undocumented) export interface FileCreateOptions extends PathCreateOptions { } @@ -846,6 +862,20 @@ export interface PathCreateHttpHeaders { contentType?: string; } +// @public (undocumented) +export interface PathCreateIfNotExistsOptions extends CommonOptions { + // (undocumented) + abortSignal?: AbortSignalLike; + // (undocumented) + metadata?: Metadata; + // (undocumented) + pathHttpHeaders?: PathCreateHttpHeaders; + // (undocumented) + permissions?: string; + // (undocumented) + umask?: string; +} + // @public (undocumented) export interface PathCreateOptions extends CommonOptions { // (undocumented) diff --git a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts index ea06d5be6eb0..06c2446805a5 100644 --- a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts +++ b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts @@ -203,6 +203,38 @@ export class DataLakeFileSystemClient extends StorageClient { } } + /** + * Creates a new file system under the specified account. If the file system with + * the same name already exists, it is not changed and this operation returns null. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-container + * + * @param {FileSystemCreateOptions} [options={}] + * @returns {Promise} + * @memberof DataLakeFileSystemClient + */ + public async createIfNotExists(options: FileSystemCreateOptions = {}): Promise { + const { span, spanOptions } = createSpan( + "DataLakeFileSystemClient-createIfNotExists", + options.tracingOptions + ); + try { + return await this.blobContainerClient.createIfNotExists({ + ...options, + access: toContainerPublicAccessType(options.access), + tracingOptions: { ...options.tracingOptions, spanOptions } + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns true if the File system represented by this client exists; false otherwise. * @@ -265,6 +297,36 @@ export class DataLakeFileSystemClient extends StorageClient { } } + /** + * Delete current file system if it exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container + * + * @param {FileSystemDeleteOptions} [options={}] + * @returns {Promise} Returns null if the specified file system doesn't exists. + * @memberof DataLakeFileSystemClient + */ + public async deleteIfExists(options: FileSystemDeleteOptions = {}): Promise { + const { span, spanOptions } = createSpan( + "DataLakeFileSystemClient-deleteIfExists", + options.tracingOptions + ); + try { + return await this.blobContainerClient.deleteIfExists({ + ...options, + tracingOptions: { ...options.tracingOptions, spanOptions } + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns all user-defined metadata and system properties for the specified * file system. diff --git a/sdk/storage/storage-file-datalake/src/clients.ts b/sdk/storage/storage-file-datalake/src/clients.ts index 3d15bb942803..e435f5d74c78 100644 --- a/sdk/storage/storage-file-datalake/src/clients.ts +++ b/sdk/storage/storage-file-datalake/src/clients.ts @@ -10,9 +10,11 @@ import { DataLakeLeaseClient } from "./DataLakeLeaseClient"; import { PathOperations } from "./generated/src/operations"; import { DirectoryCreateOptions, + DirectoryCreateIfNotExistsOptions, DirectoryCreateResponse, FileAppendOptions, FileAppendResponse, + FileCreateIfNotExistsOptions, FileCreateOptions, FileCreateResponse, FileFlushOptions, @@ -25,6 +27,7 @@ import { Metadata, PathAccessControlItem, PathCreateOptions, + PathCreateIfNotExistsOptions, PathCreateResponse, PathDeleteOptions, PathDeleteResponse, @@ -66,7 +69,8 @@ import { FILE_UPLOAD_MAX_CHUNK_SIZE, FILE_MAX_SIZE_BYTES, FILE_UPLOAD_DEFAULT_CHUNK_SIZE, - BLOCK_BLOB_MAX_BLOCKS + BLOCK_BLOB_MAX_BLOCKS, + ETagAny } from "./utils/constants"; import { BufferScheduler } from "./utils/BufferScheduler"; import { Batch } from "./utils/Batch"; @@ -243,6 +247,47 @@ export class DataLakePathClient extends StorageClient { } } + /** + * Create a directory or file. If the resource already exists, it is not changed and this + * operation returns null. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {PathResourceType} resourceType Resource type, "directory" or "file". + * @param {PathCreateOptions} [options={}] + * @returns {Promise} + * @memberof DataLakePathClient + */ + public async createIfNotExists( + resourceType: PathResourceType, + options: PathCreateIfNotExistsOptions = {} + ): Promise { + const { span, spanOptions } = createSpan("DataLakePathClient-createIfNotExists", options.tracingOptions); + try { + const conditions = { ifNoneMatch: ETagAny }; + return await this.create(resourceType, { + ...options, + conditions, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }) + } catch (e) { + if (e.details?.errorCode === "PathAlreadyExists") { + span.setStatus({ + code: CanonicalCode.ALREADY_EXISTS, + message: "Expected exception when creating a blob only if it does not already exist." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns true if the Data Lake file represented by this client exists; false otherwise. * @@ -316,6 +361,45 @@ export class DataLakePathClient extends StorageClient { } } + /** + * Delete current path (directory or file) if it exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete + * + * @param {boolean} [recursive] Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be deleted. + * @param {PathDeleteOptions} [options={}] + * @returns {Promise} Returns null if the directory or file doesn't exists. + * @memberof DataLakePathClient + */ + public async deleteIfExists( + recursive?: boolean, + options: PathDeleteOptions = {} + ): Promise { + options.conditions = options.conditions || {}; + const { span, spanOptions } = createSpan("DataLakePathClient-deleteIfExists", options.tracingOptions); + try { + return await this.delete(recursive, { + ...options, + tracingOptions: { ...options!.tracingOptions, spanOptions } + }); + } catch (e) { + if (e.details?.errorCode === "PathNotFound") { + span.setStatus({ + code: CanonicalCode.NOT_FOUND, + message: "Expected exception when deleting a directory or file only if it exists." + }); + return null; + } + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Returns the access control data for a path (directory of file). * @@ -710,6 +794,71 @@ export class DataLakeDirectoryClient extends DataLakePathClient { } } + /** + * Create a directory if it doesn't already exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {PathResourceType} resourceType Resource type, must be "directory" for DataLakeDirectoryClient. + * @param {PathCreateIfNotExistsOptions} [options] + * @returns {Promise} + * @memberof DataLakeDirectoryClient + */ + public async createIfNotExists( + resourceType: PathResourceType, + options?: PathCreateIfNotExistsOptions + ): Promise; + + /** + * Create a directory if it doesn't already exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {DirectoryCreateIfNotExistsOptions} [options] + * @returns {Promise} + * @memberof DataLakeDirectoryClient + */ + public async createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise; + + public async createIfNotExists( + resourceTypeOrOptions?: PathResourceType | PathCreateIfNotExistsOptions, + options: PathCreateIfNotExistsOptions = {} + ): Promise { + if (resourceTypeOrOptions === PathResourceType.Directory) { + // FIXME: why don't we pass in the new tracingOptions here? + return super.createIfNotExists(resourceTypeOrOptions as PathResourceType, options); + } + + if (resourceTypeOrOptions === PathResourceType.File) { + throw TypeError( + `DataLakeDirectoryClient:createIfNotExists() resourceType cannot be ${PathResourceType.File}. Refer to DataLakeFileClient for file creation.` + ); + } + + options = resourceTypeOrOptions || {}; + const { span, spanOptions } = createSpan( + "DataLakeDirectoryClient-createIfNotExists", + options.tracingOptions + ); + try { + return await super.createIfNotExists(PathResourceType.Directory, { + ...options, + tracingOptions: { + ...options.tracingOptions, + spanOptions + } + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Creates a {@link DataLakeDirectoryClient} object under current directory. * @@ -882,6 +1031,67 @@ export class DataLakeFileClient extends DataLakePathClient { } } + /** + * Create a file if it doesn't already exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {PathResourceType} resourceType Resource type, must be "file" for DataLakeFileClient. + * @param {PathCreateIfNotExistsOptions} [options] + * @returns {Promise} + * @memberof DataLakeFileClient + */ + public async createIfNotExists( + resourceType: PathResourceType, + options?: PathCreateIfNotExistsOptions + ): Promise; + + /** + * Create a file if it doesn't already exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {FileCreateIfNotExistsOptions} [options] Optional. Options when creating file. + * @returns {Promise} + * @memberof DataLakeFileClient + */ + public async createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise; + + public async createIfNotExists( + resourceTypeOrOptions?: PathResourceType | PathCreateOptions, + options: PathCreateIfNotExistsOptions = {} + ): Promise { + if (resourceTypeOrOptions === PathResourceType.File) { + return super.createIfNotExists(resourceTypeOrOptions as PathResourceType, options); + } + + if (resourceTypeOrOptions === PathResourceType.Directory) { + throw TypeError( + `DataLakeFileClient:createIfNotExists() resourceType cannot be ${PathResourceType.Directory}. Refer to DataLakeDirectoryClient for directory creation.` + ); + } + + options = resourceTypeOrOptions || {}; + const { span, spanOptions } = createSpan("DataLakeFileClient-createIfNotExists", options.tracingOptions); + try { + return await super.createIfNotExists(PathResourceType.File, { + ...options, + tracingOptions: { + ...options.tracingOptions, + spanOptions + } + }); + } catch (e) { + span.setStatus({ + code: CanonicalCode.UNKNOWN, + message: e.message + }); + throw e; + } finally { + span.end(); + } + } + /** * Downloads a file from the service, including its metadata and properties. * @@ -1228,7 +1438,7 @@ export class DataLakeFileClient extends DataLakePathClient { if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The data's size is too big or the chunkSize is too small;` + - `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } diff --git a/sdk/storage/storage-file-datalake/src/models.ts b/sdk/storage/storage-file-datalake/src/models.ts index a00b82ccadd7..ec6f621c2dd7 100644 --- a/sdk/storage/storage-file-datalake/src/models.ts +++ b/sdk/storage/storage-file-datalake/src/models.ts @@ -260,12 +260,12 @@ export interface SignedIdentifier { export type FileSystemGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & FileSystemGetAccessPolicyHeaders & { - _response: HttpResponse & { - parsedHeaders: FileSystemGetAccessPolicyHeaders; - bodyAsText: string; - parsedBody: SignedIdentifier[]; - }; + _response: HttpResponse & { + parsedHeaders: FileSystemGetAccessPolicyHeaders; + bodyAsText: string; + parsedBody: SignedIdentifier[]; }; +}; export interface FileSystemSetAccessPolicyOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -352,7 +352,7 @@ export interface Metadata { export interface DataLakeRequestConditions extends ModifiedAccessConditions, - LeaseAccessConditions {} + LeaseAccessConditions { } export interface RolePermissions { read: boolean; @@ -394,6 +394,14 @@ export interface PathCreateOptions extends CommonOptions { pathHttpHeaders?: PathCreateHttpHeaders; } +export interface PathCreateIfNotExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; + metadata?: Metadata; + permissions?: string; + umask?: string; + pathHttpHeaders?: PathCreateHttpHeaders; +} + export interface PathDeleteOptions extends CommonOptions { abortSignal?: AbortSignalLike; conditions?: DataLakeRequestConditions; @@ -591,9 +599,11 @@ export interface PathExistsOptions extends CommonOptions { /** DataLakeDirectoryClient option and response related models **/ /****************************************************************/ -export interface DirectoryCreateOptions extends PathCreateOptions {} +export interface DirectoryCreateOptions extends PathCreateOptions { } + +export interface DirectoryCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } -export interface DirectoryCreateResponse extends PathCreateResponse {} +export interface DirectoryCreateResponse extends PathCreateResponse { } /***********************************************************/ /** DataLakeFileClient option and response related models **/ @@ -665,9 +675,11 @@ export interface FileFlushOptions extends CommonOptions { pathHttpHeaders?: PathHttpHeaders; } -export interface FileCreateOptions extends PathCreateOptions {} +export interface FileCreateOptions extends PathCreateOptions { } + +export interface FileCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } -export interface FileCreateResponse extends PathCreateResponse {} +export interface FileCreateResponse extends PathCreateResponse { } /** * Option interface for Data Lake file - Upload operations diff --git a/sdk/storage/storage-file-datalake/src/utils/constants.ts b/sdk/storage/storage-file-datalake/src/utils/constants.ts index dcceca94a1b4..0a8f2982ef60 100644 --- a/sdk/storage/storage-file-datalake/src/utils/constants.ts +++ b/sdk/storage/storage-file-datalake/src/utils/constants.ts @@ -201,3 +201,5 @@ export const ToBlobEndpointHostMappings = [["dfs.core.windows.net", "blob.core.w // Mapping pairs to transform url from blob endpoint to dfs endpoint // Customize this value to add more mapping patterns export const ToDfsEndpointHostMappings = [["blob.core.windows.net", "dfs.core.windows.net"]]; + +export const ETagAny = "*"; diff --git a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts index ddb4b6b705ed..50af83c446d7 100644 --- a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts @@ -20,7 +20,7 @@ describe("DataLakeFileSystemClient", () => { let recorder: Recorder; let serviceClient: DataLakeServiceClient; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); serviceClient = getDataLakeServiceClient(); fileSystemName = recorder.getUniqueName("filesystem"); @@ -28,7 +28,7 @@ describe("DataLakeFileSystemClient", () => { await fileSystemClient.create(); }); - afterEach(async function() { + afterEach(async function () { await fileSystemClient.delete(); recorder.stop(); }); @@ -122,6 +122,27 @@ describe("DataLakeFileSystemClient", () => { assert.deepEqual(result.metadata, metadata); }); + it("createIfNotExists", async () => { + const cClient = serviceClient.getFileSystemClient(recorder.getUniqueName(fileSystemName)); + const metadata = { key: "value" }; + const access = "filesystem"; + const createRes = await cClient.createIfNotExists({ metadata, access }); + assert.notEqual(null, createRes); + + const createRes2 = await cClient.createIfNotExists({ metadata, access }); + assert.equal(null, createRes2); + + await cClient.delete(); + }); + + it("deleteIfExists", async () => { + const cClient = serviceClient.getFileSystemClient(recorder.getUniqueName(fileSystemName)); + assert.equal(null, await cClient.deleteIfExists()); + + await cClient.create(); + assert.notEqual(null, await cClient.deleteIfExists()); + }); + it("delete", (done) => { // delete() with default parameters has been tested in afterEach done(); diff --git a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts index 0fbc917c0b8f..d586cc1414da 100644 --- a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts @@ -20,7 +20,7 @@ describe("DataLakePathClient", () => { let recorder: any; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); const serviceClient = getDataLakeServiceClient(); fileSystemName = recorder.getUniqueName("filesystem"); @@ -33,7 +33,7 @@ describe("DataLakePathClient", () => { await fileClient.flush(content.length); }); - afterEach(async function() { + afterEach(async function () { await fileSystemClient.delete(); recorder.stop(); }); @@ -332,4 +332,24 @@ describe("DataLakePathClient", () => { const dirResult = await newDirectoryClient.exists(); assert.ok(dirResult === false, "exists() should return false for a non-existing directory"); }); + + it("DataLakeDirectoryClient-createIfNotExists", async () => { + const directoryName = recorder.getUniqueName("dir"); + const directoryClient = fileSystemClient.getDirectoryClient(directoryName); + assert.notEqual(null, await directoryClient.createIfNotExists()); + assert.equal(null, await directoryClient.createIfNotExists()); + }); + + it("DataLakeFileClient-createIfNotExists", async () => { + await fileClient.createIfNotExists(); + }); + + it("DataLakePathClient-deleteIfExists", async () => { + const directoryName = recorder.getUniqueName("dir"); + const directoryClient = fileSystemClient.getDirectoryClient(directoryName); + assert.equal(null, await directoryClient.deleteIfExists()); + + await directoryClient.create(); + assert.notEqual(null, await directoryClient.deleteIfExists()); + }); }); From eea3be7730cc41123a5fee0eb32bde7e5b8af38c Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 18 May 2020 13:59:44 +0800 Subject: [PATCH 07/12] record tests --- .../recording_createifnotexists.json | 87 ++++++++ .../blobclient/recording_deleteifexists.json | 90 ++++++++ .../recording_createifnotexists.json | 108 ++++++++++ .../recording_deleteifexists.json | 109 ++++++++++ .../recording_createifnotexists.json | 87 ++++++++ .../recording_createifnotexists.js | 89 ++++++++ .../blobclient/recording_deleteifexists.js | 93 +++++++++ .../recording_createifnotexists.js | 107 ++++++++++ .../recording_deleteifexists.js | 107 ++++++++++ .../recording_createifnotexists.js | 89 ++++++++ .../storage-blob/test/containerclient.spec.ts | 4 +- .../recording_createifnotexists.json | 108 ++++++++++ .../recording_deleteifexists.json | 108 ++++++++++ ...alakedirectoryclientcreateifnotexists.json | 153 ++++++++++++++ ...g_datalakefileclientcreateifnotexists.json | 132 ++++++++++++ ...ding_datalakepathclientdeleteifexists.json | 167 +++++++++++++++ .../recording_createifnotexists.js | 107 ++++++++++ .../recording_deleteifexists.js | 107 ++++++++++ ...atalakedirectoryclientcreateifnotexists.js | 155 ++++++++++++++ ...ing_datalakefileclientcreateifnotexists.js | 133 ++++++++++++ ...ording_datalakepathclientdeleteifexists.js | 171 ++++++++++++++++ .../test/filesystemclient.spec.ts | 4 +- .../test/pathclient.spec.ts | 4 +- .../recording_createifnotexists.json | 145 +++++++++++++ .../recording_deleteifexists.json | 145 +++++++++++++ .../directoryclient/recording_exists.json | 127 ++++++++++++ .../fileclient/recording_deleteifexists.json | 139 +++++++++++++ .../browsers/fileclient/recording_exists.json | 152 ++++++++++++++ .../recording_createifnotexists.json | 108 ++++++++++ .../shareclient/recording_deletifexists.json | 109 ++++++++++ .../shareclient/recording_exists.json | 93 +++++++++ .../recording_createifnotexists.js | 161 +++++++++++++++ .../recording_deleteifexists.js | 161 +++++++++++++++ .../node/directoryclient/recording_exists.js | 151 ++++++++++++++ .../fileclient/recording_deleteifexists.js | 158 ++++++++++++++ .../node/fileclient/recording_exists.js | 192 ++++++++++++++++++ .../recording_createifnotexists.js | 107 ++++++++++ .../shareclient/recording_deletifexists.js | 107 ++++++++++ .../node/shareclient/recording_exists.js | 103 ++++++++++ .../test/shareclient.spec.ts | 4 +- .../recording_createifnotexists.json | 85 ++++++++ .../queueclient/recording_deleteifexists.json | 104 ++++++++++ .../queueclient/recording_exists.json | 90 ++++++++ .../recording_createifnotexists.js | 81 ++++++++ .../queueclient/recording_deleteifexists.js | 99 +++++++++ .../node/queueclient/recording_exists.js | 93 +++++++++ .../storage-queue/review/storage-queue.api.md | 8 + 47 files changed, 5033 insertions(+), 8 deletions(-) create mode 100644 sdk/storage/storage-blob/recordings/browsers/appendblobclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-blob/recordings/browsers/containerclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-blob/recordings/browsers/containerclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-blob/recordings/browsers/pageblobclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-blob/recordings/node/appendblobclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-blob/recordings/node/containerclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-blob/recordings/node/containerclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-blob/recordings/node/pageblobclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.json create mode 100644 sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakefileclientcreateifnotexists.json create mode 100644 sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakepathclientdeleteifexists.json create mode 100644 sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.js create mode 100644 sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakefileclientcreateifnotexists.js create mode 100644 sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakepathclientdeleteifexists.js create mode 100644 sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_exists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_exists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json create mode 100644 sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_exists.json create mode 100644 sdk/storage/storage-file-share/recordings/node/directoryclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/directoryclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/directoryclient/recording_exists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/fileclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/fileclient/recording_exists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/shareclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js create mode 100644 sdk/storage/storage-file-share/recordings/node/shareclient/recording_exists.js create mode 100644 sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json create mode 100644 sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json create mode 100644 sdk/storage/storage-queue/recordings/browsers/queueclient/recording_exists.json create mode 100644 sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js create mode 100644 sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js create mode 100644 sdk/storage/storage-queue/recordings/node/queueclient/recording_exists.js diff --git a/sdk/storage/storage-blob/recordings/browsers/appendblobclient/recording_createifnotexists.json b/sdk/storage/storage-blob/recordings/browsers/appendblobclient/recording_createifnotexists.json new file mode 100644 index 000000000000..ee44d46262b4 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/browsers/appendblobclient/recording_createifnotexists.json @@ -0,0 +1,87 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219399200016", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:13 GMT", + "etag": "\"0x8D7FADACC557D8C\"", + "last-modified": "Mon, 18 May 2020 03:23:13 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "55cb7f47-55ad-402c-9783-7ccdfb46a8d4", + "x-ms-request-id": "d0a58ed4-e01e-0069-40c3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219399200016/blob158977219548204940", + "query": {}, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:13 GMT", + "etag": "\"0x8D7FADACCB1CC38\"", + "last-modified": "Mon, 18 May 2020 03:23:14 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "6aafb862-c55b-43b4-bbf4-875835fbc220", + "x-ms-request-id": "d0a590f8-e01e-0069-40c3-2c9b43000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219399200016/blob158977219548204940", + "query": {}, + "requestBody": null, + "status": 409, + "response": "BlobAlreadyExistsThe specified blob already exists.\nRequestId:d0a591db-e01e-0069-07c3-2c9b43000000\nTime:2020-05-18T03:23:14.3239981Z", + "responseHeaders": { + "content-length": "220", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 03:23:14 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "afa45086-11ad-43e2-b6cf-11e070fba3e0", + "x-ms-error-code": "BlobAlreadyExists", + "x-ms-request-id": "d0a591db-e01e-0069-07c3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219399200016", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:14 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "3244ac67-6d9f-44be-931a-3d5a97b600c7", + "x-ms-request-id": "d0a5938c-e01e-0069-02c3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "container": "container158977219399200016", + "blob": "blob158977219548204940" + }, + "newDate": {} + }, + "hash": "e6efd2486db5d337378f976ca1aec73d" +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json new file mode 100644 index 000000000000..7885e8b9e7f0 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json @@ -0,0 +1,90 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:15 GMT", + "etag": "\"0x8D7FADACD990B4A\"", + "last-modified": "Mon, 18 May 2020 03:23:15 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "5b694a9d-8a14-4dca-a8f7-89779d004726", + "x-ms-request-id": "d0a59518-e01e-0069-75c3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469/blob158977219758900546", + "query": {}, + "requestBody": "Hello World", + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "content-md5": "sQqNsWTgdUEFt6mb5y4/5Q==", + "date": "Mon, 18 May 2020 03:23:15 GMT", + "etag": "\"0x8D7FADACDF38472\"", + "last-modified": "Mon, 18 May 2020 03:23:16 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "55f89ad9-c109-4872-8ff6-d786bf88dbe1", + "x-ms-content-crc64": "YeJLfssylmU=", + "x-ms-request-id": "d0a5970f-e01e-0069-44c3-2c9b43000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469/blob2158977219818309279", + "query": {}, + "requestBody": null, + "status": 404, + "response": "BlobNotFoundThe specified blob does not exist.\nRequestId:d0a598fa-e01e-0069-12c3-2c9b43000000\nTime:2020-05-18T03:23:16.7166246Z", + "responseHeaders": { + "content-length": "215", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 03:23:16 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4f11cc72-e3ea-491b-bf39-a198f143ccff", + "x-ms-error-code": "BlobNotFound", + "x-ms-request-id": "d0a598fa-e01e-0069-12c3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:17 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a39a5a01-0d77-47a1-a633-d08252101853", + "x-ms-request-id": "d0a59a7e-e01e-0069-6bc3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "container": "container158977219699803469", + "blob": "blob158977219758900546", + "blob2": "blob2158977219818309279" + }, + "newDate": {} + }, + "hash": "f2c5329b54568da32738b0633d76fd28" +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_createifnotexists.json b/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_createifnotexists.json new file mode 100644 index 000000000000..f9d5e76cded0 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_createifnotexists.json @@ -0,0 +1,108 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977898953304407", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:28 GMT", + "etag": "\"0x8D7FAEA9ED18633\"", + "last-modified": "Mon, 18 May 2020 05:16:29 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a706b535-f439-4b10-9f4f-fc96535e9610", + "x-ms-request-id": "315c5623-301e-0045-09d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977898953304407", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 409, + "response": "ContainerAlreadyExistsThe specified container already exists.\nRequestId:315c56be-301e-0045-11d3-2c77ec000000\nTime:2020-05-18T05:16:29.3239574Z", + "responseHeaders": { + "content-length": "230", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:16:29 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "0de123b2-34c3-4720-9a7c-74ac181526c6", + "x-ms-error-code": "ContainerAlreadyExists", + "x-ms-request-id": "315c56be-301e-0045-11d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container2158977899137404377", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:29 GMT", + "etag": "\"0x8D7FAEA9F5D8BF8\"", + "last-modified": "Mon, 18 May 2020 05:16:29 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "595f2b25-40b5-472e-b245-7574856ecb12", + "x-ms-request-id": "315c57a9-301e-0045-63d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container2158977899137404377", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:30 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "c3e3bd3a-c92a-4a7c-bc62-969cd7f61f6c", + "x-ms-request-id": "315c58ca-301e-0045-64d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977898953304407", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:30 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "14a99ed8-8cef-45c4-b66a-d39c3be248b2", + "x-ms-request-id": "315c5993-301e-0045-21d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "container": "container158977898953304407", + "container2": "container2158977899137404377" + }, + "newDate": {} + }, + "hash": "d9c7dc1b415f156c20d632e9cdd9c598" +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_deleteifexists.json b/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_deleteifexists.json new file mode 100644 index 000000000000..50c47c6caee5 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/browsers/containerclient/recording_deleteifexists.json @@ -0,0 +1,109 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977899316704540", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:31 GMT", + "etag": "\"0x8D7FAEAA06FA2BF\"", + "last-modified": "Mon, 18 May 2020 05:16:31 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "81e9dcd5-18b0-481a-a0cb-1c07caeb915d", + "x-ms-request-id": "315c5a4b-301e-0045-49d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container2158977899375807936", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:32 GMT", + "etag": "\"0x8D7FAEAA0CA2F44\"", + "last-modified": "Mon, 18 May 2020 05:16:32 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "636b04c7-a232-4bc9-87ec-8e9fc163c257", + "x-ms-request-id": "315c5b82-301e-0045-64d3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container2158977899375807936", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:32 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "945a5bf4-20b4-4b02-a49f-98f2215b45ac", + "x-ms-request-id": "315c5c96-301e-0045-5ed3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container3158977899499501634", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 404, + "response": "ContainerNotFoundThe specified container does not exist.\nRequestId:315c5d93-301e-0045-4ed3-2c77ec000000\nTime:2020-05-18T05:16:33.5409468Z", + "responseHeaders": { + "content-length": "225", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:16:33 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "00780ca7-79db-4c13-8ae0-057d5c604892", + "x-ms-error-code": "ContainerNotFound", + "x-ms-request-id": "315c5d93-301e-0045-4ed3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977899316704540", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:16:33 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "0bab51cb-5375-4e4d-8156-269aac8cc241", + "x-ms-request-id": "315c5e90-301e-0045-3dd3-2c77ec000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "container": "container158977899316704540", + "container2": "container2158977899375807936", + "container3": "container3158977899499501634" + }, + "newDate": {} + }, + "hash": "7fe5c2ec7e849c7c67cd500d20d7936f" +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/browsers/pageblobclient/recording_createifnotexists.json b/sdk/storage/storage-blob/recordings/browsers/pageblobclient/recording_createifnotexists.json new file mode 100644 index 000000000000..ca1e49cb5f29 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/browsers/pageblobclient/recording_createifnotexists.json @@ -0,0 +1,87 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977220378104726", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:22 GMT", + "etag": "\"0x8D7FADAD1A29D4B\"", + "last-modified": "Mon, 18 May 2020 03:23:22 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "0302bcdd-b732-4e4f-ba46-8f9ecece2041", + "x-ms-request-id": "d0a5ab5d-e01e-0069-5ac3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977220378104726/blob158977220436307580", + "query": {}, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:22 GMT", + "etag": "\"0x8D7FADAD1FC51B6\"", + "last-modified": "Mon, 18 May 2020 03:23:22 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7a1d4ac4-d5a7-48cd-aed5-e3978ab9b46f", + "x-ms-request-id": "d0a5ad4f-e01e-0069-76c3-2c9b43000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977220378104726/blob158977220436307580", + "query": {}, + "requestBody": null, + "status": 409, + "response": "BlobAlreadyExistsThe specified blob already exists.\nRequestId:d0a5ae8f-e01e-0069-0ac3-2c9b43000000\nTime:2020-05-18T03:23:23.1980329Z", + "responseHeaders": { + "content-length": "220", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 03:23:23 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a8ba571b-bc7e-4fb3-ad2f-f51bd8172d16", + "x-ms-error-code": "BlobAlreadyExists", + "x-ms-request-id": "d0a5ae8f-e01e-0069-0ac3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container158977220378104726", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 03:23:23 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "371dd386-28eb-49da-adc8-0243fab17ed2", + "x-ms-request-id": "d0a5b0ce-e01e-0069-1bc3-2c9b43000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "container": "container158977220378104726", + "blob": "blob158977220436307580" + }, + "newDate": {} + }, + "hash": "ca54c170e36521285331b748fac5742d" +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/node/appendblobclient/recording_createifnotexists.js b/sdk/storage/storage-blob/recordings/node/appendblobclient/recording_createifnotexists.js new file mode 100644 index 000000000000..fe60dbc7a632 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/node/appendblobclient/recording_createifnotexists.js @@ -0,0 +1,89 @@ +let nock = require('nock'); + +module.exports.hash = "182afcbcd051964f01dd6aa10ef0860b"; + +module.exports.testInfo = {"uniqueName":{"container":"container158977214749307469","blob":"blob158977214884105113"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977214749307469') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:26 GMT', + 'ETag', + '"0x8D7FADAB0876854"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed205b1-701e-006b-26c3-2c25fb000000', + 'x-ms-client-request-id', + '0d50f179-961f-49ca-b81f-df1963fa169b', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:26 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977214749307469/blob158977214884105113') + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:27 GMT', + 'ETag', + '"0x8D7FADAB0B95B93"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed20642-701e-006b-2bc3-2c25fb000000', + 'x-ms-client-request-id', + 'c1ef56ec-7bc1-42e2-b234-2e69e3acd3e5', + 'x-ms-version', + '2019-07-07', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 03:22:26 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977214749307469/blob158977214884105113') + .reply(409, "BlobAlreadyExistsThe specified blob already exists.\nRequestId:eed206d9-701e-006b-39c3-2c25fb000000\nTime:2020-05-18T03:22:27.3887334Z", [ + 'Content-Length', + '220', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed206d9-701e-006b-39c3-2c25fb000000', + 'x-ms-client-request-id', + 'f8e303d9-7164-4e8e-81b0-b9f76badc938', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'BlobAlreadyExists', + 'Date', + 'Mon, 18 May 2020 03:22:26 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977214749307469') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed2074d-701e-006b-24c3-2c25fb000000', + 'x-ms-client-request-id', + '8dc0e559-e40c-49d7-a639-0dd9db5ec42c', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:27 GMT' +]); diff --git a/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js b/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js new file mode 100644 index 000000000000..f35d0f933b83 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js @@ -0,0 +1,93 @@ +let nock = require('nock'); + +module.exports.hash = "72625ad7134389678fb0c0df03b89186"; + +module.exports.testInfo = {"uniqueName":{"container":"container158977214975808781","blob":"blob158977215005109674","blob2":"blob2158977215035103936"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977214975808781') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:27 GMT', + 'ETag', + '"0x8D7FADAB14310B4"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed207ca-701e-006b-16c3-2c25fb000000', + 'x-ms-client-request-id', + '432f8326-c155-46ae-8465-1d9d2e08f009', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:27 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977214975808781/blob158977215005109674', "Hello World") + .reply(201, "", [ + 'Content-Length', + '0', + 'Content-MD5', + 'sQqNsWTgdUEFt6mb5y4/5Q==', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:28 GMT', + 'ETag', + '"0x8D7FADAB170E45C"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed20857-701e-006b-16c3-2c25fb000000', + 'x-ms-client-request-id', + '093d954c-ac27-4498-898d-77f740b3f2e6', + 'x-ms-version', + '2019-07-07', + 'x-ms-content-crc64', + 'YeJLfssylmU=', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 03:22:27 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977214975808781/blob2158977215035103936') + .reply(404, "BlobNotFoundThe specified blob does not exist.\nRequestId:eed208dc-701e-006b-15c3-2c25fb000000\nTime:2020-05-18T03:22:28.5945493Z", [ + 'Content-Length', + '215', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed208dc-701e-006b-15c3-2c25fb000000', + 'x-ms-client-request-id', + '1c2262a3-b05c-4279-881a-9f4f7b075a17', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'BlobNotFound', + 'Date', + 'Mon, 18 May 2020 03:22:28 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977214975808781') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed2096e-701e-006b-19c3-2c25fb000000', + 'x-ms-client-request-id', + '873cbaea-1e8c-4db3-89e6-d299d06c83e3', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:28 GMT' +]); diff --git a/sdk/storage/storage-blob/recordings/node/containerclient/recording_createifnotexists.js b/sdk/storage/storage-blob/recordings/node/containerclient/recording_createifnotexists.js new file mode 100644 index 000000000000..2524cdd62ec4 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/node/containerclient/recording_createifnotexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "8f96742aa7f5f2c3fbf2ae2881ac6ebc"; + +module.exports.testInfo = {"uniqueName":{"container":"container158977895191804446","container2":"container2158977895359500682"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977895191804446') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:15:51 GMT', + 'ETag', + '"0x8D7FAEA884EF299"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '809198b4-101e-0052-37d3-2cdee7000000', + 'x-ms-client-request-id', + 'a0621908-73be-4777-8916-8053776f29ed', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:51 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977895191804446') + .query(true) + .reply(409, "ContainerAlreadyExistsThe specified container already exists.\nRequestId:8091998e-101e-0052-7cd3-2cdee7000000\nTime:2020-05-18T05:15:51.5483295Z", [ + 'Content-Length', + '230', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '8091998e-101e-0052-7cd3-2cdee7000000', + 'x-ms-client-request-id', + 'e684fde9-78bf-4850-a7f2-6bdd3d7b44b5', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ContainerAlreadyExists', + 'Date', + 'Mon, 18 May 2020 05:15:51 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container2158977895359500682') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:15:51 GMT', + 'ETag', + '"0x8D7FAEA88AD506A"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919a5f-101e-0052-3bd3-2cdee7000000', + 'x-ms-client-request-id', + '6acd8757-a34e-47c9-ac2e-cac79ed3a581', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:51 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container2158977895359500682') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919b5a-101e-0052-1fd3-2cdee7000000', + 'x-ms-client-request-id', + 'c809a7d3-468e-4b85-8420-f27265beb7a1', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:52 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977895191804446') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919c1f-101e-0052-44d3-2cdee7000000', + 'x-ms-client-request-id', + '7a566973-d4dc-4802-87f5-e8d7fe6511d1', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:52 GMT' +]); diff --git a/sdk/storage/storage-blob/recordings/node/containerclient/recording_deleteifexists.js b/sdk/storage/storage-blob/recordings/node/containerclient/recording_deleteifexists.js new file mode 100644 index 000000000000..d3e2498bda73 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/node/containerclient/recording_deleteifexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "b0e0629f46595c8ad0ac3aa52f63d434"; + +module.exports.testInfo = {"uniqueName":{"container":"container158977895451106039","container2":"container2158977895481308612","container3":"container3158977895541909286"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977895451106039') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:15:52 GMT', + 'ETag', + '"0x8D7FAEA893907F1"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919cf0-101e-0052-6cd3-2cdee7000000', + 'x-ms-client-request-id', + '9cce3650-a136-4f46-91d6-c41ed703acb5', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:52 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container2158977895481308612') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:15:53 GMT', + 'ETag', + '"0x8D7FAEA8967734C"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919daf-101e-0052-03d3-2cdee7000000', + 'x-ms-client-request-id', + '4f37487f-1488-47d4-8eaa-435c93fe22a9', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:53 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container2158977895481308612') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919e6f-101e-0052-1bd3-2cdee7000000', + 'x-ms-client-request-id', + 'b4d54db2-0264-4f17-afc1-1e733eca8987', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:53 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container3158977895541909286') + .query(true) + .reply(404, "ContainerNotFoundThe specified container does not exist.\nRequestId:80919f4e-101e-0052-57d3-2cdee7000000\nTime:2020-05-18T05:15:53.6808389Z", [ + 'Content-Length', + '225', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '80919f4e-101e-0052-57d3-2cdee7000000', + 'x-ms-client-request-id', + '5d8eaac9-b24b-43d3-8380-73d9c7d06711', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ContainerNotFound', + 'Date', + 'Mon, 18 May 2020 05:15:53 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977895451106039') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '8091a048-101e-0052-37d3-2cdee7000000', + 'x-ms-client-request-id', + '2f6a7c3c-2a7a-486a-b204-e54d8addfbe8', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:15:53 GMT' +]); diff --git a/sdk/storage/storage-blob/recordings/node/pageblobclient/recording_createifnotexists.js b/sdk/storage/storage-blob/recordings/node/pageblobclient/recording_createifnotexists.js new file mode 100644 index 000000000000..a99aa73e0ee0 --- /dev/null +++ b/sdk/storage/storage-blob/recordings/node/pageblobclient/recording_createifnotexists.js @@ -0,0 +1,89 @@ +let nock = require('nock'); + +module.exports.hash = "fbf6feac48348943de323529a76f3f2f"; + +module.exports.testInfo = {"uniqueName":{"container":"container158977215391405044","blob":"blob158977215420602835"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977215391405044') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:32 GMT', + 'ETag', + '"0x8D7FADAB3BD57B0"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed2111d-701e-006b-28c3-2c25fb000000', + 'x-ms-client-request-id', + '265a89bd-236b-42ee-8cb0-a0a7512ee5d3', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:31 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977215391405044/blob158977215420602835') + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 03:22:32 GMT', + 'ETag', + '"0x8D7FADAB3EA4124"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed211a2-701e-006b-20c3-2c25fb000000', + 'x-ms-client-request-id', + '5b7bd94e-7988-4280-8b38-f57bfd3c6b42', + 'x-ms-version', + '2019-07-07', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 03:22:31 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/container158977215391405044/blob158977215420602835') + .reply(409, "BlobAlreadyExistsThe specified blob already exists.\nRequestId:eed21257-701e-006b-46c3-2c25fb000000\nTime:2020-05-18T03:22:32.7423460Z", [ + 'Content-Length', + '220', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed21257-701e-006b-46c3-2c25fb000000', + 'x-ms-client-request-id', + '2b1114b5-0a8a-46e1-bbe6-8d408935ea0d', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'BlobAlreadyExists', + 'Date', + 'Mon, 18 May 2020 03:22:32 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container158977215391405044') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'eed21374-701e-006b-55c3-2c25fb000000', + 'x-ms-client-request-id', + '6471de5c-8a27-4cdd-9aec-023a1fe5322e', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 03:22:32 GMT' +]); diff --git a/sdk/storage/storage-blob/test/containerclient.spec.ts b/sdk/storage/storage-blob/test/containerclient.spec.ts index 572c219d87ca..107a7c7ac8b1 100644 --- a/sdk/storage/storage-blob/test/containerclient.spec.ts +++ b/sdk/storage/storage-blob/test/containerclient.spec.ts @@ -72,7 +72,7 @@ describe("ContainerClient", () => { const containerName2 = recorder.getUniqueName("container2"); const containerClient2 = blobServiceClient.getContainerClient(containerName2); const createRes = await containerClient2.createIfNotExists(); - assert.notEqual(createRes, null); + assert.notDeepStrictEqual(createRes, null); await containerClient2.delete(); }); @@ -81,7 +81,7 @@ describe("ContainerClient", () => { const containerClient2 = blobServiceClient.getContainerClient(containerName2); await containerClient2.create(); const res = await containerClient2.deleteIfExists(); - assert.notEqual(null, res); + assert.notDeepStrictEqual(null, res); const containerName3 = recorder.getUniqueName("container3"); const containerClient3 = blobServiceClient.getContainerClient(containerName3); diff --git a/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_createifnotexists.json b/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_createifnotexists.json new file mode 100644 index 000000000000..2e11b02947e3 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_createifnotexists.json @@ -0,0 +1,108 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978056950202862", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:48 GMT", + "etag": "\"0x8D7FAEE4C936B54\"", + "last-modified": "Mon, 18 May 2020 05:42:49 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b9ca1b09-f5c4-4aef-aa3b-673e9bc3c0df", + "x-ms-request-id": "15dabaa9-001e-00a5-54d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978056950202862158978057106306412", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:49 GMT", + "etag": "\"0x8D7FAEE4CEFF6E1\"", + "last-modified": "Mon, 18 May 2020 05:42:49 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "40b1f17b-f279-42a8-800c-82d2005fde14", + "x-ms-request-id": "15dabb85-001e-00a5-24d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978056950202862158978057106306412", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 409, + "response": "ContainerAlreadyExistsThe specified container already exists.\nRequestId:15dabbe7-001e-00a5-76d7-2c7e87000000\nTime:2020-05-18T05:42:49.9282287Z", + "responseHeaders": { + "content-length": "230", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:42:49 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "6d810382-9f01-4528-9ac2-6bc312c6c5a8", + "x-ms-error-code": "ContainerAlreadyExists", + "x-ms-request-id": "15dabbe7-001e-00a5-76d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978056950202862158978057106306412", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:50 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4a80f9c4-54ec-4368-abb3-e6a744bcb837", + "x-ms-request-id": "15dabca0-001e-00a5-1ed7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978056950202862", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:50 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "f3b831a8-dfff-43df-8f01-c5d87da43cc9", + "x-ms-request-id": "15dabd8d-001e-00a5-67d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "filesystem": "filesystem158978056950202862", + "filesystem158978056950202862": "filesystem158978056950202862158978057106306412" + }, + "newDate": {} + }, + "hash": "d2c1dddb7afb8e7cda0f3df363449343" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_deleteifexists.json b/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_deleteifexists.json new file mode 100644 index 000000000000..c3294e4332db --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/browsers/datalakefilesystemclient/recording_deleteifexists.json @@ -0,0 +1,108 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057319505927", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:51 GMT", + "etag": "\"0x8D7FAEE4E33DF4C\"", + "last-modified": "Mon, 18 May 2020 05:42:51 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "9ee1136d-2c18-430f-82e5-6a25e95786ae", + "x-ms-request-id": "15dabe91-001e-00a5-6bd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057319505927158978057377701071", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 404, + "response": "ContainerNotFoundThe specified container does not exist.\nRequestId:15dac006-001e-00a5-1dd7-2c7e87000000\nTime:2020-05-18T05:42:52.3242191Z", + "responseHeaders": { + "content-length": "225", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:42:52 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b16ad610-63c2-443f-a5eb-e230e032bb0d", + "x-ms-error-code": "ContainerNotFound", + "x-ms-request-id": "15dac006-001e-00a5-1dd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057319505927158978057377701071", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:52 GMT", + "etag": "\"0x8D7FAEE4EE33057\"", + "last-modified": "Mon, 18 May 2020 05:42:52 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fd36e9a3-be56-424f-a92e-25ff040219ee", + "x-ms-request-id": "15dac126-001e-00a5-1ed7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057319505927158978057377701071", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:53 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "835b0d77-99fd-4e6f-955c-bdd8e10be154", + "x-ms-request-id": "15dac265-001e-00a5-74d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057319505927", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:53 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "92a91c39-3fa1-4d4b-bc19-d6b99dfae527", + "x-ms-request-id": "15dac357-001e-00a5-4fd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "filesystem": "filesystem158978057319505927", + "filesystem158978057319505927": "filesystem158978057319505927158978057377701071" + }, + "newDate": {} + }, + "hash": "fbb56cb4c4e266e407f6137fade18987" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.json b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.json new file mode 100644 index 000000000000..ce2fe7ad7593 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.json @@ -0,0 +1,153 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057610606087", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:54 GMT", + "etag": "\"0x8D7FAEE4FEFF779\"", + "last-modified": "Mon, 18 May 2020 05:42:54 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4cc8f9c4-aa0a-4d4e-8645-1b293df8347e", + "x-ms-request-id": "15dac458-001e-00a5-2cd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978057610606087/file158978057668701341", + "query": { + "resource": "file" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:55 GMT", + "etag": "\"0x8D7FAEE50E59DD8\"", + "last-modified": "Mon, 18 May 2020 05:42:56 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "29d57229-0f87-4e6a-b26c-08dc4aa61287", + "x-ms-request-id": "bdcbc679-101f-005f-01d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978057610606087/file158978057668701341", + "query": { + "position": "0", + "action": "append" + }, + "requestBody": "Hello World", + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:56 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fbae98a8-ccc4-4805-89d5-250799a1031d", + "x-ms-request-id": "bdcbc6a5-101f-005f-2dd7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978057610606087/file158978057668701341", + "query": { + "position": "11", + "action": "flush" + }, + "requestBody": "", + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:56 GMT", + "etag": "\"0x8D7FAEE519600BB\"", + "last-modified": "Mon, 18 May 2020 05:42:57 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "992185fd-5d73-4e00-9ff3-abf6795e8fa8", + "x-ms-request-id": "bdcbc6cd-101f-005f-55d7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978057610606087/dir158978057944601135", + "query": { + "resource": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:57 GMT", + "etag": "\"0x8D7FAEE51EDEF7C\"", + "last-modified": "Mon, 18 May 2020 05:42:57 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4ca7fa54-1b2e-4387-b0d8-ef39737019ec", + "x-ms-request-id": "bdcbc6f1-101f-005f-79d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978057610606087/dir158978057944601135", + "query": { + "resource": "directory" + }, + "requestBody": null, + "status": 409, + "response": "{\"error\":{\"code\":\"PathAlreadyExists\",\"message\":\"The specified path already exists.\\nRequestId:bdcbc702-101f-005f-0ad7-2cb760000000\\nTime:2020-05-18T05:42:58.2793770Z\"}}", + "responseHeaders": { + "content-length": "168", + "content-type": "application/json;charset=utf-8", + "date": "Mon, 18 May 2020 05:42:57 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "e9688972-709e-4d09-9fbb-7243827bf36d", + "x-ms-error-code": "PathAlreadyExists", + "x-ms-request-id": "bdcbc702-101f-005f-0ad7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978057610606087", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:58 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "89c67459-4247-436a-a306-05cec273a122", + "x-ms-request-id": "15dacb75-001e-00a5-0dd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "filesystem": "filesystem158978057610606087", + "file": "file158978057668701341", + "dir": "dir158978057944601135" + }, + "newDate": {} + }, + "hash": "334989a3215fedac66110333330bc920" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakefileclientcreateifnotexists.json b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakefileclientcreateifnotexists.json new file mode 100644 index 000000000000..81a25715c3e3 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakefileclientcreateifnotexists.json @@ -0,0 +1,132 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978058090909990", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:59 GMT", + "etag": "\"0x8D7FAEE52CCFF55\"", + "last-modified": "Mon, 18 May 2020 05:42:59 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "f2b928a0-2f16-4c9f-bac7-6bf32f0b47bf", + "x-ms-request-id": "15dacc48-001e-00a5-47d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058090909990/file158978058149204991", + "query": { + "resource": "file" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:59 GMT", + "etag": "\"0x8D7FAEE532B89BB\"", + "last-modified": "Mon, 18 May 2020 05:43:00 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "da84be6d-3585-4fa0-bad0-3f43064e3525", + "x-ms-request-id": "bdcbc765-101f-005f-6cd7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058090909990/file158978058149204991", + "query": { + "position": "0", + "action": "append" + }, + "requestBody": "Hello World", + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:42:59 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "61c134c2-a100-4c76-abb5-52c5d781eb86", + "x-ms-request-id": "bdcbc788-101f-005f-0fd7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058090909990/file158978058149204991", + "query": { + "position": "11", + "action": "flush" + }, + "requestBody": "", + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:00 GMT", + "etag": "\"0x8D7FAEE53DBF591\"", + "last-modified": "Mon, 18 May 2020 05:43:01 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4e5f1fa7-cc81-4229-9384-6c6b3034309b", + "x-ms-request-id": "bdcbc7ac-101f-005f-32d7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058090909990/file158978058149204991", + "query": { + "resource": "file" + }, + "requestBody": null, + "status": 409, + "response": "{\"error\":{\"code\":\"PathAlreadyExists\",\"message\":\"The specified path already exists.\\nRequestId:bdcbc7cd-101f-005f-53d7-2cb760000000\\nTime:2020-05-18T05:43:01.8033083Z\"}}", + "responseHeaders": { + "content-length": "168", + "content-type": "application/json;charset=utf-8", + "date": "Mon, 18 May 2020 05:43:01 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "41ed0375-b693-458c-90d3-024b5b3b87a1", + "x-ms-error-code": "PathAlreadyExists", + "x-ms-request-id": "bdcbc7cd-101f-005f-53d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978058090909990", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:02 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "31ed2f6b-8d84-4f06-b092-df630075b49e", + "x-ms-request-id": "15dad038-001e-00a5-4fd7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "filesystem": "filesystem158978058090909990", + "file": "file158978058149204991" + }, + "newDate": {} + }, + "hash": "f7176b5fa4ce66198ec0eed42335ec53" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakepathclientdeleteifexists.json b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakepathclientdeleteifexists.json new file mode 100644 index 000000000000..0c659dd6d461 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/browsers/datalakepathclient/recording_datalakepathclientdeleteifexists.json @@ -0,0 +1,167 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978058443504810", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:02 GMT", + "etag": "\"0x8D7FAEE54E7511A\"", + "last-modified": "Mon, 18 May 2020 05:43:02 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "dff23c05-a5ec-4373-90ee-30e207a5e3ff", + "x-ms-request-id": "15dad0e5-001e-00a5-70d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/file158978058502300502", + "query": { + "resource": "file" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:02 GMT", + "etag": "\"0x8D7FAEE554309AF\"", + "last-modified": "Mon, 18 May 2020 05:43:03 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "203b47a0-8987-4a74-b5f3-7a83236a3a4f", + "x-ms-request-id": "bdcbc82a-101f-005f-30d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/file158978058502300502", + "query": { + "position": "0", + "action": "append" + }, + "requestBody": "Hello World", + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:03 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "8244c175-e24c-480e-babc-7213c46ce574", + "x-ms-request-id": "bdcbc83d-101f-005f-42d7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PATCH", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/file158978058502300502", + "query": { + "position": "11", + "action": "flush" + }, + "requestBody": "", + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:04 GMT", + "etag": "\"0x8D7FAEE55F4D69E\"", + "last-modified": "Mon, 18 May 2020 05:43:04 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "1549c622-bf11-4591-adef-30f6b379e336", + "x-ms-request-id": "bdcbc843-101f-005f-48d7-2cb760000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/dir158978058677805985", + "query": {}, + "requestBody": null, + "status": 404, + "response": "{\"error\":{\"code\":\"PathNotFound\",\"message\":\"The specified path does not exist.\\nRequestId:bdcbc849-101f-005f-4ed7-2cb760000000\\nTime:2020-05-18T05:43:05.3252343Z\"}}", + "responseHeaders": { + "content-length": "163", + "content-type": "application/json;charset=utf-8", + "date": "Mon, 18 May 2020 05:43:04 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "6161d563-bed7-4640-bc99-354f2619cfe1", + "x-ms-error-code": "PathNotFound", + "x-ms-request-id": "bdcbc849-101f-005f-4ed7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/dir158978058677805985", + "query": { + "resource": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:05 GMT", + "etag": "\"0x8D7FAEE56A451B4\"", + "last-modified": "Mon, 18 May 2020 05:43:05 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4953c250-19ee-4956-98ab-ed4c0325a14a", + "x-ms-request-id": "bdcbc84b-101f-005f-50d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.dfs.core.windows.net/filesystem158978058443504810/dir158978058677805985", + "query": {}, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:05 GMT", + "server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fb996841-b205-4a4c-8d8d-49cb304aea74", + "x-ms-request-id": "bdcbc84c-101f-005f-51d7-2cb760000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/filesystem158978058443504810", + "query": { + "restype": "container" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:43:06 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "e1f124b9-d414-403d-959d-34422f6fd935", + "x-ms-request-id": "15dad5b7-001e-00a5-52d7-2c7e87000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "filesystem": "filesystem158978058443504810", + "file": "file158978058502300502", + "dir": "dir158978058677805985" + }, + "newDate": {} + }, + "hash": "e6fccfcc91f368ed4b5bddba0212ceb0" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_createifnotexists.js b/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_createifnotexists.js new file mode 100644 index 000000000000..69c2b8cc70f6 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_createifnotexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "20dbc14eb779c9620f4adbba78aa35ca"; + +module.exports.testInfo = {"uniqueName":{"filesystem":"filesystem158977960418708486","filesystem158977960418708486":"filesystem158977960418708486158977960748306575"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977960418708486') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:45 GMT', + 'ETag', + '"0x8D7FAEC0E0BABF5"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bd6f8-a01e-002b-2dd4-2c3126000000', + 'x-ms-client-request-id', + '35e3dc14-51eb-48df-9027-262f222639a4', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:44 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977960418708486158977960748306575') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:45 GMT', + 'ETag', + '"0x8D7FAEC0E6EC870"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bd83c-a01e-002b-56d4-2c3126000000', + 'x-ms-client-request-id', + 'c0647c84-ab76-40ab-83af-7d601e52a85f', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:45 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977960418708486158977960748306575') + .query(true) + .reply(409, "ContainerAlreadyExistsThe specified container already exists.\nRequestId:dc4bd8f2-a01e-002b-7cd4-2c3126000000\nTime:2020-05-18T05:26:46.1284743Z", [ + 'Content-Length', + '230', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bd8f2-a01e-002b-7cd4-2c3126000000', + 'x-ms-client-request-id', + 'ee8432a2-2585-473d-aaa0-ee45e4902544', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ContainerAlreadyExists', + 'Date', + 'Mon, 18 May 2020 05:26:45 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977960418708486158977960748306575') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bd9a9-a01e-002b-1fd4-2c3126000000', + 'x-ms-client-request-id', + '9940ef89-f0f5-4695-a1e3-e52f2fd40fd3', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:46 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977960418708486') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdaa1-a01e-002b-08d4-2c3126000000', + 'x-ms-client-request-id', + 'bab87cc5-fa72-416d-92dc-6e7ace950c85', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:46 GMT' +]); diff --git a/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_deleteifexists.js b/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_deleteifexists.js new file mode 100644 index 000000000000..f38856042504 --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/node/datalakefilesystemclient/recording_deleteifexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "89c02adcefa8cfbd0c30ffd7ecf1b9bd"; + +module.exports.testInfo = {"uniqueName":{"filesystem":"filesystem158977960906408084","filesystem158977960906408084":"filesystem158977960906408084158977960937306987"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977960906408084') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:47 GMT', + 'ETag', + '"0x8D7FAEC0F5CDD31"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdb84-a01e-002b-60d4-2c3126000000', + 'x-ms-client-request-id', + '4ff67a02-50ad-47e1-8130-cf405eb5ed88', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:46 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977960906408084158977960937306987') + .query(true) + .reply(404, "ContainerNotFoundThe specified container does not exist.\nRequestId:dc4bdc35-a01e-002b-02d4-2c3126000000\nTime:2020-05-18T05:26:47.6287116Z", [ + 'Content-Length', + '225', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdc35-a01e-002b-02d4-2c3126000000', + 'x-ms-client-request-id', + '6efbbfbb-6911-4ee1-877e-5b5e9b0671f9', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ContainerNotFound', + 'Date', + 'Mon, 18 May 2020 05:26:47 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977960906408084158977960937306987') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:47 GMT', + 'ETag', + '"0x8D7FAEC0FB82FD2"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdcbd-a01e-002b-7cd4-2c3126000000', + 'x-ms-client-request-id', + '885c5736-4127-4782-964c-5afc78f653bb', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:47 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977960906408084158977960937306987') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdd75-a01e-002b-24d4-2c3126000000', + 'x-ms-client-request-id', + '6dbd449c-804c-4518-99b6-05554e219398', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:47 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977960906408084') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bde30-a01e-002b-4bd4-2c3126000000', + 'x-ms-client-request-id', + 'f1043536-e432-4db0-ab4b-8eceb05c3375', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:48 GMT' +]); diff --git a/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.js b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.js new file mode 100644 index 000000000000..eaa18644ca4b --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakedirectoryclientcreateifnotexists.js @@ -0,0 +1,155 @@ +let nock = require('nock'); + +module.exports.hash = "720d743ded24f582eadd4ae8659a2dac"; + +module.exports.testInfo = {"uniqueName":{"filesystem":"filesystem158977961057503329","file":"file158977961087608276","dir":"dir158977961287500504"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961057503329') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:48 GMT', + 'ETag', + '"0x8D7FAEC1043EB89"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bdec0-a01e-002b-55d4-2c3126000000', + 'x-ms-client-request-id', + '00321166-23da-4020-933d-48e55bea3769', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:48 GMT' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961057503329/file158977961087608276') + .query(true) + .reply(201, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:50 GMT', + 'ETag', + '"0x8D7FAEC111932E9"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4c4-b01f-0070-34d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '40831bcb-20fe-4ac8-86ac-37c5114c8a58', + 'Date', + 'Mon, 18 May 2020 05:26:49 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961057503329/file158977961087608276', "Hello World") + .query(true) + .reply(202, "", [ + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4c5-b01f-0070-35d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'c6847254-86cc-45cf-a643-9f2809ffc38b', + 'Date', + 'Mon, 18 May 2020 05:26:49 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961057503329/file158977961087608276') + .query(true) + .reply(200, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:50 GMT', + 'ETag', + '"0x8D7FAEC1176AF33"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4c6-b01f-0070-36d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'c94ddeea-b53d-42d7-8cf2-99cc40847db2', + 'Date', + 'Mon, 18 May 2020 05:26:50 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961057503329/dir158977961287500504') + .query(true) + .reply(201, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:51 GMT', + 'ETag', + '"0x8D7FAEC11A5403D"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4c7-b01f-0070-37d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'b59ba02f-cd21-4ac7-a31e-03ff0a9dd896', + 'Date', + 'Mon, 18 May 2020 05:26:50 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961057503329/dir158977961287500504') + .query(true) + .reply(409, {"error":{"code":"PathAlreadyExists","message":"The specified path already exists.\nRequestId:2823e4c8-b01f-0070-38d4-2c365a000000\nTime:2020-05-18T05:26:51.4395475Z"}}, [ + 'Content-Length', + '168', + 'Content-Type', + 'application/json;charset=utf-8', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-error-code', + 'PathAlreadyExists', + 'x-ms-request-id', + '2823e4c8-b01f-0070-38d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'd8f499fe-b4f6-4ffa-95ca-9e5f4f4dcbd9', + 'Date', + 'Mon, 18 May 2020 05:26:50 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977961057503329') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4be47a-a01e-002b-1ad4-2c3126000000', + 'x-ms-client-request-id', + '334ae9bc-1126-4104-857a-7a8b8475a696', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:51 GMT' +]); diff --git a/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakefileclientcreateifnotexists.js b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakefileclientcreateifnotexists.js new file mode 100644 index 000000000000..eb75056a2dbe --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakefileclientcreateifnotexists.js @@ -0,0 +1,133 @@ +let nock = require('nock'); + +module.exports.hash = "1811b46713226bbde364c95d60a8ea4e"; + +module.exports.testInfo = {"uniqueName":{"filesystem":"filesystem158977961377602903","file":"file158977961409907239"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961377602903') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:52 GMT', + 'ETag', + '"0x8D7FAEC122C2572"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4be52f-a01e-002b-41d4-2c3126000000', + 'x-ms-client-request-id', + 'a6024aa2-65f7-462d-943c-8c4e9b66d7b7', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:51 GMT' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961377602903/file158977961409907239') + .query(true) + .reply(201, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:52 GMT', + 'ETag', + '"0x8D7FAEC12608474"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4c9-b01f-0070-39d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '3eb0261a-53de-401f-b7bd-a1f56115bd5d', + 'Date', + 'Mon, 18 May 2020 05:26:51 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961377602903/file158977961409907239', "Hello World") + .query(true) + .reply(202, "", [ + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4ca-b01f-0070-3ad4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'e7b78740-0a29-4920-b6a3-20b7fcfe4617', + 'Date', + 'Mon, 18 May 2020 05:26:51 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961377602903/file158977961409907239') + .query(true) + .reply(200, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:52 GMT', + 'ETag', + '"0x8D7FAEC12BD0C71"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4cb-b01f-0070-3bd4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '4c1d3f4c-d135-417a-bcff-598df8be3f99', + 'Date', + 'Mon, 18 May 2020 05:26:52 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961377602903/file158977961409907239') + .query(true) + .reply(409, {"error":{"code":"PathAlreadyExists","message":"The specified path already exists.\nRequestId:2823e4cc-b01f-0070-3cd4-2c365a000000\nTime:2020-05-18T05:26:53.2810660Z"}}, [ + 'Content-Length', + '168', + 'Content-Type', + 'application/json;charset=utf-8', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-error-code', + 'PathAlreadyExists', + 'x-ms-request-id', + '2823e4cc-b01f-0070-3cd4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '6ccdf7be-52c6-4fa4-a3f8-8053c55146c6', + 'Date', + 'Mon, 18 May 2020 05:26:52 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977961377602903') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4be885-a01e-002b-4ad4-2c3126000000', + 'x-ms-client-request-id', + 'b2fd7748-868c-491a-9452-071f5fd652d3', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:53 GMT' +]); diff --git a/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakepathclientdeleteifexists.js b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakepathclientdeleteifexists.js new file mode 100644 index 000000000000..8f09f2ce2f3d --- /dev/null +++ b/sdk/storage/storage-file-datalake/recordings/node/datalakepathclient/recording_datalakepathclientdeleteifexists.js @@ -0,0 +1,171 @@ +let nock = require('nock'); + +module.exports.hash = "17316020828266734478147489dea269"; + +module.exports.testInfo = {"uniqueName":{"filesystem":"filesystem158977961561501572","file":"file158977961591704183","dir":"dir158977961681406305"},"newDate":{}} + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961561501572') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:26:53 GMT', + 'ETag', + '"0x8D7FAEC1344D59F"', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4be8fe-a01e-002b-3dd4-2c3126000000', + 'x-ms-client-request-id', + 'f1176dc0-3ffd-4118-9b61-164c76a56860', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:53 GMT' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961561501572/file158977961591704183') + .query(true) + .reply(201, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:54 GMT', + 'ETag', + '"0x8D7FAEC1375B2EC"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4cd-b01f-0070-3dd4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'eee57c09-aea5-46d0-aff0-aaa15e70f68f', + 'Date', + 'Mon, 18 May 2020 05:26:53 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961561501572/file158977961591704183', "Hello World") + .query(true) + .reply(202, "", [ + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4ce-b01f-0070-3ed4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '775db9f4-4231-48e3-a5ae-d45f2ff2a9ff', + 'Date', + 'Mon, 18 May 2020 05:26:53 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .patch('/filesystem158977961561501572/file158977961591704183') + .query(true) + .reply(200, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:54 GMT', + 'ETag', + '"0x8D7FAEC13CFFE23"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-server-encrypted', + 'true', + 'x-ms-request-id', + '2823e4d1-b01f-0070-41d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '03756e83-5941-4605-8a82-9a8c20c4f0f9', + 'Date', + 'Mon, 18 May 2020 05:26:54 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977961561501572/dir158977961681406305') + .reply(404, {"error":{"code":"PathNotFound","message":"The specified path does not exist.\nRequestId:2823e4d8-b01f-0070-48d4-2c365a000000\nTime:2020-05-18T05:26:55.0795499Z"}}, [ + 'Content-Length', + '163', + 'Content-Type', + 'application/json;charset=utf-8', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-error-code', + 'PathNotFound', + 'x-ms-request-id', + '2823e4d8-b01f-0070-48d4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '86eeec30-ee07-4e10-8706-1e07424755b2', + 'Date', + 'Mon, 18 May 2020 05:26:54 GMT' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .put('/filesystem158977961561501572/dir158977961681406305') + .query(true) + .reply(201, "", [ + 'Last-Modified', + 'Mon, 18 May 2020 05:26:55 GMT', + 'ETag', + '"0x8D7FAEC1429C71F"', + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4dd-b01f-0070-4cd4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + '76f58d30-797e-4cf0-8fe4-f4b783b9f5a3', + 'Date', + 'Mon, 18 May 2020 05:26:54 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.dfs.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977961561501572/dir158977961681406305') + .reply(200, "", [ + 'Server', + 'Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2823e4e0-b01f-0070-4fd4-2c365a000000', + 'x-ms-version', + '2019-07-07', + 'x-ms-client-request-id', + 'f3557731-2ac0-4591-8099-e4690aed2662', + 'Date', + 'Mon, 18 May 2020 05:26:54 GMT', + 'Content-Length', + '0' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/filesystem158977961561501572') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'dc4bed2c-a01e-002b-25d4-2c3126000000', + 'x-ms-client-request-id', + '3ddc4336-029d-484f-a62d-6935bc1ccd54', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:26:55 GMT' +]); diff --git a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts index 50af83c446d7..baab8c2d48d3 100644 --- a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts @@ -127,7 +127,7 @@ describe("DataLakeFileSystemClient", () => { const metadata = { key: "value" }; const access = "filesystem"; const createRes = await cClient.createIfNotExists({ metadata, access }); - assert.notEqual(null, createRes); + assert.notDeepStrictEqual(null, createRes); const createRes2 = await cClient.createIfNotExists({ metadata, access }); assert.equal(null, createRes2); @@ -140,7 +140,7 @@ describe("DataLakeFileSystemClient", () => { assert.equal(null, await cClient.deleteIfExists()); await cClient.create(); - assert.notEqual(null, await cClient.deleteIfExists()); + assert.notDeepStrictEqual(null, await cClient.deleteIfExists()); }); it("delete", (done) => { diff --git a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts index d586cc1414da..91fa1dd91e0b 100644 --- a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts @@ -336,7 +336,7 @@ describe("DataLakePathClient", () => { it("DataLakeDirectoryClient-createIfNotExists", async () => { const directoryName = recorder.getUniqueName("dir"); const directoryClient = fileSystemClient.getDirectoryClient(directoryName); - assert.notEqual(null, await directoryClient.createIfNotExists()); + assert.notDeepStrictEqual(null, await directoryClient.createIfNotExists()); assert.equal(null, await directoryClient.createIfNotExists()); }); @@ -350,6 +350,6 @@ describe("DataLakePathClient", () => { assert.equal(null, await directoryClient.deleteIfExists()); await directoryClient.create(); - assert.notEqual(null, await directoryClient.deleteIfExists()); + assert.notDeepStrictEqual(null, await directoryClient.deleteIfExists()); }); }); diff --git a/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_createifnotexists.json b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_createifnotexists.json new file mode 100644 index 000000000000..7a6f1089b962 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_createifnotexists.json @@ -0,0 +1,145 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:51:58 GMT", + "etag": "\"0x8D7FAEF94AAB0B6\"", + "last-modified": "Mon, 18 May 2020 05:51:59 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "2b715a5e-99ac-4a96-87a1-6ee8ea2855a3", + "x-ms-request-id": "a9f6a5c8-601a-0048-71d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930/dir158978112149802377", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:51:59 GMT", + "etag": "\"0x8D7FAEF9505A7CC\"", + "last-modified": "Mon, 18 May 2020 05:52:00 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "67eb0636-6886-4de5-86f9-c13a6adae9ec", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:00.0518092Z", + "x-ms-file-creation-time": "2020-05-18T05:52:00.0518092Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:00.0518092Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5cc-601a-0048-74d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930/dir158978112149802377", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 409, + "response": "ResourceAlreadyExistsThe specified resource already exists.\nRequestId:a9f6a5cd-601a-0048-75d8-2cbf38000000\nTime:2020-05-18T05:52:00.3482887Z", + "responseHeaders": { + "content-length": "228", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:51:59 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "15cac587-9e6a-4c34-b646-f4415d3fb1b4", + "x-ms-error-code": "ResourceAlreadyExists", + "x-ms-request-id": "a9f6a5cd-601a-0048-75d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930/dir158978112149802377158978112238709606", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:00 GMT", + "etag": "\"0x8D7FAEF958CF0E5\"", + "last-modified": "Mon, 18 May 2020 05:52:00 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7b5c2bc7-ee97-44b7-82d6-fb650c00dc5a", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:00.9384165Z", + "x-ms-file-creation-time": "2020-05-18T05:52:00.9384165Z", + "x-ms-file-id": "16140971433240035328", + "x-ms-file-last-write-time": "2020-05-18T05:52:00.9384165Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5d0-601a-0048-77d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930/dir158978112149802377158978112238709606", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:00 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b22848a8-82e9-4369-b225-58622c54ce66", + "x-ms-request-id": "a9f6a5d3-601a-0048-79d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112004901930", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:01 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fd510c33-9df7-40e3-9972-b2a968ee4400", + "x-ms-request-id": "a9f6a5d6-601a-0048-7bd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978112004901930", + "dir": "dir158978112149802377", + "dir158978112149802377": "dir158978112149802377158978112238709606" + }, + "newDate": {} + }, + "hash": "44f320098f57e5f1787fd83ab90a12bc" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_deleteifexists.json b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_deleteifexists.json new file mode 100644 index 000000000000..0cb8187516f9 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_deleteifexists.json @@ -0,0 +1,145 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:01 GMT", + "etag": "\"0x8D7FAEF9697225F\"", + "last-modified": "Mon, 18 May 2020 05:52:02 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b4d5657d-504f-4c0b-834c-0085e1571895", + "x-ms-request-id": "a9f6a5d9-601a-0048-7dd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930/dir158978112471809255", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:02 GMT", + "etag": "\"0x8D7FAEF96F08FDD\"", + "last-modified": "Mon, 18 May 2020 05:52:03 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "8996ecdc-3fd1-4710-88fe-edcac0a93adc", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:03.2690141Z", + "x-ms-file-creation-time": "2020-05-18T05:52:03.2690141Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:03.2690141Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5dc-601a-0048-7fd8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930/dir158978112471809255158978112530103895", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 404, + "response": "ResourceNotFoundThe specified resource does not exist.\nRequestId:a9f6a5de-601a-0048-01d8-2cbf38000000\nTime:2020-05-18T05:52:03.8447627Z", + "responseHeaders": { + "content-length": "223", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:02 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d81332d2-963d-4e25-b5c6-d44fa1210376", + "x-ms-error-code": "ResourceNotFound", + "x-ms-request-id": "a9f6a5de-601a-0048-01d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930/dir158978112471809255158978112530103895", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:03 GMT", + "etag": "\"0x8D7FAEF979FDA5E\"", + "last-modified": "Mon, 18 May 2020 05:52:04 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "8c215a39-f38d-46f3-b949-ff5095219d56", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:04.4178014Z", + "x-ms-file-creation-time": "2020-05-18T05:52:04.4178014Z", + "x-ms-file-id": "11529285414812647424", + "x-ms-file-last-write-time": "2020-05-18T05:52:04.4178014Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5e2-601a-0048-03d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930/dir158978112471809255158978112530103895", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:04 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "71ca6580-1691-4302-8b55-85d0267f5716", + "x-ms-request-id": "a9f6a5e4-601a-0048-05d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112412800930", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:04 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fdffcbcb-6321-4f30-b132-0685be2ad035", + "x-ms-request-id": "a9f6a5e7-601a-0048-07d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978112412800930", + "dir": "dir158978112471809255", + "dir158978112471809255": "dir158978112471809255158978112530103895" + }, + "newDate": {} + }, + "hash": "dec25781899b6294b96ed0ad9313628a" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_exists.json b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_exists.json new file mode 100644 index 000000000000..51491af36967 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/directoryclient/recording_exists.json @@ -0,0 +1,127 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112763200734", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:05 GMT", + "etag": "\"0x8D7FAEF98ABBCA7\"", + "last-modified": "Mon, 18 May 2020 05:52:06 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "3184ab5a-c2fe-4379-bcbd-5de9335e85ec", + "x-ms-request-id": "a9f6a5e9-601a-0048-09d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112763200734/dir158978112820509613", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:05 GMT", + "etag": "\"0x8D7FAEF99046415\"", + "last-modified": "Mon, 18 May 2020 05:52:06 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b7646bcd-195d-4147-aaa2-6bedd208bb01", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-creation-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5ed-601a-0048-0bd8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112763200734/dir158978112820509613", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:06 GMT", + "etag": "\"0x8D7FAEF99046415\"", + "last-modified": "Mon, 18 May 2020 05:52:06 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "2e5d5098-144f-4906-8a95-1fac48a25b82", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-creation-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:06.7544085Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5ef-601a-0048-0dd8-2cbf38000000", + "x-ms-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112763200734/dir158978112820509613158978112936208676", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 404, + "response": "ResourceNotFoundThe specified resource does not exist.\nRequestId:a9f6a5f3-601a-0048-10d8-2cbf38000000\nTime:2020-05-18T05:52:07.9136362Z", + "responseHeaders": { + "content-length": "223", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:07 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "1d56bf0e-c139-4387-92dc-0beb2aa68ddb", + "x-ms-error-code": "ResourceNotFound", + "x-ms-request-id": "a9f6a5f3-601a-0048-10d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978112763200734", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:07 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "c449059b-914d-4b72-ae01-2b0ed8236eb3", + "x-ms-request-id": "a9f6a5f6-601a-0048-12d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978112763200734", + "dir": "dir158978112820509613", + "dir158978112820509613": "dir158978112820509613158978112936208676" + }, + "newDate": {} + }, + "hash": "b8a79749eb645a2f892fbec5c54ff311" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_deleteifexists.json b/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_deleteifexists.json new file mode 100644 index 000000000000..8e4dbb86f3d9 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_deleteifexists.json @@ -0,0 +1,139 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:08 GMT", + "etag": "\"0x8D7FAEF9A683BF3\"", + "last-modified": "Mon, 18 May 2020 05:52:09 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "9402a792-34a7-432d-b68f-30c77a83df3d", + "x-ms-request-id": "a9f6a5fa-601a-0048-15d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763/dir158978113112008111", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:08 GMT", + "etag": "\"0x8D7FAEF9AC0E112\"", + "last-modified": "Mon, 18 May 2020 05:52:09 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d1b1bc4d-0da6-448c-9ae5-5b4180786dce", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:09.6674066Z", + "x-ms-file-creation-time": "2020-05-18T05:52:09.6674066Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:09.6674066Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a5fd-601a-0048-17d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763/dir158978113112008111/file158978113169901410", + "query": {}, + "requestBody": null, + "status": 404, + "response": "ResourceNotFoundThe specified resource does not exist.\nRequestId:a9f6a5ff-601a-0048-19d8-2cbf38000000\nTime:2020-05-18T05:52:10.2452831Z", + "responseHeaders": { + "content-length": "223", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:09 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7cfdb98d-7d2d-4071-bbac-f70049bb6cf5", + "x-ms-error-code": "ResourceNotFound", + "x-ms-request-id": "a9f6a5ff-601a-0048-19d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763/dir158978113112008111/file158978113169901410", + "query": {}, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:09 GMT", + "etag": "\"0x8D7FAEF9B70C7E2\"", + "last-modified": "Mon, 18 May 2020 05:52:10 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "f2669caf-bfbb-4c42-b614-c8bf08134e76", + "x-ms-file-attributes": "Archive", + "x-ms-file-change-time": "2020-05-18T05:52:10.8201954Z", + "x-ms-file-creation-time": "2020-05-18T05:52:10.8201954Z", + "x-ms-file-id": "11529285414812647424", + "x-ms-file-last-write-time": "2020-05-18T05:52:10.8201954Z", + "x-ms-file-parent-id": "13835128424026341376", + "x-ms-file-permission-key": "1978041915872117222*12957844477200427368", + "x-ms-request-id": "a9f6a601-601a-0048-1bd8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763/dir158978113112008111/file158978113169901410", + "query": {}, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:10 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "22256165-6c67-4c03-8aa9-2a97f9f2cb2d", + "x-ms-request-id": "a9f6a603-601a-0048-1dd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113053702763", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:11 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "8c7e07bf-64f0-47b1-af79-30820214744d", + "x-ms-request-id": "a9f6a606-601a-0048-1fd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978113053702763", + "dir": "dir158978113112008111", + "file": "file158978113169901410" + }, + "newDate": {} + }, + "hash": "c4251098f40ea448eb84b3a0b939eb6b" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_exists.json b/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_exists.json new file mode 100644 index 000000000000..d9d705b81d03 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/fileclient/recording_exists.json @@ -0,0 +1,152 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:11 GMT", + "etag": "\"0x8D7FAEF9C7ADA23\"", + "last-modified": "Mon, 18 May 2020 05:52:12 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "1d4bc071-10c9-4840-b6c2-cac3f4f157b6", + "x-ms-request-id": "a9f6a609-601a-0048-21d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379/dir158978113459700504", + "query": { + "restype": "directory" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:12 GMT", + "etag": "\"0x8D7FAEF9CD3553C\"", + "last-modified": "Mon, 18 May 2020 05:52:13 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a2781f8f-e667-4078-b78e-17c1b0eedfaa", + "x-ms-file-attributes": "Directory", + "x-ms-file-change-time": "2020-05-18T05:52:13.1437884Z", + "x-ms-file-creation-time": "2020-05-18T05:52:13.1437884Z", + "x-ms-file-id": "13835128424026341376", + "x-ms-file-last-write-time": "2020-05-18T05:52:13.1437884Z", + "x-ms-file-parent-id": "0", + "x-ms-file-permission-key": "15783046271365971681*12957844477200427368", + "x-ms-request-id": "a9f6a60c-601a-0048-23d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "HEAD", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379/dir158978113459700504/file158978113517502681", + "query": {}, + "requestBody": null, + "status": 404, + "response": "", + "responseHeaders": { + "date": "Mon, 18 May 2020 05:52:12 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "e54c34d7-4708-4172-9357-0f0a09d27c5c", + "x-ms-error-code": "ResourceNotFound", + "x-ms-request-id": "a9f6a60e-601a-0048-25d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379/dir158978113459700504/file158978113517502681", + "query": {}, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:13 GMT", + "etag": "\"0x8D7FAEF9D833C1A\"", + "last-modified": "Mon, 18 May 2020 05:52:14 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "e2c419c9-b5fa-4d2f-bdc0-d0d97e338243", + "x-ms-file-attributes": "Archive", + "x-ms-file-change-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-creation-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-id": "11529285414812647424", + "x-ms-file-last-write-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-parent-id": "13835128424026341376", + "x-ms-file-permission-key": "1978041915872117222*12957844477200427368", + "x-ms-request-id": "a9f6a611-601a-0048-27d8-2cbf38000000", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "HEAD", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379/dir158978113459700504/file158978113517502681", + "query": {}, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "11", + "content-type": "application/octet-stream", + "date": "Mon, 18 May 2020 05:52:13 GMT", + "etag": "\"0x8D7FAEF9D833C1A\"", + "last-modified": "Mon, 18 May 2020 05:52:14 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "dba1de30-408b-4837-9c09-05a725fa2f15", + "x-ms-file-attributes": "Archive", + "x-ms-file-change-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-creation-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-id": "11529285414812647424", + "x-ms-file-last-write-time": "2020-05-18T05:52:14.2965786Z", + "x-ms-file-parent-id": "13835128424026341376", + "x-ms-file-permission-key": "1978041915872117222*12957844477200427368", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-request-id": "a9f6a613-601a-0048-29d8-2cbf38000000", + "x-ms-server-encrypted": "true", + "x-ms-type": "File", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113402108379", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:14 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d4a5da1e-4cc2-4703-8924-d39ce74a0c12", + "x-ms-request-id": "a9f6a615-601a-0048-2bd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978113402108379", + "dir": "dir158978113459700504", + "file": "file158978113517502681" + }, + "newDate": {} + }, + "hash": "5c254c3d7520a6dafeb3cd746396176b" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_createifnotexists.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_createifnotexists.json new file mode 100644 index 000000000000..b5aeb7e76b74 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_createifnotexists.json @@ -0,0 +1,108 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113981605831", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:17 GMT", + "etag": "\"0x8D7FAEF9FEF6B40\"", + "last-modified": "Mon, 18 May 2020 05:52:18 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "62575038-2b36-4c43-ab4d-e8b7f6b02f82", + "x-ms-request-id": "a9f6a626-601a-0048-37d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113981605831158978114039400925", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:18 GMT", + "etag": "\"0x8D7FAEFA0475F39\"", + "last-modified": "Mon, 18 May 2020 05:52:18 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "51688ada-5dff-4694-b619-c5ad7cfa28b8", + "x-ms-request-id": "a9f6a62a-601a-0048-39d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113981605831158978114039400925", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 409, + "response": "ShareAlreadyExistsThe specified share already exists.\nRequestId:a9f6a62d-601a-0048-3ad8-2cbf38000000\nTime:2020-05-18T05:52:19.2336358Z", + "responseHeaders": { + "content-length": "222", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:18 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "1fc8d7a8-f2e3-4824-80d7-a7eb230a1a75", + "x-ms-error-code": "ShareAlreadyExists", + "x-ms-request-id": "a9f6a62d-601a-0048-3ad8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113981605831158978114039400925", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:18 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "a07789c5-e59e-415b-afbd-4e1747766246", + "x-ms-request-id": "a9f6a630-601a-0048-3cd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113981605831", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:19 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "37144726-b6e1-475a-b2e9-6fe11a31da75", + "x-ms-request-id": "a9f6a633-601a-0048-3ed8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978113981605831", + "share158978113981605831": "share158978113981605831158978114039400925" + }, + "newDate": {} + }, + "hash": "1d5ed99d3f822200dacdcfac7f67f5fa" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json new file mode 100644 index 000000000000..1a4a54f6d61a --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json @@ -0,0 +1,109 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978114242308721", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:20 GMT", + "etag": "\"0x8D7FAEFA17DCD4E\"", + "last-modified": "Mon, 18 May 2020 05:52:20 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "51f88630-c302-43b5-be82-5e1448fdeeb3", + "x-ms-request-id": "a9f6a637-601a-0048-40d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978114242308721158978114300508815", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:20 GMT", + "etag": "\"0x8D7FAEFA1D5E847\"", + "last-modified": "Mon, 18 May 2020 05:52:21 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "be6c73f2-0ab6-4978-8c5a-5c473db49b39", + "x-ms-request-id": "a9f6a63b-601a-0048-42d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978114242308721158978114300508815", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:21 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "e02eeb72-be21-4cdb-b537-4c66f757dbd7", + "x-ms-request-id": "a9f6a63f-601a-0048-44d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share1589781142423087213158978114415803871", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 404, + "response": "ShareNotFoundThe specified share does not exist.\nRequestId:a9f6a642-601a-0048-46d8-2cbf38000000\nTime:2020-05-18T05:52:22.7020860Z", + "responseHeaders": { + "content-length": "217", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:21 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fdf1072c-71a6-405e-9dbe-4824b6fd59b4", + "x-ms-error-code": "ShareNotFound", + "x-ms-request-id": "a9f6a642-601a-0048-46d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978114242308721", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:22 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b14ba131-ddc4-4ba4-bed1-645d82fa91ad", + "x-ms-request-id": "a9f6a645-601a-0048-48d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978114242308721", + "share158978114242308721": "share158978114242308721158978114300508815", + "share1589781142423087213": "share1589781142423087213158978114415803871" + }, + "newDate": {} + }, + "hash": "27fb753ff4c53facca241255df04cd2c" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_exists.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_exists.json new file mode 100644 index 000000000000..954956fd61ee --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_exists.json @@ -0,0 +1,93 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113750506578", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:15 GMT", + "etag": "\"0x8D7FAEF9E8EFF3B\"", + "last-modified": "Mon, 18 May 2020 05:52:16 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7d170480-afa2-46c7-9367-3ef90c81e699", + "x-ms-request-id": "a9f6a617-601a-0048-2dd8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113750506578", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:15 GMT", + "etag": "\"0x8D7FAEF9E8EFF3B\"", + "last-modified": "Mon, 18 May 2020 05:52:16 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "74ce1c17-bce9-429a-91f9-df373304c8f4", + "x-ms-has-immutability-policy": "false", + "x-ms-has-legal-hold": "false", + "x-ms-request-id": "a9f6a61c-601a-0048-30d8-2cbf38000000", + "x-ms-share-quota": "5120", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113750506578158978113865604206", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 404, + "response": "ShareNotFoundThe specified share does not exist.\nRequestId:a9f6a61e-601a-0048-32d8-2cbf38000000\nTime:2020-05-18T05:52:17.2001946Z", + "responseHeaders": { + "content-length": "217", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:52:16 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "9a860e0a-90b9-4637-ac0c-d35a9cf3226a", + "x-ms-error-code": "ShareNotFound", + "x-ms-request-id": "a9f6a61e-601a-0048-32d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.file.core.windows.net/share158978113750506578", + "query": { + "restype": "share" + }, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:52:16 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "3303b283-07ed-46d5-8c23-e0584a8b1a3c", + "x-ms-request-id": "a9f6a623-601a-0048-35d8-2cbf38000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "share": "share158978113750506578", + "share158978113750506578": "share158978113750506578158978113865604206" + }, + "newDate": {} + }, + "hash": "af6a0e2cc9ade6366722f18ab328d4be" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_createifnotexists.js b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_createifnotexists.js new file mode 100644 index 000000000000..22368c142289 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_createifnotexists.js @@ -0,0 +1,161 @@ +let nock = require('nock'); + +module.exports.hash = "8efaa05b167dfd91d7eb2869d74482bf"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978107550705372","dir":"dir158978107688705269","dir158978107688705269":"dir158978107688705269158978107751909767"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107550705372') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:14 GMT', + 'ETag', + '"0x8D7FAEF7A118948"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2631-401a-0012-0dd8-2cd9df000000', + 'x-ms-client-request-id', + '6404a1f5-4c3a-4802-b00b-7280f1a4927d', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:14 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107550705372/dir158978107688705269') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:15 GMT', + 'ETag', + '"0x8D7FAEF7A4564D3"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2634-401a-0012-0ed8-2cd9df000000', + 'x-ms-client-request-id', + 'c75fd2f1-d619-4c83-8480-4680de9dfd87', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:15.1710419Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:15.1710419Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:15.1710419Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:14 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107550705372/dir158978107688705269') + .query(true) + .reply(409, "ResourceAlreadyExistsThe specified resource already exists.\nRequestId:b2da2635-401a-0012-0fd8-2cd9df000000\nTime:2020-05-18T05:51:15.4766432Z", [ + 'Content-Length', + '228', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2635-401a-0012-0fd8-2cd9df000000', + 'x-ms-client-request-id', + 'c826c54b-9e80-4f9c-b92c-c5c02e901f6d', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ResourceAlreadyExists', + 'Date', + 'Mon, 18 May 2020 05:51:15 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107550705372/dir158978107688705269158978107751909767') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:15 GMT', + 'ETag', + '"0x8D7FAEF7AA2894B"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2637-401a-0012-10d8-2cd9df000000', + 'x-ms-client-request-id', + '8c6cf1da-52ca-4f6b-ab7f-c8201865edae', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:15.7814603Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:15.7814603Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:15.7814603Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '16140971433240035328', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:15 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978107550705372/dir158978107688705269158978107751909767') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2638-401a-0012-11d8-2cd9df000000', + 'x-ms-client-request-id', + 'bac363a4-2225-41c4-9c55-2d1e45517b08', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:15 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978107550705372') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2639-401a-0012-12d8-2cd9df000000', + 'x-ms-client-request-id', + '1b352fec-5233-4a4c-97cd-a0e53822303b', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:16 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_deleteifexists.js b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_deleteifexists.js new file mode 100644 index 000000000000..9f3c84060e7d --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_deleteifexists.js @@ -0,0 +1,161 @@ +let nock = require('nock'); + +module.exports.hash = "1049ebc97f564d93f265d8c9f984849e"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978107842601513","dir":"dir158978107872208254","dir158978107872208254":"dir158978107872208254158978107908607949"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107842601513') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:16 GMT', + 'ETag', + '"0x8D7FAEF7B2CF0A7"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da263a-401a-0012-13d8-2cd9df000000', + 'x-ms-client-request-id', + '200a9e33-01f3-436d-9f7f-c10551c38385', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:16 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107842601513/dir158978107872208254') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:17 GMT', + 'ETag', + '"0x8D7FAEF7B644D98"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da263c-401a-0012-14d8-2cd9df000000', + 'x-ms-client-request-id', + 'a2836029-5f8f-4cbd-911b-90bb05c6f6de', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:17.0513304Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:17.0513304Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:17.0513304Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:16 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978107842601513/dir158978107872208254158978107908607949') + .query(true) + .reply(404, "ResourceNotFoundThe specified resource does not exist.\nRequestId:b2da263f-401a-0012-15d8-2cd9df000000\nTime:2020-05-18T05:51:17.3529760Z", [ + 'Content-Length', + '223', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da263f-401a-0012-15d8-2cd9df000000', + 'x-ms-client-request-id', + '84fa0ba6-abbd-4111-8da3-1b9d4d906acc', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ResourceNotFound', + 'Date', + 'Mon, 18 May 2020 05:51:16 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978107842601513/dir158978107872208254158978107908607949') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:17 GMT', + 'ETag', + '"0x8D7FAEF7BBF009E"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2641-401a-0012-17d8-2cd9df000000', + 'x-ms-client-request-id', + '6422d90a-444f-4afd-9de6-156688a8df16', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:17.6457374Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:17.6457374Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:17.6457374Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '11529285414812647424', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:17 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978107842601513/dir158978107872208254158978107908607949') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2642-401a-0012-18d8-2cd9df000000', + 'x-ms-client-request-id', + '47281c29-a266-4485-9270-bfccd47f85ed', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:17 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978107842601513') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2644-401a-0012-19d8-2cd9df000000', + 'x-ms-client-request-id', + '15ef2946-7047-4c03-8533-15b80456486b', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:17 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_exists.js b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_exists.js new file mode 100644 index 000000000000..f87e507226d8 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/directoryclient/recording_exists.js @@ -0,0 +1,151 @@ +let nock = require('nock'); + +module.exports.hash = "76ab00b4ac39f66a41605dd37adec5e3"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108027809479","dir":"dir158978108058109414","dir158978108058109414":"dir158978108058109414158978108118100008"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108027809479') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:18 GMT', + 'ETag', + '"0x8D7FAEF7C48582C"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2645-401a-0012-1ad8-2cd9df000000', + 'x-ms-client-request-id', + 'ec84b59b-61ca-4474-9444-b907b8fb24ce', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:18 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108027809479/dir158978108058109414') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:18 GMT', + 'ETag', + '"0x8D7FAEF7C763BC9"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2647-401a-0012-1bd8-2cd9df000000', + 'x-ms-client-request-id', + '144b5fa8-6b19-465c-98f3-2b484bf4d37c', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:18 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/share158978108027809479/dir158978108058109414') + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:18 GMT', + 'ETag', + '"0x8D7FAEF7C763BC9"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2648-401a-0012-1cd8-2cd9df000000', + 'x-ms-client-request-id', + '18f964a3-bbf1-4613-b8e3-3469f3ebbf10', + 'x-ms-version', + '2019-07-07', + 'x-ms-server-encrypted', + 'true', + 'x-ms-file-change-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:18.8465609Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Last-Modified,ETag,x-ms-server-encrypted,x-ms-file-change-time,x-ms-file-last-write-time,x-ms-file-creation-time,x-ms-file-permission-key,x-ms-file-attributes,x-ms-file-id,x-ms-file-parent-id,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:18 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/share158978108027809479/dir158978108058109414158978108118100008') + .query(true) + .reply(404, "ResourceNotFoundThe specified resource does not exist.\nRequestId:b2da2649-401a-0012-1dd8-2cd9df000000\nTime:2020-05-18T05:51:19.4484607Z", [ + 'Content-Length', + '223', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2649-401a-0012-1dd8-2cd9df000000', + 'x-ms-client-request-id', + 'd734061e-9d17-4007-a447-e4c0c8c7867b', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ResourceNotFound', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-error-code,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:19 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108027809479') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da264a-401a-0012-1ed8-2cd9df000000', + 'x-ms-client-request-id', + 'ebbd0dbc-0e6a-4bbe-91ea-47c71e60e832', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:19 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/fileclient/recording_deleteifexists.js b/sdk/storage/storage-file-share/recordings/node/fileclient/recording_deleteifexists.js new file mode 100644 index 000000000000..f7e2071316c2 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/fileclient/recording_deleteifexists.js @@ -0,0 +1,158 @@ +let nock = require('nock'); + +module.exports.hash = "3cd044cf62a7627d4095071099982981"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108193707360","dir":"dir158978108223407005","file":"file158978108253102790"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108193707360') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:20 GMT', + 'ETag', + '"0x8D7FAEF7D44C05A"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da264b-401a-0012-1fd8-2cd9df000000', + 'x-ms-client-request-id', + '54bf16e2-c3d5-458e-8226-a019278efe2b', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:19 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108193707360/dir158978108223407005') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:20 GMT', + 'ETag', + '"0x8D7FAEF7D725432"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da264d-401a-0012-20d8-2cd9df000000', + 'x-ms-client-request-id', + 'e5c7370e-8ce6-4ca2-85d8-586332da8800', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:20.4986930Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:20.4986930Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:20.4986930Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:20 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108193707360/dir158978108223407005/file158978108253102790') + .reply(404, "ResourceNotFoundThe specified resource does not exist.\nRequestId:b2da264f-401a-0012-21d8-2cd9df000000\nTime:2020-05-18T05:51:20.7944189Z", [ + 'Content-Length', + '223', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da264f-401a-0012-21d8-2cd9df000000', + 'x-ms-client-request-id', + '29097611-39e0-4049-978e-4abd8343d90b', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ResourceNotFound', + 'Date', + 'Mon, 18 May 2020 05:51:20 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108193707360/dir158978108223407005/file158978108253102790') + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:21 GMT', + 'ETag', + '"0x8D7FAEF7DCC43D0"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2650-401a-0012-22d8-2cd9df000000', + 'x-ms-client-request-id', + '2b617c12-89f0-4af0-ba05-a9b28b43ad85', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:21.0880976Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:21.0880976Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:21.0880976Z', + 'x-ms-file-permission-key', + '1978041915872117222*12957844477200427368', + 'x-ms-file-attributes', + 'Archive', + 'x-ms-file-id', + '11529285414812647424', + 'x-ms-file-parent-id', + '13835128424026341376', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:20 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108193707360/dir158978108223407005/file158978108253102790') + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2651-401a-0012-23d8-2cd9df000000', + 'x-ms-client-request-id', + '6dc42b3f-9023-48c2-b128-a9cb8c90a25c', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:21 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108193707360') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2652-401a-0012-24d8-2cd9df000000', + 'x-ms-client-request-id', + '264f64c5-66b1-46a2-8a65-176b977ee4a0', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:21 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/fileclient/recording_exists.js b/sdk/storage/storage-file-share/recordings/node/fileclient/recording_exists.js new file mode 100644 index 000000000000..24525dbf9b7c --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/fileclient/recording_exists.js @@ -0,0 +1,192 @@ +let nock = require('nock'); + +module.exports.hash = "9d35b839f8787ab888e77eb6d4ce6c08"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108371900572","dir":"dir158978108401803708","file":"file158978108431706300"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108371900572') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:21 GMT', + 'ETag', + '"0x8D7FAEF7E552973"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2653-401a-0012-25d8-2cd9df000000', + 'x-ms-client-request-id', + 'd24a9bbc-3e4e-4683-b62a-520501705ca1', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:21 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108371900572/dir158978108401803708') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:22 GMT', + 'ETag', + '"0x8D7FAEF7E826D55"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2656-401a-0012-26d8-2cd9df000000', + 'x-ms-client-request-id', + '8853c31d-dbf0-42b9-93c5-547efcd2883b', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:22.2819157Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:22.2819157Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:22.2819157Z', + 'x-ms-file-permission-key', + '15783046271365971681*12957844477200427368', + 'x-ms-file-attributes', + 'Directory', + 'x-ms-file-id', + '13835128424026341376', + 'x-ms-file-parent-id', + '0', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:21 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .head('/share158978108371900572/dir158978108401803708/file158978108431706300') + .reply(404, "", [ + 'Transfer-Encoding', + 'chunked', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2658-401a-0012-28d8-2cd9df000000', + 'x-ms-client-request-id', + 'aeca4849-acf4-444f-be33-12061be7f0eb', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ResourceNotFound', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-error-code,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:22 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108371900572/dir158978108401803708/file158978108431706300') + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:22 GMT', + 'ETag', + '"0x8D7FAEF7EDD4778"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2659-401a-0012-29d8-2cd9df000000', + 'x-ms-client-request-id', + '4fee2dc2-d702-4738-a6fc-e8d8b8cc9d8c', + 'x-ms-version', + '2019-07-07', + 'x-ms-file-change-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-permission-key', + '1978041915872117222*12957844477200427368', + 'x-ms-file-attributes', + 'Archive', + 'x-ms-file-id', + '11529285414812647424', + 'x-ms-file-parent-id', + '13835128424026341376', + 'x-ms-request-server-encrypted', + 'true', + 'Date', + 'Mon, 18 May 2020 05:51:22 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .head('/share158978108371900572/dir158978108401803708/file158978108431706300') + .reply(200, "", [ + 'Content-Length', + '11', + 'Content-Type', + 'application/octet-stream', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:22 GMT', + 'ETag', + '"0x8D7FAEF7EDD4778"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da265b-401a-0012-2ad8-2cd9df000000', + 'x-ms-client-request-id', + '263ba5e7-f47c-43fc-ba21-ef446e4d8c96', + 'x-ms-version', + '2019-07-07', + 'x-ms-type', + 'File', + 'x-ms-server-encrypted', + 'true', + 'x-ms-lease-status', + 'unlocked', + 'x-ms-lease-state', + 'available', + 'x-ms-file-change-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-last-write-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-creation-time', + '2020-05-18T05:51:22.8773240Z', + 'x-ms-file-permission-key', + '1978041915872117222*12957844477200427368', + 'x-ms-file-attributes', + 'Archive', + 'x-ms-file-id', + '11529285414812647424', + 'x-ms-file-parent-id', + '13835128424026341376', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Type,Last-Modified,ETag,x-ms-type,x-ms-server-encrypted,x-ms-lease-status,x-ms-lease-state,x-ms-file-change-time,x-ms-file-last-write-time,x-ms-file-creation-time,x-ms-file-permission-key,x-ms-file-attributes,x-ms-file-id,x-ms-file-parent-id,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:22 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108371900572') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da265d-401a-0012-2bd8-2cd9df000000', + 'x-ms-client-request-id', + '07ecb2b0-62ab-458c-a83e-22fcc20b5376', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:23 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_createifnotexists.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_createifnotexists.js new file mode 100644 index 000000000000..aec0ab714d07 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_createifnotexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "22482e1dd1c751c45cc4c4047970c845"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108669701515","share158978108669701515":"share158978108669701515158978108699400572"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108669701515') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:24 GMT', + 'ETag', + '"0x8D7FAEF801AF9A4"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da266f-401a-0012-30d8-2cd9df000000', + 'x-ms-client-request-id', + 'a6b025ec-c745-4c58-9d45-dd0a3696a79a', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:24 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108669701515158978108699400572') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:25 GMT', + 'ETag', + '"0x8D7FAEF80487A8E"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2671-401a-0012-31d8-2cd9df000000', + 'x-ms-client-request-id', + '5dbe7c10-39f8-47d1-8c2b-ba11df145182', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:24 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108669701515158978108699400572') + .query(true) + .reply(409, "ShareAlreadyExistsThe specified share already exists.\nRequestId:b2da2673-401a-0012-32d8-2cd9df000000\nTime:2020-05-18T05:51:25.5537999Z", [ + 'Content-Length', + '222', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2673-401a-0012-32d8-2cd9df000000', + 'x-ms-client-request-id', + 'f9a13168-6513-48e8-80b3-f0e2c0a68f36', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ShareAlreadyExists', + 'Date', + 'Mon, 18 May 2020 05:51:25 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108669701515158978108699400572') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2675-401a-0012-33d8-2cd9df000000', + 'x-ms-client-request-id', + '20401e55-ebd4-494c-88ee-be585955beb8', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:25 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108669701515') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2676-401a-0012-34d8-2cd9df000000', + 'x-ms-client-request-id', + '07d6b264-8e4c-4478-b02e-acdd70c58935', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:25 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js new file mode 100644 index 000000000000..83d8cfb6ba11 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js @@ -0,0 +1,107 @@ +let nock = require('nock'); + +module.exports.hash = "e97179d82a50d9d87f011bdafbd816d3"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108818205267","share158978108818205267":"share158978108818205267158978108847803646","share1589781088182052673":"share1589781088182052673158978108907107388"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108818205267') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:26 GMT', + 'ETag', + '"0x8D7FAEF80FD9396"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2677-401a-0012-35d8-2cd9df000000', + 'x-ms-client-request-id', + '50c45b56-e31d-403a-9225-abe367d527e7', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:26 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108818205267158978108847803646') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:26 GMT', + 'ETag', + '"0x8D7FAEF812B1472"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da267a-401a-0012-37d8-2cd9df000000', + 'x-ms-client-request-id', + '65306e07-9751-4a86-9400-cc9ecd8d9a26', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:26 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108818205267158978108847803646') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da267c-401a-0012-38d8-2cd9df000000', + 'x-ms-client-request-id', + '5dac858c-28ee-475b-ba7d-d7dfc6b5c32d', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:26 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share1589781088182052673158978108907107388') + .query(true) + .reply(404, "ShareNotFoundThe specified share does not exist.\nRequestId:b2da267e-401a-0012-39d8-2cd9df000000\nTime:2020-05-18T05:51:27.3350614Z", [ + 'Content-Length', + '217', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da267e-401a-0012-39d8-2cd9df000000', + 'x-ms-client-request-id', + 'a3c80b81-8ca9-46e3-b221-f88c8750c8a2', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ShareNotFound', + 'Date', + 'Mon, 18 May 2020 05:51:26 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108818205267') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da267f-401a-0012-3ad8-2cd9df000000', + 'x-ms-client-request-id', + '702686cb-608a-418e-8ea1-e3fb0808adc8', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:27 GMT' +]); diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_exists.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_exists.js new file mode 100644 index 000000000000..9cfceacdd117 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_exists.js @@ -0,0 +1,103 @@ +let nock = require('nock'); + +module.exports.hash = "e795b67a4f961b23b646fb0f8c21444d"; + +module.exports.testInfo = {"uniqueName":{"share":"share158978108551204482","share158978108551204482":"share158978108551204482158978108609708713"},"newDate":{}} + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/share158978108551204482') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:23 GMT', + 'ETag', + '"0x8D7FAEF7F65B975"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2666-401a-0012-2cd8-2cd9df000000', + 'x-ms-client-request-id', + '2bde80ff-3265-4fba-92dc-5d3dbed518fb', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:23 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/share158978108551204482') + .query(true) + .reply(200, "", [ + 'Content-Length', + '0', + 'Last-Modified', + 'Mon, 18 May 2020 05:51:23 GMT', + 'ETag', + '"0x8D7FAEF7F65B975"', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da2669-401a-0012-2dd8-2cd9df000000', + 'x-ms-client-request-id', + '5c766a9b-37d8-4f97-b65f-a835d0e46de4', + 'x-ms-version', + '2019-07-07', + 'x-ms-has-immutability-policy', + 'false', + 'x-ms-has-legal-hold', + 'false', + 'x-ms-share-quota', + '5120', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Last-Modified,ETag,x-ms-has-immutability-policy,x-ms-has-legal-hold,x-ms-share-quota,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:23 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/share158978108551204482158978108609708713') + .query(true) + .reply(404, "ShareNotFoundThe specified share does not exist.\nRequestId:b2da266c-401a-0012-2ed8-2cd9df000000\nTime:2020-05-18T05:51:24.3649542Z", [ + 'Content-Length', + '217', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da266c-401a-0012-2ed8-2cd9df000000', + 'x-ms-client-request-id', + '6acc5f58-83c4-42a6-a45d-f0f54d215a0e', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'ShareNotFound', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-error-code,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:51:23 GMT' +]); + +nock('https://fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/share158978108551204482') + .query(true) + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b2da266e-401a-0012-2fd8-2cd9df000000', + 'x-ms-client-request-id', + 'c968185d-87d4-49bb-a6b5-5ee222b73423', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:51:24 GMT' +]); diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index 6404a8306242..962d5c82f54e 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -69,7 +69,7 @@ describe("ShareClient", () => { it("createIfNotExists", async () => { const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); const res = await shareClient2.createIfNotExists(); - assert.notEqual(null, res); + assert.notDeepStrictEqual(null, res); const res2 = await shareClient2.createIfNotExists(); assert.equal(null, res2); await shareClient2.delete(); @@ -85,7 +85,7 @@ describe("ShareClient", () => { await shareClient2.create(); await shareClient2.deletIfExists(); - const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); + const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName + '3')); await shareClient3.deletIfExists(); }); diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json new file mode 100644 index 000000000000..5bcfa7fa70ed --- /dev/null +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json @@ -0,0 +1,85 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:42 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "493c1131-ba4a-4a01-8b64-3f88aa2ccb48", + "x-ms-request-id": "3d8b7a45-5003-001e-1ed9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:42 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "844535f0-6ff1-4d10-9910-a511869c3d4d", + "x-ms-request-id": "3d8b7c83-5003-001e-55d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 409, + "response": "QueueAlreadyExistsThe specified queue already exists.\nRequestId:3d8b80f1-5003-001e-30d9-2c4ed7000000\nTime:2020-05-18T05:58:43.7722180Z", + "responseHeaders": { + "content-length": "222", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:58:43 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "af893455-8680-4268-9537-be4456ec2f18", + "x-ms-error-code": "QueueAlreadyExists", + "x-ms-request-id": "3d8b80f1-5003-001e-30d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:44 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "93e45113-0f50-4158-8647-b0862a123933", + "x-ms-request-id": "3d8b8641-5003-001e-64d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "queue": "queue158978152434109586" + }, + "newDate": {} + }, + "hash": "2dfd66cca269eb00ecd875c757db0440" +} \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json new file mode 100644 index 000000000000..37d5320f4f44 --- /dev/null +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json @@ -0,0 +1,104 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:44 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "72ff95af-5bfa-4dcc-9281-c61a876b4e49", + "x-ms-request-id": "3d8b899b-5003-001e-2fd9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 404, + "response": "QueueNotFoundThe specified queue does not exist.\nRequestId:3d8b8dc3-5003-001e-45d9-2c4ed7000000\nTime:2020-05-18T05:58:45.5314591Z", + "responseHeaders": { + "content-length": "217", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:58:45 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "88ed4a52-0c97-48ef-ab30-6aee7f949cd1", + "x-ms-error-code": "QueueNotFound", + "x-ms-request-id": "3d8b8dc3-5003-001e-45d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:45 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "47ee701b-0405-4d75-9604-ae1c9daf3909", + "x-ms-request-id": "3d8b92a0-5003-001e-03d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:46 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "b3fb7bad-d544-4d6d-baa4-118cc2589d6a", + "x-ms-request-id": "3d8b9706-5003-001e-50d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:46 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "fd9ba84f-6259-4438-8361-d2b2906337bf", + "x-ms-request-id": "3d8b9b2c-5003-001e-64d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "queue": "queue158978152639806367", + "queue158978152639806367": "queue158978152639806367158978152698101446" + }, + "newDate": {} + }, + "hash": "6a4f2d1b9350f0624e76226aa5bccfa5" +} \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_exists.json b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_exists.json new file mode 100644 index 000000000000..06783932f659 --- /dev/null +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_exists.json @@ -0,0 +1,90 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152108502408", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:40 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "793552df-6525-4732-b9de-d14d683a111a", + "x-ms-request-id": "3d8b668d-5003-001e-53d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152108502408", + "query": { + "comp": "metadata", + "timeout": "30" + }, + "requestBody": null, + "status": 200, + "response": "", + "responseHeaders": { + "cache-control": "no-cache", + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:40 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-approximate-messages-count": "0", + "x-ms-client-request-id": "5908d4f5-f42d-4adc-a27b-c25ded6aa59c", + "x-ms-request-id": "3d8b6aec-5003-001e-18d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152108502408158978152313603258", + "query": { + "comp": "metadata", + "timeout": "30" + }, + "requestBody": null, + "status": 404, + "response": "QueueNotFoundThe specified queue does not exist.\nRequestId:3d8b6f17-5003-001e-22d9-2c4ed7000000\nTime:2020-05-18T05:58:41.7027617Z", + "responseHeaders": { + "content-length": "217", + "content-type": "application/xml", + "date": "Mon, 18 May 2020 05:58:41 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "12cf103f-f6c1-4a4d-bc46-d435e3b4981f", + "x-ms-error-code": "QueueNotFound", + "x-ms-request-id": "3d8b6f17-5003-001e-22d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152108502408", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 18 May 2020 05:58:41 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7529fb45-f9eb-45a9-a082-fcf9f77436db", + "x-ms-request-id": "3d8b74f5-5003-001e-64d9-2c4ed7000000", + "x-ms-version": "2019-07-07" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "queue": "queue158978152108502408", + "queue158978152108502408": "queue158978152108502408158978152313603258" + }, + "newDate": {} + }, + "hash": "b378eed67d5e32bad7a662a0828b1601" +} \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js b/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js new file mode 100644 index 000000000000..701288ae4f78 --- /dev/null +++ b/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js @@ -0,0 +1,81 @@ +let nock = require('nock'); + +module.exports.hash = "40ed65f81a62b4b9c0e44b0c82d4a02e"; + +module.exports.testInfo = {"uniqueName":{"queue":"queue158978149547700911"},"newDate":{}} + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149547700911') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46faa11-8003-0050-79d9-2c605f000000', + 'x-ms-client-request-id', + '0351f48a-f4c4-43d1-98f9-ff6b62df0751', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:13 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149547700911') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fab08-8003-0050-62d9-2c605f000000', + 'x-ms-client-request-id', + 'd96c803b-f773-4ece-b9af-18ad3b7a69e4', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:13 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149547700911') + .query(true) + .reply(409, "QueueAlreadyExistsThe specified queue already exists.\nRequestId:f46fac03-8003-0050-52d9-2c605f000000\nTime:2020-05-18T05:58:14.3411781Z", [ + 'Content-Length', + '222', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fac03-8003-0050-52d9-2c605f000000', + 'x-ms-client-request-id', + 'a425cd6c-4a10-4ec0-b87c-916af7d39185', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'QueueAlreadyExists', + 'Date', + 'Mon, 18 May 2020 05:58:14 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue158978149547700911') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46facf2-8003-0050-36d9-2c605f000000', + 'x-ms-client-request-id', + '62b3bb18-cc28-4e10-b6e0-070d3e352bb4', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:14 GMT' +]); diff --git a/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js b/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js new file mode 100644 index 000000000000..68b9f9ee9c3d --- /dev/null +++ b/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js @@ -0,0 +1,99 @@ +let nock = require('nock'); + +module.exports.hash = "1aaaf9d056b4eabfcaa061f70b932ee7"; + +module.exports.testInfo = {"uniqueName":{"queue":"queue158978149667203283","queue158978149667203283":"queue158978149667203283158978149696809280"},"newDate":{}} + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149667203283') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fadea-8003-0050-25d9-2c605f000000', + 'x-ms-client-request-id', + '97dba666-e09c-43ff-a6e9-8d1264da40a2', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:14 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue158978149667203283158978149696809280') + .query(true) + .reply(404, "QueueNotFoundThe specified queue does not exist.\nRequestId:f46faf0c-8003-0050-3dd9-2c605f000000\nTime:2020-05-18T05:58:15.2348136Z", [ + 'Content-Length', + '217', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46faf0c-8003-0050-3dd9-2c605f000000', + 'x-ms-client-request-id', + 'f2a699b8-2645-4d28-9303-0b42f19c0d1c', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'QueueNotFound', + 'Date', + 'Mon, 18 May 2020 05:58:15 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149667203283158978149696809280') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fb02b-8003-0050-4dd9-2c605f000000', + 'x-ms-client-request-id', + '3487828b-b346-4b88-9ce9-8a39413172af', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:15 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue158978149667203283158978149696809280') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fb0f6-8003-0050-0ed9-2c605f000000', + 'x-ms-client-request-id', + 'fa2a9c75-74c3-4c61-8eb7-3443a601389a', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:15 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue158978149667203283') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fb1dd-8003-0050-71d9-2c605f000000', + 'x-ms-client-request-id', + '2512a572-210b-40a8-a697-5dd82fcc8041', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:15 GMT' +]); diff --git a/sdk/storage/storage-queue/recordings/node/queueclient/recording_exists.js b/sdk/storage/storage-queue/recordings/node/queueclient/recording_exists.js new file mode 100644 index 000000000000..58d04b489b17 --- /dev/null +++ b/sdk/storage/storage-queue/recordings/node/queueclient/recording_exists.js @@ -0,0 +1,93 @@ +let nock = require('nock'); + +module.exports.hash = "ef71ed1d7a755db09faa585b94f68a33"; + +module.exports.testInfo = {"uniqueName":{"queue":"queue158978149318207514","queue158978149318207514":"queue158978149318207514158978149486703820"},"newDate":{}} + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue158978149318207514') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fa64d-8003-0050-68d9-2c605f000000', + 'x-ms-client-request-id', + 'a25183a1-affc-48dc-96b5-33a26535f00d', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:12 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .get('/queue158978149318207514') + .query(true) + .reply(200, "", [ + 'Cache-Control', + 'no-cache', + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fa72f-8003-0050-3dd9-2c605f000000', + 'x-ms-client-request-id', + '7ed17f4e-0dcc-4e43-9493-75f5ce167a08', + 'x-ms-version', + '2019-07-07', + 'x-ms-approximate-messages-count', + '0', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-approximate-messages-count,Cache-Control,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:58:12 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .get('/queue158978149318207514158978149486703820') + .query(true) + .reply(404, "QueueNotFoundThe specified queue does not exist.\nRequestId:f46fa838-8003-0050-39d9-2c605f000000\nTime:2020-05-18T05:58:13.1343246Z", [ + 'Content-Length', + '217', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fa838-8003-0050-39d9-2c605f000000', + 'x-ms-client-request-id', + '4bdcd298-4f43-4226-84b3-a0fa348d650b', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'QueueNotFound', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-error-code,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Mon, 18 May 2020 05:58:12 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue158978149318207514') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'f46fa938-8003-0050-29d9-2c605f000000', + 'x-ms-client-request-id', + '21ec402a-eb02-441f-a8be-fa104430e8ed', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 18 May 2020 05:58:13 GMT' +]); diff --git a/sdk/storage/storage-queue/review/storage-queue.api.md b/sdk/storage/storage-queue/review/storage-queue.api.md index 2802b01534ab..69cb13a5d812 100644 --- a/sdk/storage/storage-queue/review/storage-queue.api.md +++ b/sdk/storage/storage-queue/review/storage-queue.api.md @@ -357,8 +357,11 @@ export class QueueClient extends StorageClient { constructor(url: string, pipeline: Pipeline); clearMessages(options?: QueueClearMessagesOptions): Promise; create(options?: QueueCreateOptions): Promise; + createIfNotExists(options?: QueueCreateOptions): Promise; delete(options?: QueueDeleteOptions): Promise; + deleteIfExists(options?: QueueDeleteOptions): Promise; deleteMessage(messageId: string, popReceipt: string, options?: QueueDeleteMessageOptions): Promise; + exists(options?: QueueExistsOptions): Promise; getAccessPolicy(options?: QueueGetAccessPolicyOptions): Promise; getProperties(options?: QueueGetPropertiesOptions): Promise; get name(): string; @@ -423,6 +426,11 @@ export type QueueDeleteResponse = QueueDeleteHeaders & { }; }; +// @public +export interface QueueExistsOptions extends CommonOptions { + abortSignal?: AbortSignalLike; +} + // @public export interface QueueGetAccessPolicyHeaders { clientRequestId?: string; From 7e8be86533d1d7ff699b03c291b15a983f03520f Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 29 Jun 2020 10:53:32 +0800 Subject: [PATCH 08/12] fix typo --- ...ing_deletifexists.json => recording_deleteifexists.json} | 0 ...cording_deletifexists.js => recording_deleteifexists.js} | 0 sdk/storage/storage-file-share/src/ShareClient.ts | 4 ++-- sdk/storage/storage-file-share/test/shareclient.spec.ts | 6 +++--- 4 files changed, 5 insertions(+), 5 deletions(-) rename sdk/storage/storage-file-share/recordings/browsers/shareclient/{recording_deletifexists.json => recording_deleteifexists.json} (100%) rename sdk/storage/storage-file-share/recordings/node/shareclient/{recording_deletifexists.js => recording_deleteifexists.js} (100%) diff --git a/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json b/sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deleteifexists.json similarity index 100% rename from sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deletifexists.json rename to sdk/storage/storage-file-share/recordings/browsers/shareclient/recording_deleteifexists.json diff --git a/sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js b/sdk/storage/storage-file-share/recordings/node/shareclient/recording_deleteifexists.js similarity index 100% rename from sdk/storage/storage-file-share/recordings/node/shareclient/recording_deletifexists.js rename to sdk/storage/storage-file-share/recordings/node/shareclient/recording_deleteifexists.js diff --git a/sdk/storage/storage-file-share/src/ShareClient.ts b/sdk/storage/storage-file-share/src/ShareClient.ts index 0c8dc71a8317..a806757ed580 100644 --- a/sdk/storage/storage-file-share/src/ShareClient.ts +++ b/sdk/storage/storage-file-share/src/ShareClient.ts @@ -845,10 +845,10 @@ export class ShareClient extends StorageClient { * @returns {Promise} Return null if the share does not exist. * @memberof ShareClient */ - public async deletIfExists( + public async deleteIfExists( options: ShareDeleteMethodOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-deletIfExists", options.tracingOptions); + const { span, spanOptions } = createSpan("ShareClient-deleteIfExists", options.tracingOptions); try { return await this.delete({ ...options, diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index 962d5c82f54e..7a84869e0398 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -80,13 +80,13 @@ describe("ShareClient", () => { done(); }); - it("deletIfExists", async () => { + it("deleteIfExists", async () => { const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); await shareClient2.create(); - await shareClient2.deletIfExists(); + await shareClient2.deleteIfExists(); const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName + '3')); - await shareClient3.deletIfExists(); + await shareClient3.deleteIfExists(); }); it("setQuota", async () => { From ce57c80decf5e930fd782d633c432b3b8005dd69 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 29 Jun 2020 15:55:06 +0800 Subject: [PATCH 09/12] change return type - blob --- .../blobclient/recording_delete_snapshot.json | 172 +++--- .../blobclient/recording_deleteifexists.json | 67 ++- .../blobclient/recording_delete_snapshot.js | 172 +++--- .../blobclient/recording_deleteifexists.js | 65 ++- .../storage-blob/review/storage-blob.api.md | 35 +- sdk/storage/storage-blob/src/Clients.ts | 504 +++++++++++------- .../test/appendblobclient.spec.ts | 9 +- .../storage-blob/test/blobclient.spec.ts | 11 +- .../storage-blob/test/containerclient.spec.ts | 14 +- .../storage-blob/test/pageblobclient.spec.ts | 9 +- 10 files changed, 658 insertions(+), 400 deletions(-) diff --git a/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_delete_snapshot.json b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_delete_snapshot.json index ec622fc511d2..4d3f2f19971f 100644 --- a/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_delete_snapshot.json +++ b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_delete_snapshot.json @@ -2,7 +2,7 @@ "recordings": [ { "method": "PUT", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180", "query": { "restype": "container" }, @@ -10,40 +10,40 @@ "status": 201, "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", - "last-modified": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:43 GMT", + "etag": "\"0x8D81C006DAF336B\"", + "last-modified": "Mon, 29 Jun 2020 07:45:43 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "etag": "\"0x8D747578428C6E9\"", - "x-ms-request-id": "215f0cd7-201e-0080-6040-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "74a25bd4-2326-42a6-a9bd-edc41ece2156", - "content-length": "0" + "x-ms-client-request-id": "f58173cf-373d-49d9-8287-d9d8ac77245c", + "x-ms-request-id": "c6ab1622-301e-006a-6fe9-4d7a27000000", + "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943/blob157003455048300515", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", "query": {}, "requestBody": "Hello World", "status": 201, "response": "", "responseHeaders": { - "x-ms-content-crc64": "YeJLfssylmU=", - "date": "Wed, 02 Oct 2019 16:42:30 GMT", - "last-modified": "Wed, 02 Oct 2019 16:42:30 GMT", - "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "content-length": "0", "content-md5": "sQqNsWTgdUEFt6mb5y4/5Q==", - "etag": "\"0x8D747578433A58C\"", - "x-ms-request-id": "215f0d14-201e-0080-1340-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "4a7171ac-62e6-43ad-9287-9ad39bf9e588", + "date": "Mon, 29 Jun 2020 07:45:43 GMT", + "etag": "\"0x8D81C006E0805EE\"", + "last-modified": "Mon, 29 Jun 2020 07:45:44 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d67412d0-a8c0-45ec-b238-008a41bf5a56", + "x-ms-content-crc64": "YeJLfssylmU=", + "x-ms-request-id": "c6ab17f4-301e-006a-22e9-4d7a27000000", "x-ms-request-server-encrypted": "true", - "content-length": "0" + "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943/blob157003455048300515", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", "query": { "comp": "snapshot" }, @@ -51,108 +51,126 @@ "status": 201, "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", - "last-modified": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:44 GMT", + "etag": "\"0x8D81C006E0805EE\"", + "last-modified": "Mon, 29 Jun 2020 07:45:44 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "etag": "\"0x8D747578433A58C\"", - "x-ms-request-id": "215f0d65-201e-0080-5940-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "58c5b2f1-c327-43f3-9f7c-a1b7a7d50612", + "x-ms-client-request-id": "5691bbd0-d002-4b5a-8fa6-0a59e7cc59a7", + "x-ms-request-id": "c6ab19bd-301e-006a-4ce9-4d7a27000000", "x-ms-request-server-encrypted": "false", - "content-length": "0", - "x-ms-snapshot": "2019-10-02T16:42:30.2779406Z" + "x-ms-snapshot": "2020-06-29T07:45:45.0286530Z", + "x-ms-version": "2019-07-07" } }, { "method": "HEAD", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943/blob157003455048300515", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", "query": { - "snapshot": "2019-10-02T16:42:30.2779406Z" + "snapshot": "2020-06-29T07:45:45.0286530Z" }, "requestBody": null, "status": 200, "response": "", "responseHeaders": { - "x-ms-blob-type": "BlockBlob", - "date": "Wed, 02 Oct 2019 16:42:30 GMT", - "content-md5": "sQqNsWTgdUEFt6mb5y4/5Q==", - "x-ms-tag-count": "0", - "x-ms-server-encrypted": "true", - "x-ms-client-request-id": "209a2e06-f911-4147-984c-d17017aea291", + "accept-ranges": "bytes", "content-length": "11", - "x-ms-access-tier": "Cool", - "x-ms-creation-time": "Wed, 02 Oct 2019 16:42:30 GMT", - "last-modified": "Wed, 02 Oct 2019 16:42:30 GMT", - "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "etag": "\"0x8D747578433A58C\"", + "content-md5": "sQqNsWTgdUEFt6mb5y4/5Q==", "content-type": "application/octet-stream", + "date": "Mon, 29 Jun 2020 07:45:44 GMT", + "etag": "\"0x8D81C006E0805EE\"", + "last-modified": "Mon, 29 Jun 2020 07:45:44 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-access-tier": "Hot", "x-ms-access-tier-inferred": "true", - "x-ms-version": "2019-02-02", - "accept-ranges": "bytes", - "x-ms-request-id": "215f0dac-201e-0080-1f40-7993dc000000", - "x-ms-snapshot": "2019-10-02T16:42:30.2779406Z" + "x-ms-blob-type": "BlockBlob", + "x-ms-client-request-id": "8d8b2309-e260-4f73-8934-2c99b3643452", + "x-ms-creation-time": "Mon, 29 Jun 2020 07:45:44 GMT", + "x-ms-request-id": "c6ab1bbd-301e-006a-05e9-4d7a27000000", + "x-ms-server-encrypted": "true", + "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943/blob157003455048300515", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", "query": { - "snapshot": "2019-10-02T16:42:30.2779406Z" + "snapshot": "2020-06-29T07:45:45.0286530Z" }, "requestBody": null, "status": 202, "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:45 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "5c4e0c91-900a-4461-942a-6724cc9c8521", "x-ms-delete-type-permanent": "false", - "x-ms-request-id": "215f0dfa-201e-0080-6940-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "8c2537b9-6491-48b4-9e65-ea01efc3d151", - "content-length": "0" + "x-ms-request-id": "c6ab1dee-301e-006a-5ee9-4d7a27000000", + "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943/blob157003455048300515", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", + "query": { + "snapshot": "2020-06-29T07:45:45.0286530Z" + }, + "requestBody": null, + "status": 404, + "response": "BlobNotFoundThe specified blob does not exist.\nRequestId:c6ab1ef9-301e-006a-4be9-4d7a27000000\nTime:2020-06-29T07:45:46.4689001Z", + "responseHeaders": { + "content-length": "215", + "content-type": "application/xml", + "date": "Mon, 29 Jun 2020 07:45:45 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "df013535-c7a6-4d30-b481-ad906122e016", + "x-ms-error-code": "BlobNotFound", + "x-ms-request-id": "c6ab1ef9-301e-006a-4be9-4d7a27000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180/blob159341674565700412", "query": {}, "requestBody": null, "status": 202, "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:46 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "144ce0fe-6287-4011-8e0d-d2059f9ad5d1", "x-ms-delete-type-permanent": "false", - "x-ms-request-id": "215f0e24-201e-0080-1040-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "cfb3d783-4983-4256-85bb-c0d76ad6f3a2", - "content-length": "0" + "x-ms-request-id": "c6ab20e8-301e-006a-10e9-4d7a27000000", + "x-ms-version": "2019-07-07" } }, { "method": "GET", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180", "query": { - "comp": "list", "include": "snapshots", - "restype": "container" + "restype": "container", + "comp": "list" }, "requestBody": null, "status": 200, - "response": "", + "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-type": "application/xml", + "date": "Mon, 29 Jun 2020 07:45:46 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "transfer-encoding": "chunked", - "content-type": "application/xml", - "x-ms-request-id": "215f0e54-201e-0080-3b40-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "13d1af9b-7858-4c92-b184-fa608ca6fd61" + "x-ms-client-request-id": "5011540c-1afb-4534-aa6b-b70f30fb9ef8", + "x-ms-request-id": "c6ab22a0-301e-006a-16e9-4d7a27000000", + "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.blob.core.windows.net/container157003455041202943", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674506509180", "query": { "restype": "container" }, @@ -160,17 +178,21 @@ "status": 202, "response": "", "responseHeaders": { - "date": "Wed, 02 Oct 2019 16:42:30 GMT", + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:47 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-request-id": "215f0e87-201e-0080-6940-7993dc000000", - "x-ms-version": "2019-02-02", - "x-ms-client-request-id": "c40b2079-a9ba-4a03-abdb-89239209e244", - "content-length": "0" + "x-ms-client-request-id": "ac220f94-5a37-4d70-9d65-970bf6f893ce", + "x-ms-request-id": "c6ab245e-301e-006a-2ee9-4d7a27000000", + "x-ms-version": "2019-07-07" } } ], "uniqueTestInfo": { - "container": "container157003455041202943", - "blob": "blob157003455048300515" - } + "uniqueName": { + "container": "container159341674506509180", + "blob": "blob159341674565700412" + }, + "newDate": {} + }, + "hash": "5449bf4c6b366054c628261ba260927e" } \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json index 7885e8b9e7f0..be55cba03ce8 100644 --- a/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json +++ b/sdk/storage/storage-blob/recordings/browsers/blobclient/recording_deleteifexists.json @@ -2,7 +2,7 @@ "recordings": [ { "method": "PUT", - "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674112908273", "query": { "restype": "container" }, @@ -11,18 +11,18 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 03:23:15 GMT", - "etag": "\"0x8D7FADACD990B4A\"", - "last-modified": "Mon, 18 May 2020 03:23:15 GMT", + "date": "Mon, 29 Jun 2020 07:45:40 GMT", + "etag": "\"0x8D81C006BE65948\"", + "last-modified": "Mon, 29 Jun 2020 07:45:40 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "5b694a9d-8a14-4dca-a8f7-89779d004726", - "x-ms-request-id": "d0a59518-e01e-0069-75c3-2c9b43000000", + "x-ms-client-request-id": "a3491ce8-2635-4d25-abd0-3293f9946b5c", + "x-ms-request-id": "c6ab0c14-301e-006a-1be9-4d7a27000000", "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469/blob158977219758900546", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674112908273/blob159341674267205962", "query": {}, "requestBody": "Hello World", "status": 201, @@ -30,38 +30,55 @@ "responseHeaders": { "content-length": "0", "content-md5": "sQqNsWTgdUEFt6mb5y4/5Q==", - "date": "Mon, 18 May 2020 03:23:15 GMT", - "etag": "\"0x8D7FADACDF38472\"", - "last-modified": "Mon, 18 May 2020 03:23:16 GMT", + "date": "Mon, 29 Jun 2020 07:45:40 GMT", + "etag": "\"0x8D81C006C4320EF\"", + "last-modified": "Mon, 29 Jun 2020 07:45:41 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "55f89ad9-c109-4872-8ff6-d786bf88dbe1", + "x-ms-client-request-id": "4847a0e4-18cf-4970-81dd-3e4c315ea36b", "x-ms-content-crc64": "YeJLfssylmU=", - "x-ms-request-id": "d0a5970f-e01e-0069-44c3-2c9b43000000", + "x-ms-request-id": "c6ab0e2a-301e-006a-07e9-4d7a27000000", "x-ms-request-server-encrypted": "true", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469/blob2158977219818309279", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674112908273/blob159341674267205962", + "query": {}, + "requestBody": null, + "status": 202, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 29 Jun 2020 07:45:41 GMT", + "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "c29ef75e-d5ec-41f2-8940-40dc8aeb4788", + "x-ms-delete-type-permanent": "false", + "x-ms-request-id": "c6ab1002-301e-006a-37e9-4d7a27000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674112908273/blob2159341674385306397", "query": {}, "requestBody": null, "status": 404, - "response": "BlobNotFoundThe specified blob does not exist.\nRequestId:d0a598fa-e01e-0069-12c3-2c9b43000000\nTime:2020-05-18T03:23:16.7166246Z", + "response": "BlobNotFoundThe specified blob does not exist.\nRequestId:c6ab1204-301e-006a-14e9-4d7a27000000\nTime:2020-06-29T07:45:42.6483145Z", "responseHeaders": { "content-length": "215", "content-type": "application/xml", - "date": "Mon, 18 May 2020 03:23:16 GMT", + "date": "Mon, 29 Jun 2020 07:45:41 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "4f11cc72-e3ea-491b-bf39-a198f143ccff", + "x-ms-client-request-id": "6fd6d947-b1bb-46c4-ad7e-d2e81c5abe59", "x-ms-error-code": "BlobNotFound", - "x-ms-request-id": "d0a598fa-e01e-0069-12c3-2c9b43000000", + "x-ms-request-id": "c6ab1204-301e-006a-14e9-4d7a27000000", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.blob.core.windows.net/container158977219699803469", + "url": "https://fakestorageaccount.blob.core.windows.net/container159341674112908273", "query": { "restype": "container" }, @@ -70,21 +87,21 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 03:23:17 GMT", + "date": "Mon, 29 Jun 2020 07:45:42 GMT", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "a39a5a01-0d77-47a1-a633-d08252101853", - "x-ms-request-id": "d0a59a7e-e01e-0069-6bc3-2c9b43000000", + "x-ms-client-request-id": "442d9096-dbe2-41dd-a4f1-d971dc3eb021", + "x-ms-request-id": "c6ab13ff-301e-006a-66e9-4d7a27000000", "x-ms-version": "2019-07-07" } } ], "uniqueTestInfo": { "uniqueName": { - "container": "container158977219699803469", - "blob": "blob158977219758900546", - "blob2": "blob2158977219818309279" + "container": "container159341674112908273", + "blob": "blob159341674267205962", + "blob2": "blob2159341674385306397" }, "newDate": {} }, - "hash": "f2c5329b54568da32738b0633d76fd28" + "hash": "8cfb9a4cc56ebf355235df977184be08" } \ No newline at end of file diff --git a/sdk/storage/storage-blob/recordings/node/blobclient/recording_delete_snapshot.js b/sdk/storage/storage-blob/recordings/node/blobclient/recording_delete_snapshot.js index c0db836b9a53..bdf97a817daa 100644 --- a/sdk/storage/storage-blob/recordings/node/blobclient/recording_delete_snapshot.js +++ b/sdk/storage/storage-blob/recordings/node/blobclient/recording_delete_snapshot.js @@ -1,197 +1,225 @@ let nock = require('nock'); -module.exports.testInfo = {"container":"container156816830699007626","blob":"blob156816830740709825"} +module.exports.hash = "afa85391c0cc900675990e5afe772e0c"; + +module.exports.testInfo = {"uniqueName":{"container":"container159341668720405141","blob":"blob159341668750408325"},"newDate":{}} nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .put('/container156816830699007626') + .put('/container159341668720405141') .query(true) - .reply(201, "", [ 'Content-Length', + .reply(201, "", [ + 'Content-Length', '0', 'Last-Modified', - 'Wed, 11 Sep 2019 02:18:27 GMT', + 'Mon, 29 Jun 2020 07:44:45 GMT', 'ETag', - '"0x8D7365E54C73878"', + '"0x8D81C004B058141"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '1ab468b1-a01e-003f-7147-68d120000000', + '148ba47e-f01e-0065-1de9-4d0c4b000000', 'x-ms-client-request-id', - 'd37ce78a-f261-435a-8fc9-eacecd99eb19', + '8a525b0f-0d53-4c22-adeb-b5d77a0525ec', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'Date', - 'Wed, 11 Sep 2019 02:18:26 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:44 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .put('/container156816830699007626/blob156816830740709825', "Hello World") - .reply(201, "", [ 'Content-Length', + .put('/container159341668720405141/blob159341668750408325', "Hello World") + .reply(201, "", [ + 'Content-Length', '0', 'Content-MD5', 'sQqNsWTgdUEFt6mb5y4/5Q==', 'Last-Modified', - 'Wed, 11 Sep 2019 02:18:27 GMT', + 'Mon, 29 Jun 2020 07:44:46 GMT', 'ETag', - '"0x8D7365E550842C4"', + '"0x8D81C004B3338A7"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '5b62e85c-801e-0001-6747-686701000000', + '148ba540-f01e-0065-3ce9-4d0c4b000000', 'x-ms-client-request-id', - '3b57baa3-ac09-4781-a04b-2f7f04ae4fe4', + 'c0348608-e0c6-4d84-b1b5-6f7317396a54', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'x-ms-content-crc64', 'YeJLfssylmU=', 'x-ms-request-server-encrypted', 'true', 'Date', - 'Wed, 11 Sep 2019 02:18:26 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:45 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .put('/container156816830699007626/blob156816830740709825') + .put('/container159341668720405141/blob159341668750408325') .query(true) - .reply(201, "", [ 'Content-Length', + .reply(201, "", [ + 'Content-Length', '0', 'Last-Modified', - 'Wed, 11 Sep 2019 02:18:27 GMT', + 'Mon, 29 Jun 2020 07:44:46 GMT', 'ETag', - '"0x8D7365E550842C4"', + '"0x8D81C004B3338A7"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '49227429-901e-0015-7a47-68a465000000', + '148ba620-f01e-0065-7be9-4d0c4b000000', 'x-ms-client-request-id', - 'a158121c-1f31-4c3c-8419-a0ca4c3ab217', + '9c3d9229-9ff4-4268-9b2c-4bcdaabb4ad1', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'x-ms-snapshot', - '2019-09-11T02:18:28.1807935Z', + '2020-06-29T07:44:46.3113040Z', 'x-ms-request-server-encrypted', 'false', 'Date', - 'Wed, 11 Sep 2019 02:18:27 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:45 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .head('/container156816830699007626/blob156816830740709825') + .head('/container159341668720405141/blob159341668750408325') .query(true) - .reply(200, "", [ 'Content-Length', + .reply(200, "", [ + 'Content-Length', '11', 'Content-Type', 'application/octet-stream', 'Content-MD5', 'sQqNsWTgdUEFt6mb5y4/5Q==', 'Last-Modified', - 'Wed, 11 Sep 2019 02:18:27 GMT', + 'Mon, 29 Jun 2020 07:44:46 GMT', 'Accept-Ranges', 'bytes', 'ETag', - '"0x8D7365E550842C4"', + '"0x8D81C004B3338A7"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f194ba7e-301e-0057-0847-688f71000000', + '148ba6d0-f01e-0065-17e9-4d0c4b000000', 'x-ms-client-request-id', - 'dc46702b-ea94-4517-b9a4-c2a02983fa74', + '6ee873d9-8f11-4e4c-8afe-db6646f93400', 'x-ms-version', - '2019-02-02', - 'x-ms-snapshot', - '2019-09-11T02:18:28.1807935Z', - 'x-ms-tag-count', - '0', + '2019-07-07', 'x-ms-creation-time', - 'Wed, 11 Sep 2019 02:18:27 GMT', + 'Mon, 29 Jun 2020 07:44:46 GMT', 'x-ms-blob-type', 'BlockBlob', 'x-ms-server-encrypted', 'true', 'x-ms-access-tier', - 'Cool', + 'Hot', 'x-ms-access-tier-inferred', 'true', 'Access-Control-Expose-Headers', - 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-snapshot,x-ms-tag-count,Content-Type,Last-Modified,ETag,x-ms-creation-time,Content-MD5,x-ms-blob-type,x-ms-server-encrypted,x-ms-access-tier,x-ms-access-tier-inferred,Accept-Ranges,Content-Length,Date,Transfer-Encoding', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Type,Last-Modified,ETag,x-ms-creation-time,Content-MD5,x-ms-blob-type,x-ms-server-encrypted,x-ms-access-tier,x-ms-access-tier-inferred,Accept-Ranges,Content-Length,Date,Transfer-Encoding', 'Access-Control-Allow-Origin', '*', 'Date', - 'Wed, 11 Sep 2019 02:18:27 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:45 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/container156816830699007626/blob156816830740709825') + .delete('/container159341668720405141/blob159341668750408325') .query(true) - .reply(202, "", [ 'Content-Length', + .reply(202, "", [ + 'Content-Length', '0', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '0188a6d2-d01e-0019-6d47-684a94000000', + '148ba764-f01e-0065-19e9-4d0c4b000000', 'x-ms-client-request-id', - '52744197-7462-47bc-84d9-f2d1599c5545', + '51cdc4c9-4e36-4833-ab02-365350c8f6c5', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'x-ms-delete-type-permanent', 'false', 'Date', - 'Wed, 11 Sep 2019 02:18:28 GMT' ]); + 'Mon, 29 Jun 2020 07:44:46 GMT' +]); +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container159341668720405141/blob159341668750408325') + .query(true) + .reply(404, "BlobNotFoundThe specified blob does not exist.\nRequestId:148ba85b-f01e-0065-77e9-4d0c4b000000\nTime:2020-06-29T07:44:47.2845453Z", [ + 'Content-Length', + '215', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '148ba85b-f01e-0065-77e9-4d0c4b000000', + 'x-ms-client-request-id', + 'feede690-2f09-4ef5-9db9-2af18c4d3705', + 'x-ms-version', + '2019-07-07', + 'x-ms-error-code', + 'BlobNotFound', + 'Date', + 'Mon, 29 Jun 2020 07:44:46 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/container156816830699007626/blob156816830740709825') - .reply(202, "", [ 'Content-Length', + .delete('/container159341668720405141/blob159341668750408325') + .reply(202, "", [ + 'Content-Length', '0', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '66b0912f-f01e-004a-7847-68569b000000', + '148ba91b-f01e-0065-21e9-4d0c4b000000', 'x-ms-client-request-id', - 'fd836213-9ac3-463b-9257-c0d0099ac627', + 'b3bf741f-2d57-4812-a610-79316ed2929d', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'x-ms-delete-type-permanent', 'false', 'Date', - 'Wed, 11 Sep 2019 02:18:28 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:46 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .get('/container156816830699007626') + .get('/container159341668720405141') .query(true) - .reply(200, "", [ 'Transfer-Encoding', + .reply(200, "", [ + 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/xml', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'be43ac1d-201e-0007-3c47-689079000000', + '148ba9c5-f01e-0065-3de9-4d0c4b000000', 'x-ms-client-request-id', - '9da5858c-1cf8-4898-8310-622d0eef5358', + '92e8186a-6091-4216-ae21-1a3fec576f8f', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'Access-Control-Expose-Headers', 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Type,Content-Length,Date,Transfer-Encoding', 'Access-Control-Allow-Origin', '*', 'Date', - 'Wed, 11 Sep 2019 02:18:29 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:47 GMT' +]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/container156816830699007626') + .delete('/container159341668720405141') .query(true) - .reply(202, "", [ 'Content-Length', + .reply(202, "", [ + 'Content-Length', '0', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - '9bf7f967-501e-0047-0847-68b997000000', + '148baab9-f01e-0065-17e9-4d0c4b000000', 'x-ms-client-request-id', - '06627d00-2545-4771-bb56-55500fea4663', + '490a55e5-67a5-4ba7-abe9-4bd305bfad19', 'x-ms-version', - '2019-02-02', + '2019-07-07', 'Date', - 'Wed, 11 Sep 2019 02:18:30 GMT' ]); - + 'Mon, 29 Jun 2020 07:44:47 GMT' +]); diff --git a/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js b/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js index f35d0f933b83..b83c73b85a1c 100644 --- a/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js +++ b/sdk/storage/storage-blob/recordings/node/blobclient/recording_deleteifexists.js @@ -1,48 +1,48 @@ let nock = require('nock'); -module.exports.hash = "72625ad7134389678fb0c0df03b89186"; +module.exports.hash = "ad00623b96703abd10479eb1162a588d"; -module.exports.testInfo = {"uniqueName":{"container":"container158977214975808781","blob":"blob158977215005109674","blob2":"blob2158977215035103936"},"newDate":{}} +module.exports.testInfo = {"uniqueName":{"container":"container159341668458503751","blob":"blob159341668595804648","blob2":"blob2159341668657509953"},"newDate":{}} nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .put('/container158977214975808781') + .put('/container159341668458503751') .query(true) .reply(201, "", [ 'Content-Length', '0', 'Last-Modified', - 'Mon, 18 May 2020 03:22:27 GMT', + 'Mon, 29 Jun 2020 07:44:44 GMT', 'ETag', - '"0x8D7FADAB14310B4"', + '"0x8D81C004A16B216"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'eed207ca-701e-006b-16c3-2c25fb000000', + '148b9fd5-f01e-0065-7be9-4d0c4b000000', 'x-ms-client-request-id', - '432f8326-c155-46ae-8465-1d9d2e08f009', + '21f0d4a8-4c28-4367-99f1-6ccf9e0b63d4', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 03:22:27 GMT' + 'Mon, 29 Jun 2020 07:44:43 GMT' ]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .put('/container158977214975808781/blob158977215005109674', "Hello World") + .put('/container159341668458503751/blob159341668595804648', "Hello World") .reply(201, "", [ 'Content-Length', '0', 'Content-MD5', 'sQqNsWTgdUEFt6mb5y4/5Q==', 'Last-Modified', - 'Mon, 18 May 2020 03:22:28 GMT', + 'Mon, 29 Jun 2020 07:44:44 GMT', 'ETag', - '"0x8D7FADAB170E45C"', + '"0x8D81C004A4971E1"', 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'eed20857-701e-006b-16c3-2c25fb000000', + '148ba0d9-f01e-0065-63e9-4d0c4b000000', 'x-ms-client-request-id', - '093d954c-ac27-4498-898d-77f740b3f2e6', + '8ec90cab-945f-4fa4-95ae-6057d8510080', 'x-ms-version', '2019-07-07', 'x-ms-content-crc64', @@ -50,12 +50,31 @@ nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParam 'x-ms-request-server-encrypted', 'true', 'Date', - 'Mon, 18 May 2020 03:22:27 GMT' + 'Mon, 29 Jun 2020 07:44:43 GMT' ]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/container158977214975808781/blob2158977215035103936') - .reply(404, "BlobNotFoundThe specified blob does not exist.\nRequestId:eed208dc-701e-006b-15c3-2c25fb000000\nTime:2020-05-18T03:22:28.5945493Z", [ + .delete('/container159341668458503751/blob159341668595804648') + .reply(202, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '148ba1a8-f01e-0065-1ae9-4d0c4b000000', + 'x-ms-client-request-id', + 'f99aee2f-7027-4de5-953a-fbc1a90d5e8e', + 'x-ms-version', + '2019-07-07', + 'x-ms-delete-type-permanent', + 'false', + 'Date', + 'Mon, 29 Jun 2020 07:44:44 GMT' +]); + +nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/container159341668458503751/blob2159341668657509953') + .reply(404, "BlobNotFoundThe specified blob does not exist.\nRequestId:148ba281-f01e-0065-5de9-4d0c4b000000\nTime:2020-06-29T07:44:45.0880620Z", [ 'Content-Length', '215', 'Content-Type', @@ -63,19 +82,19 @@ nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParam 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'eed208dc-701e-006b-15c3-2c25fb000000', + '148ba281-f01e-0065-5de9-4d0c4b000000', 'x-ms-client-request-id', - '1c2262a3-b05c-4279-881a-9f4f7b075a17', + '54d4dd87-b16e-4571-8fb9-50076e3832db', 'x-ms-version', '2019-07-07', 'x-ms-error-code', 'BlobNotFound', 'Date', - 'Mon, 18 May 2020 03:22:28 GMT' + 'Mon, 29 Jun 2020 07:44:44 GMT' ]); nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/container158977214975808781') + .delete('/container159341668458503751') .query(true) .reply(202, "", [ 'Content-Length', @@ -83,11 +102,11 @@ nock('https://fakestorageaccount.blob.core.windows.net:443', {"encodedQueryParam 'Server', 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'eed2096e-701e-006b-19c3-2c25fb000000', + '148ba38a-f01e-0065-45e9-4d0c4b000000', 'x-ms-client-request-id', - '873cbaea-1e8c-4db3-89e6-d299d06c83e3', + '5d53fb8e-d717-44e5-8736-a2cbfd079655', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 03:22:28 GMT' + 'Mon, 29 Jun 2020 07:44:44 GMT' ]); diff --git a/sdk/storage/storage-blob/review/storage-blob.api.md b/sdk/storage/storage-blob/review/storage-blob.api.md index 6ac8910bcc56..81c38ee35dd7 100644 --- a/sdk/storage/storage-blob/review/storage-blob.api.md +++ b/sdk/storage/storage-blob/review/storage-blob.api.md @@ -179,7 +179,7 @@ export class AppendBlobClient extends BlobClient { appendBlock(body: HttpRequestBody, contentLength: number, options?: AppendBlobAppendBlockOptions): Promise; appendBlockFromURL(sourceURL: string, sourceOffset: number, count: number, options?: AppendBlobAppendBlockFromURLOptions): Promise; create(options?: AppendBlobCreateOptions): Promise; - createIfNotExists(options?: AppendBlobCreateIfNotExistsOptions): Promise; + createIfNotExists(options?: AppendBlobCreateIfNotExistsOptions): Promise; withSnapshot(snapshot: string): AppendBlobClient; } @@ -208,6 +208,11 @@ export interface AppendBlobCreateIfNotExistsOptions extends CommonOptions { metadata?: Metadata; } +// @public +export interface AppendBlobCreateIfNotExistsResponse extends AppendBlobCreateResponse { + succeeded: boolean; +} + // @public export interface AppendBlobCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -371,7 +376,7 @@ export class BlobClient extends StorageClient { get containerName(): string; createSnapshot(options?: BlobCreateSnapshotOptions): Promise; delete(options?: BlobDeleteOptions): Promise; - deleteIfExists(options?: BlobDeleteOptions): Promise; + deleteIfExists(options?: BlobDeleteOptions): Promise; download(offset?: number, count?: number, options?: BlobDownloadOptions): Promise; downloadToBuffer(offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise; downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: BlobDownloadToBufferOptions): Promise; @@ -454,6 +459,11 @@ export interface BlobDeleteHeaders { version?: string; } +// @public +export interface BlobDeleteIfExistsResponse extends BlobDeleteResponse { + succeeded: boolean; +} + // @public export interface BlobDeleteOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1247,10 +1257,10 @@ export class ContainerClient extends StorageClient { constructor(url: string, pipeline: Pipeline); get containerName(): string; create(options?: ContainerCreateOptions): Promise; - createIfNotExists(options?: ContainerCreateOptions): Promise; + createIfNotExists(options?: ContainerCreateOptions): Promise; delete(options?: ContainerDeleteMethodOptions): Promise; deleteBlob(blobName: string, options?: BlobDeleteOptions): Promise; - deleteIfExists(options?: ContainerDeleteMethodOptions): Promise; + deleteIfExists(options?: ContainerDeleteMethodOptions): Promise; exists(options?: ContainerExistsOptions): Promise; getAccessPolicy(options?: ContainerGetAccessPolicyOptions): Promise; getAppendBlobClient(blobName: string): AppendBlobClient; @@ -1285,6 +1295,11 @@ export interface ContainerCreateHeaders { version?: string; } +// @public +export interface ContainerCreateIfNotExistsResponse extends ContainerCreateResponse { + succeeded: boolean; +} + // @public export interface ContainerCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1310,6 +1325,11 @@ export interface ContainerDeleteHeaders { version?: string; } +// @public +export interface ContainerDeleteIfExistsResponse extends ContainerDeleteResponse { + succeeded: boolean; +} + // @public export interface ContainerDeleteMethodOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1804,7 +1824,7 @@ export class PageBlobClient extends BlobClient { constructor(url: string, pipeline: Pipeline); clearPages(offset?: number, count?: number, options?: PageBlobClearPagesOptions): Promise; create(size: number, options?: PageBlobCreateOptions): Promise; - createIfNotExists(size: number, options?: PageBlobCreateIfNotExistsOptions): Promise; + createIfNotExists(size: number, options?: PageBlobCreateIfNotExistsOptions): Promise; getPageRanges(offset?: number, count?: number, options?: PageBlobGetPageRangesOptions): Promise; getPageRangesDiff(offset: number, count: number, prevSnapshot: string, options?: PageBlobGetPageRangesDiffOptions): Promise; getPageRangesDiffForManagedDisks(offset: number, count: number, prevSnapshotUrl: string, options?: PageBlobGetPageRangesDiffOptions): Promise; @@ -1864,6 +1884,11 @@ export interface PageBlobCreateIfNotExistsOptions extends CommonOptions { tier?: PremiumPageBlobTier | string; } +// @public +export interface PageBlobCreateIfNotExistsResponse extends PageBlobCreateResponse { + succeeded: boolean; +} + // @public export interface PageBlobCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; diff --git a/sdk/storage/storage-blob/src/Clients.ts b/sdk/storage/storage-blob/src/Clients.ts index 4df1d4a88da8..d70c67d2401e 100644 --- a/sdk/storage/storage-blob/src/Clients.ts +++ b/sdk/storage/storage-blob/src/Clients.ts @@ -7,7 +7,7 @@ import { TokenCredential, isTokenCredential, getDefaultProxySettings, - URLBuilder, + URLBuilder } from "@azure/core-http"; import { CanonicalCode } from "@opentelemetry/api"; import { @@ -29,7 +29,7 @@ import { BlobAbortCopyFromURLResponse, BlobCopyFromURLResponse, BlobSetTierResponse, - ContainerEncryptionScope, + ContainerEncryptionScope } from "./generatedModels"; import { AbortSignalLike } from "@azure/abort-controller"; import { BlobDownloadResponse } from "./BlobDownloadResponse"; @@ -41,19 +41,19 @@ import { ensureCpkIfSpecified, BlockBlobTier, PremiumPageBlobTier, - toAccessTier, + toAccessTier } from "./models"; import { newPipeline, StoragePipelineOptions, Pipeline } from "./Pipeline"; import { DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, URLConstants, DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES, - DEFAULT_BLOCK_BUFFER_SIZE_BYTES, + DEFAULT_BLOCK_BUFFER_SIZE_BYTES } from "./utils/constants"; import { setURLParameter, extractConnectionStringParts, - appendToURLPath, + appendToURLPath } from "./utils/utils.common"; import { fsStat, readStreamToLocalFile, streamToBuffer } from "./utils/utils.node"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; @@ -64,7 +64,7 @@ import { HttpRequestBody } from "@azure/core-http"; import { AppendBlobCreateResponse, AppendBlobAppendBlockFromUrlResponse, - AppendBlobAppendBlockResponse, + AppendBlobAppendBlockResponse } from "./generatedModels"; import { AppendBlob } from "./generated/src/operations"; import { AppendBlobRequestConditions } from "./models"; @@ -78,7 +78,7 @@ import { BlockBlobStageBlockFromURLResponse, BlockBlobCommitBlockListResponse, BlockBlobGetBlockListResponse, - BlockListType, + BlockListType } from "./generatedModels"; import { BlockBlob } from "./generated/src/operations"; import { Range } from "./Range"; @@ -87,7 +87,7 @@ import { BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES, BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES, BLOCK_BLOB_MAX_BLOCKS, - ETagAny, + ETagAny } from "./utils/constants"; import { BufferScheduler } from "./utils/BufferScheduler"; import { Readable } from "stream"; @@ -99,19 +99,19 @@ import { PageBlobResizeResponse, SequenceNumberActionType, PageBlobUpdateSequenceNumberResponse, - PageBlobCopyIncrementalResponse, + PageBlobCopyIncrementalResponse } from "./generatedModels"; import { PageBlob } from "./generated/src/operations"; import { PageBlobRequestConditions } from "./models"; import { PageBlobGetPageRangesDiffResponse, PageBlobGetPageRangesResponse, - rangeResponseFromModel, + rangeResponseFromModel } from "./PageBlobRangeResponse"; import { BlobBeginCopyFromUrlPoller, BlobBeginCopyFromUrlPollState, - CopyPollerBlobClient, + CopyPollerBlobClient } from "./pollers/BlobStartCopyFromUrlPoller"; import { PollerLike, PollOperationState } from "@azure/core-lro"; import { ContainerBreakLeaseOptionalParams } from "./generatedModels"; @@ -129,7 +129,7 @@ import { ContainerListBlobFlatSegmentResponse, ContainerListBlobHierarchySegmentResponse, BlobItem, - BlobPrefix, + BlobPrefix } from "./generatedModels"; import { Container } from "./generated/src/operations"; import { ETagNone } from "./utils/constants"; @@ -847,6 +847,22 @@ export interface BlobDownloadToBufferOptions extends CommonOptions { concurrency?: number; } +/** + * Contains response data for the {@link BlobClient.deleteIfExists} operation. + * + * @export + * @interface BlobDeleteIfExistsResponse + */ +export interface BlobDeleteIfExistsResponse extends BlobDeleteResponse { + /** + * Indicate whether the blob is successfully deleted. Is false if the blob does not exist in the first place. + * + * @type {boolean} + * @memberof BlobDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A BlobClient represents a URL to an Azure Storage blob; the blob may be a block blob, * append blob, or page blob. @@ -1021,7 +1037,7 @@ export class BlobClient extends StorageClient { super(url, pipeline); ({ blobName: this._name, - containerName: this._containerName, + containerName: this._containerName } = this.getBlobAndContainerNamesFromUrl()); this.blobContext = new StorageBlob(this.storageClientContext); } @@ -1157,7 +1173,7 @@ export class BlobClient extends StorageClient { rangeGetContentCRC64: options.rangeGetContentCrc64, snapshot: options.snapshot, cpkInfo: options.customerProvidedKey, - spanOptions, + spanOptions }); // Return browser response immediately @@ -1192,16 +1208,16 @@ export class BlobClient extends StorageClient { ifMatch: options.conditions!.ifMatch || res.etag, ifModifiedSince: options.conditions!.ifModifiedSince, ifNoneMatch: options.conditions!.ifNoneMatch, - ifUnmodifiedSince: options.conditions!.ifUnmodifiedSince, + ifUnmodifiedSince: options.conditions!.ifUnmodifiedSince }, range: rangeToString({ count: offset + res.contentLength! - start, - offset: start, + offset: start }), rangeGetContentMD5: options.rangeGetContentMD5, rangeGetContentCRC64: options.rangeGetContentCrc64, snapshot: options.snapshot, - cpkInfo: options.customerProvidedKey, + cpkInfo: options.customerProvidedKey }; // Debug purpose only @@ -1214,7 +1230,7 @@ export class BlobClient extends StorageClient { return ( await this.blobContext.download({ abortSignal: options.abortSignal, - ...updatedOptions, + ...updatedOptions }) ).readableStreamBody!; }, @@ -1223,13 +1239,13 @@ export class BlobClient extends StorageClient { { abortSignal: options.abortSignal, maxRetryRequests: options.maxRetryRequests, - onProgress: options.onProgress, + onProgress: options.onProgress } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1257,21 +1273,21 @@ export class BlobClient extends StorageClient { customerProvidedKey: options.customerProvidedKey, tracingOptions: { ...options.tracingOptions, - spanOptions, - }, + spanOptions + } }); return true; } catch (e) { if (e.statusCode === 404) { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when checking blob existence", + message: "Expected exception when checking blob existence" }); return false; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1305,12 +1321,12 @@ export class BlobClient extends StorageClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1338,12 +1354,12 @@ export class BlobClient extends StorageClient { deleteSnapshots: options.deleteSnapshots, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1359,27 +1375,37 @@ export class BlobClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob * * @param {BlobDeleteOptions} [options] Optional options to Blob Delete operation. - * @returns {Promise} Returns null if the blob/snapshot does not exist. + * @returns {Promise} * @memberof BlobClient */ - public async deleteIfExists(options: BlobDeleteOptions = {}): Promise { + public async deleteIfExists( + options: BlobDeleteOptions = {} + ): Promise { const { span, spanOptions } = createSpan("BlobClient-deleteIfExists", options.tracingOptions); try { - return await this.delete({ + const res = await this.delete({ ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "BlobNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting a blob or snapshot only if it exists.", + message: "Expected exception when deleting a blob or snapshot only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1402,12 +1428,12 @@ export class BlobClient extends StorageClient { try { return await this.blobContext.undelete({ abortSignal: options.abortSignal, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1443,12 +1469,12 @@ export class BlobClient extends StorageClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1484,12 +1510,12 @@ export class BlobClient extends StorageClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1530,12 +1556,12 @@ export class BlobClient extends StorageClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1624,7 +1650,7 @@ export class BlobClient extends StorageClient { const client: CopyPollerBlobClient = { abortCopyFromURL: (...args) => this.abortCopyFromURL(...args), getProperties: (...args) => this.getProperties(...args), - startCopyFromURL: (...args) => this.startCopyFromURL(...args), + startCopyFromURL: (...args) => this.startCopyFromURL(...args) }; const poller = new BlobBeginCopyFromUrlPoller({ blobClient: client, @@ -1632,7 +1658,7 @@ export class BlobClient extends StorageClient { intervalInMs: options.intervalInMs, onProgress: options.onProgress, resumeFrom: options.resumeFrom, - startCopyFromURLOptions: options, + startCopyFromURLOptions: options }); // Trigger the startCopyFromURL call by calling poll. @@ -1661,12 +1687,12 @@ export class BlobClient extends StorageClient { return await this.blobContext.abortCopyFromURL(copyId, { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1702,15 +1728,15 @@ export class BlobClient extends StorageClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince }, sourceContentMD5: options.sourceContentMD5, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1741,12 +1767,12 @@ export class BlobClient extends StorageClient { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, rehydratePriority: options.rehydratePriority, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1852,8 +1878,8 @@ export class BlobClient extends StorageClient { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions, - }, + spanOptions + } }); count = response.contentLength! - offset; if (count < 0) { @@ -1895,8 +1921,8 @@ export class BlobClient extends StorageClient { maxRetryRequests: options.maxRetryRequestsPerBlock, tracingOptions: { ...options.tracingOptions, - spanOptions, - }, + spanOptions + } }); const stream = response.readableStreamBody!; await streamToBuffer(stream, buffer!, off - offset, chunkEnd - offset); @@ -1914,7 +1940,7 @@ export class BlobClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -1951,8 +1977,8 @@ export class BlobClient extends StorageClient { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions, - }, + spanOptions + } }); if (response.readableStreamBody) { await readStreamToLocalFile(response.readableStreamBody, filePath); @@ -1964,7 +1990,7 @@ export class BlobClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -2054,16 +2080,16 @@ export class BlobClient extends StorageClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince }, rehydratePriority: options.rehydratePriority, tier: toAccessTier(options.tier), - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -2314,6 +2340,22 @@ export interface AppendBlobAppendBlockFromURLOptions extends CommonOptions { encryptionScope?: string; } +/** + * Contains response data for the {@link appendBlobClient.createIfNotExists} operation. + * + * @export + * @interface AppendBlobCreateIfNotExistsResponse + */ +export interface AppendBlobCreateIfNotExistsResponse extends AppendBlobCreateResponse { + /** + * Indicate whether the blob is successfully created. Is false when the blob is not changed as it already exists. + * + * @type {boolean} + * @memberof AppendBlobCreateIfNotExistsResponse + */ + succeeded: boolean; +} + /** * AppendBlobClient defines a set of operations applicable to append blobs. * @@ -2527,12 +2569,12 @@ export class AppendBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -2546,34 +2588,43 @@ export class AppendBlobClient extends BlobClient { * @see https://docs.microsoft.com/rest/api/storageservices/put-blob * * @param {AppendBlobCreateIfNotExistsOptions} [options] - * @returns {Promise} If the blob does not already exist, an AppendBlobCreateResponse. Otherwise, null. + * @returns {Promise} * @memberof AppendBlobClient */ public async createIfNotExists( options: AppendBlobCreateIfNotExistsOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "AppendBlobClient-createIfNotExists", options.tracingOptions ); const conditions = { ifNoneMatch: ETagAny }; try { - return await this.create({ + const res = await this.create({ ...options, conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "BlobAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating a blob only if it does not already exist.", + message: "Expected exception when creating a blob only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } + span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -2629,12 +2680,12 @@ export class AppendBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -2685,16 +2736,16 @@ export class AppendBlobClient extends BlobClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3395,12 +3446,12 @@ export class BlockBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3437,12 +3488,12 @@ export class BlockBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3493,12 +3544,12 @@ export class BlockBlobClient extends BlobClient { sourceRange: offset === 0 && !count ? undefined : rangeToString({ offset, count }), cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3541,13 +3592,13 @@ export class BlockBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions, + spanOptions } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3578,7 +3629,7 @@ export class BlockBlobClient extends BlobClient { const res = await this.blockBlobContext.getBlockList(listType, { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions, + spanOptions }); if (!res.committedBlocks) { @@ -3593,7 +3644,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3638,7 +3689,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3715,7 +3766,7 @@ export class BlockBlobClient extends BlobClient { if (size <= options.maxSingleShotSize) { return await this.upload(blobFactory(0, size), size, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } @@ -3744,14 +3795,14 @@ export class BlockBlobClient extends BlobClient { abortSignal: options.abortSignal, conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); // Update progress after block is successfully uploaded to server, in case of block trying // TODO: Hook with convenience layer progress event in finer level transferProgress += contentLength; if (options.onProgress) { options.onProgress!({ - loadedBytes: transferProgress, + loadedBytes: transferProgress }); } } @@ -3761,12 +3812,12 @@ export class BlockBlobClient extends BlobClient { return this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3800,7 +3851,7 @@ export class BlockBlobClient extends BlobClient { fs.createReadStream(filePath, { autoClose: true, end: count ? offset + count - 1 : Infinity, - start: offset, + start: offset }), size, { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } @@ -3808,7 +3859,7 @@ export class BlockBlobClient extends BlobClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3869,7 +3920,7 @@ export class BlockBlobClient extends BlobClient { await this.stageBlock(blockID, buffer, buffer.length, { conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); // Update progress after block is successfully uploaded to server, in case of block trying @@ -3888,12 +3939,12 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -3973,7 +4024,7 @@ export class BlockBlobClient extends BlobClient { if (size <= options.maxSingleShotSize) { return await this.upload(() => streamFactory(0), size, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } @@ -4006,7 +4057,7 @@ export class BlockBlobClient extends BlobClient { abortSignal: options.abortSignal, conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } } ); // Update progress after block is successfully uploaded to server, in case of block trying @@ -4021,12 +4072,12 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4486,6 +4537,22 @@ export interface PageBlobUploadPagesFromURLOptions extends CommonOptions { encryptionScope?: string; } +/** + * Contains response data for the {@link PageBlobClient.createIfNotExists} operation. + * + * @export + * @interface PageBlobCreateIfNotExistsResponse + */ +export interface PageBlobCreateIfNotExistsResponse extends PageBlobCreateResponse { + /** + * Indicate whether the blob is successfully created. Is false when the blob is not changed as it already exists. + * + * @type {boolean} + * @memberof PageBlobCreateIfNotExistsResponse + */ + succeeded: boolean; +} + /** * PageBlobClient defines a set of operations applicable to page blobs. * @@ -4690,12 +4757,12 @@ export class PageBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4711,35 +4778,44 @@ export class PageBlobClient extends BlobClient { * * @param {number} size size of the page blob. * @param {PageBlobCreateIfNotExistsOptions} [options] - * @returns {Promise} If the blob does not already exist, an PageBlobCreateResponse. Otherwise, null. + * @returns {Promise} * @memberof PageBlobClient */ public async createIfNotExists( size: number, options: PageBlobCreateIfNotExistsOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "PageBlobClient-createIfNotExists", options.tracingOptions ); try { const conditions = { ifNoneMatch: ETagAny }; - return await this.create(size, { + const res = await this.create(size, { ...options, conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "BlobAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: "Expected exception when creating a blob only if it does not already exist.", + message: "Expected exception when creating a blob only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } + span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4779,12 +4855,12 @@ export class PageBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4836,17 +4912,17 @@ export class PageBlobClient extends BlobClient { sourceIfMatch: options.sourceConditions.ifMatch, sourceIfModifiedSince: options.sourceConditions.ifModifiedSince, sourceIfNoneMatch: options.sourceConditions.ifNoneMatch, - sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince, + sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions } ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4880,12 +4956,12 @@ export class PageBlobClient extends BlobClient { sequenceNumberAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4920,13 +4996,13 @@ export class PageBlobClient extends BlobClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, range: rangeToString({ offset, count }), - spanOptions, + spanOptions }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -4965,13 +5041,13 @@ export class PageBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, prevsnapshot: prevSnapshot, range: rangeToString({ offset, count }), - spanOptions, + spanOptions }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5010,13 +5086,13 @@ export class PageBlobClient extends BlobClient { modifiedAccessConditions: options.conditions, prevSnapshotUrl, range: rangeToString({ offset, count }), - spanOptions, + spanOptions }) .then(rangeResponseFromModel); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5045,12 +5121,12 @@ export class PageBlobClient extends BlobClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, encryptionScope: options.encryptionScope, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5084,12 +5160,12 @@ export class PageBlobClient extends BlobClient { blobSequenceNumber: sequenceNumber, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5123,12 +5199,12 @@ export class PageBlobClient extends BlobClient { return await this.pageBlobContext.copyIncremental(copySource, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5312,12 +5388,12 @@ export class BlobLeaseClient { duration, modifiedAccessConditions: options.conditions, proposedLeaseId: this._leaseId, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5348,7 +5424,7 @@ export class BlobLeaseClient { { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions } ); this._leaseId = proposedLeaseId; @@ -5356,7 +5432,7 @@ export class BlobLeaseClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5384,12 +5460,12 @@ export class BlobLeaseClient { return await this._containerOrBlobOperation.releaseLease(this._leaseId, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5413,12 +5489,12 @@ export class BlobLeaseClient { return await this._containerOrBlobOperation.renewLease(this._leaseId, { abortSignal: options.abortSignal, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5449,13 +5525,13 @@ export class BlobLeaseClient { abortSignal: options.abortSignal, breakPeriod, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }; return await this._containerOrBlobOperation.breakLease(operationOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -5910,6 +5986,38 @@ export interface ContainerListBlobsOptions extends CommonOptions { includeUncommitedBlobs?: boolean; } +/** + * Contains response data for the {@link ContainerClient.createIfNotExists} operation. + * + * @export + * @interface ContainerCreateIfNotExistsResponse + */ +export interface ContainerCreateIfNotExistsResponse extends ContainerCreateResponse { + /** + * Indicate whether the container is successfully created. Is false when the container is not changed as it already exists. + * + * @type {boolean} + * @memberof ContainerCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link ContainerClient.deleteIfExists} operation. + * + * @export + * @interface ContainerDeleteIfExistsResponse + */ +export interface ContainerDeleteIfExistsResponse extends ContainerDeleteResponse { + /** + * Indicate whether the container is successfully deleted. Is false if the container does not exist in the first place. + * + * @type {boolean} + * @memberof ContainerDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A ContainerClient represents a URL to the Azure Storage container allowing you to manipulate its blobs. * @@ -6088,12 +6196,12 @@ export class ContainerClient extends StorageClient { // this will filter out unwanted properties from the response object into result object return await this.containerContext.create({ ...options, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6107,33 +6215,41 @@ export class ContainerClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-container * * @param {ContainerCreateOptions} [options] - * @returns {Promise} If the container with the same name does not already exist, a ContainerCreateResponse. Otherwise, null. + * @returns {Promise} * @memberof ContainerClient */ public async createIfNotExists( options: ContainerCreateOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "ContainerClient-createIfNotExists", options.tracingOptions ); try { - return await this.create({ + const res = await this.create({ ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ContainerAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, - message: - "Expected exception when creating a container only if it does not already exist.", + message: "Expected exception when creating a container only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } + span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6157,20 +6273,20 @@ export class ContainerClient extends StorageClient { try { await this.getProperties({ abortSignal: options.abortSignal, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); return true; } catch (e) { if (e.statusCode === 404) { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when checking container existence", + message: "Expected exception when checking container existence" }); return false; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6269,12 +6385,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.getProperties({ abortSignal: options.abortSignal, ...options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6315,12 +6431,12 @@ export class ContainerClient extends StorageClient { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6334,33 +6450,41 @@ export class ContainerClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container * * @param {ContainerDeleteMethodOptions} [options] Options to Container Delete operation. - * @returns {Promise} Returns null if the container does not exist. + * @returns {Promise} * @memberof ContainerClient */ public async deleteIfExists( options: ContainerDeleteMethodOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "ContainerClient-deleteIfExists", options.tracingOptions ); try { - return await this.delete({ + const res = await this.delete({ ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ContainerNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, - message: "Expected exception when deleting a container only if it exists.", + message: "Expected exception when deleting a container only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6409,12 +6533,12 @@ export class ContainerClient extends StorageClient { leaseAccessConditions: options.conditions, metadata, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6451,7 +6575,7 @@ export class ContainerClient extends StorageClient { const response = await this.containerContext.getAccessPolicy({ abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions, + spanOptions }); const res: ContainerGetAccessPolicyResponse = { @@ -6464,14 +6588,14 @@ export class ContainerClient extends StorageClient { requestId: response.requestId, clientRequestId: response.clientRequestId, signedIdentifiers: [], - version: response.version, + version: response.version }; for (const identifier of response) { let accessPolicy: any = undefined; if (identifier.accessPolicy) { accessPolicy = { - permissions: identifier.accessPolicy.permissions, + permissions: identifier.accessPolicy.permissions }; if (identifier.accessPolicy.expiresOn) { @@ -6485,7 +6609,7 @@ export class ContainerClient extends StorageClient { res.signedIdentifiers.push({ accessPolicy, - id: identifier.id, + id: identifier.id }); } @@ -6493,7 +6617,7 @@ export class ContainerClient extends StorageClient { } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6541,9 +6665,9 @@ export class ContainerClient extends StorageClient { permissions: identifier.accessPolicy.permissions, startsOn: identifier.accessPolicy.startsOn ? truncatedISO8061Date(identifier.accessPolicy.startsOn) - : "", + : "" }, - id: identifier.id, + id: identifier.id }); } @@ -6553,12 +6677,12 @@ export class ContainerClient extends StorageClient { containerAcl: acl, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6614,16 +6738,16 @@ export class ContainerClient extends StorageClient { const blockBlobClient = this.getBlockBlobClient(blobName); const response = await blockBlobClient.upload(body, contentLength, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); return { blockBlobClient, - response, + response }; } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6652,12 +6776,12 @@ export class ContainerClient extends StorageClient { const blobClient = this.getBlobClient(blobName); return await blobClient.delete({ ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions }, + tracingOptions: { ...options!.tracingOptions, spanOptions } }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6689,12 +6813,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.listBlobFlatSegment({ marker, ...options, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6728,12 +6852,12 @@ export class ContainerClient extends StorageClient { return await this.containerContext.listBlobHierarchySegment(delimiter, { marker, ...options, - spanOptions, + spanOptions }); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, - message: e.message, + message: e.message }); throw e; } finally { @@ -6883,7 +7007,7 @@ export class ContainerClient extends StorageClient { const updatedOptions: ContainerListBlobsSegmentOptions = { ...options, - ...(include.length > 0 ? { include: include } : {}), + ...(include.length > 0 ? { include: include } : {}) }; // AsyncIterableIterator to iterate over blobs @@ -6907,9 +7031,9 @@ export class ContainerClient extends StorageClient { byPage: (settings: PageSettings = {}) => { return this.listSegments(settings.continuationToken, { maxPageSize: settings.maxPageSize, - ...updatedOptions, + ...updatedOptions }); - }, + } }; } @@ -7088,7 +7212,7 @@ export class ContainerClient extends StorageClient { const updatedOptions: ContainerListBlobsSegmentOptions = { ...options, - ...(include.length > 0 ? { include: include } : {}), + ...(include.length > 0 ? { include: include } : {}) }; // AsyncIterableIterator to iterate over blob prefixes and blobs const iter = this.listItemsByHierarchy(delimiter, updatedOptions); @@ -7111,9 +7235,9 @@ export class ContainerClient extends StorageClient { byPage: (settings: PageSettings = {}) => { return this.listHierarchySegments(delimiter, settings.continuationToken, { maxPageSize: settings.maxPageSize, - ...updatedOptions, + ...updatedOptions }); - }, + } }; } diff --git a/sdk/storage/storage-blob/test/appendblobclient.spec.ts b/sdk/storage/storage-blob/test/appendblobclient.spec.ts index 2f8b41e00a9d..eb740182d732 100644 --- a/sdk/storage/storage-blob/test/appendblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/appendblobclient.spec.ts @@ -65,8 +65,13 @@ describe("AppendBlobClient", () => { }); it("createIfNotExists", async () => { - await appendBlobClient.createIfNotExists(); - await appendBlobClient.createIfNotExists(); + const res = await appendBlobClient.createIfNotExists(); + assert.ok(res.succeeded); + assert.ok(res.etag); + + const res2 = await appendBlobClient.createIfNotExists(); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "BlobAlreadyExists"); }); it("appendBlock", async () => { diff --git a/sdk/storage/storage-blob/test/blobclient.spec.ts b/sdk/storage/storage-blob/test/blobclient.spec.ts index cd475ea424d6..2aec1943cfb0 100644 --- a/sdk/storage/storage-blob/test/blobclient.spec.ts +++ b/sdk/storage/storage-blob/test/blobclient.spec.ts @@ -174,10 +174,15 @@ describe("BlobClient", () => { }); it("deleteIfExists", async () => { + const res = await blobClient.deleteIfExists(); + assert.ok(res.succeeded); + const blobName2 = recorder.getUniqueName("blob2"); const blobClient2 = containerClient.getBlobClient(blobName2); // delete a non-existent blob - await blobClient2.deleteIfExists(); + const res2 = await blobClient2.deleteIfExists(); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "BlobNotFound"); }); // The following code illustrates deleting a snapshot after creating one @@ -189,6 +194,10 @@ describe("BlobClient", () => { await blobSnapshotClient.getProperties(); await blobSnapshotClient.delete(); + const res = await blobSnapshotClient.deleteIfExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "BlobNotFound"); + await blobClient.delete(); const result2 = ( diff --git a/sdk/storage/storage-blob/test/containerclient.spec.ts b/sdk/storage/storage-blob/test/containerclient.spec.ts index 107a7c7ac8b1..3a5896a589af 100644 --- a/sdk/storage/storage-blob/test/containerclient.spec.ts +++ b/sdk/storage/storage-blob/test/containerclient.spec.ts @@ -67,12 +67,15 @@ describe("ContainerClient", () => { it("createIfNotExists", async () => { const res = await containerClient.createIfNotExists(); - assert.equal(res, null); + assert.equal(res.succeeded, false); + assert.equal(res.errorCode, "ContainerAlreadyExists"); const containerName2 = recorder.getUniqueName("container2"); const containerClient2 = blobServiceClient.getContainerClient(containerName2); - const createRes = await containerClient2.createIfNotExists(); - assert.notDeepStrictEqual(createRes, null); + const res2 = await containerClient2.createIfNotExists(); + assert.equal(res2.succeeded, true); + assert.ok(res2.etag); + await containerClient2.delete(); }); @@ -81,12 +84,13 @@ describe("ContainerClient", () => { const containerClient2 = blobServiceClient.getContainerClient(containerName2); await containerClient2.create(); const res = await containerClient2.deleteIfExists(); - assert.notDeepStrictEqual(null, res); + assert.ok(res.succeeded); const containerName3 = recorder.getUniqueName("container3"); const containerClient3 = blobServiceClient.getContainerClient(containerName3); const res2 = await containerClient3.deleteIfExists(); - assert.equal(null, res2); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "ContainerNotFound"); }); it("create with default parameters", (done) => { diff --git a/sdk/storage/storage-blob/test/pageblobclient.spec.ts b/sdk/storage/storage-blob/test/pageblobclient.spec.ts index 452624738b07..9281abdc7f96 100644 --- a/sdk/storage/storage-blob/test/pageblobclient.spec.ts +++ b/sdk/storage/storage-blob/test/pageblobclient.spec.ts @@ -99,8 +99,13 @@ describe("PageBlobClient", () => { }); it("createIfNotExists", async () => { - await pageBlobClient.createIfNotExists(512); - await pageBlobClient.createIfNotExists(512); + const res = await pageBlobClient.createIfNotExists(512); + assert.ok(res.succeeded); + assert.ok(res.etag); + + const res2 = await pageBlobClient.createIfNotExists(512); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "BlobAlreadyExists"); }); it("uploadPages", async () => { From d93cb59de1b7e0edaf491b34fb4d0d0294c8501f Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 29 Jun 2020 17:26:14 +0800 Subject: [PATCH 10/12] change return type - datalake --- .../review/storage-file-datalake.api.md | 44 ++++-- .../src/DataLakeFileSystemClient.ts | 18 ++- .../storage-file-datalake/src/clients.ts | 135 +++++++++++------- .../storage-file-datalake/src/models.ts | 95 ++++++++++-- .../test/filesystemclient.spec.ts | 15 +- .../test/pathclient.spec.ts | 23 ++- 6 files changed, 237 insertions(+), 93 deletions(-) diff --git a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md index 3f8105dedf27..88c213ae9301 100644 --- a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md +++ b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md @@ -133,8 +133,8 @@ export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: Reque export class DataLakeDirectoryClient extends DataLakePathClient { create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; create(options?: DirectoryCreateOptions): Promise; - createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; - createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; + createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise; getFileClient(fileName: string): DataLakeFileClient; getSubdirectoryClient(subdirectoryName: string): DataLakeDirectoryClient; } @@ -146,8 +146,8 @@ export class DataLakeFileClient extends DataLakePathClient { append(body: HttpRequestBody, offset: number, length: number, options?: FileAppendOptions): Promise; create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; create(options?: FileCreateOptions): Promise; - createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; - createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; + createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise; flush(position: number, options?: FileFlushOptions): Promise; read(offset?: number, count?: number, options?: FileReadOptions): Promise; readToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileReadToBufferOptions): Promise; @@ -165,9 +165,9 @@ export class DataLakeFileSystemClient extends StorageClient { constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); constructor(url: string, pipeline: Pipeline); create(options?: FileSystemCreateOptions): Promise; - createIfNotExists(options?: FileSystemCreateOptions): Promise; + createIfNotExists(options?: FileSystemCreateOptions): Promise; delete(options?: FileSystemDeleteOptions): Promise; - deleteIfExists(options?: FileSystemDeleteOptions): Promise; + deleteIfExists(options?: FileSystemDeleteOptions): Promise; exists(options?: FileSystemExistsOptions): Promise; getAccessPolicy(options?: FileSystemGetAccessPolicyOptions): Promise; getDataLakeLeaseClient(proposeLeaseId?: string): DataLakeLeaseClient; @@ -204,9 +204,9 @@ export class DataLakePathClient extends StorageClient { constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions); constructor(url: string, pipeline: Pipeline); create(resourceType: PathResourceType, options?: PathCreateOptions): Promise; - createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; + createIfNotExists(resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions): Promise; delete(recursive?: boolean, options?: PathDeleteOptions): Promise; - deleteIfExists(recursive?: boolean, options?: PathDeleteOptions): Promise; + deleteIfExists(recursive?: boolean, options?: PathDeleteOptions): Promise; exists(options?: PathExistsOptions): Promise; get fileSystemName(): string; getAccessControl(options?: PathGetAccessControlOptions): Promise; @@ -272,6 +272,10 @@ export { deserializationPolicy } export interface DirectoryCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } +// @public (undocumented) +export interface DirectoryCreateIfNotExistsResponse extends PathCreateIfNotExistsResponse { +} + // @public export interface DirectoryCreateOptions extends PathCreateOptions { } @@ -296,6 +300,10 @@ export interface FileAppendOptions extends CommonOptions { export interface FileCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } +// @public (undocumented) +export interface FileCreateIfNotExistsResponse extends PathCreateIfNotExistsResponse { +} + // @public (undocumented) export interface FileCreateOptions extends PathCreateOptions { } @@ -446,6 +454,11 @@ export interface FileSystemCreateHeaders { version?: string; } +// @public +export interface FileSystemCreateIfNotExistsResponse extends FileSystemCreateResponse { + succeeded: boolean; +} + // @public export interface FileSystemCreateOptions extends CommonOptions { // (undocumented) @@ -475,6 +488,11 @@ export interface FileSystemDeleteHeaders { version?: string; } +// @public +export interface FileSystemDeleteIfExistsResponse extends FileSystemDeleteResponse { + succeeded: boolean; +} + // @public (undocumented) export interface FileSystemDeleteOptions extends CommonOptions { // (undocumented) @@ -876,6 +894,11 @@ export interface PathCreateIfNotExistsOptions extends CommonOptions { umask?: string; } +// @public +export interface PathCreateIfNotExistsResponse extends PathCreateResponse { + succeeded: boolean; +} + // @public (undocumented) export interface PathCreateOptions extends CommonOptions { // (undocumented) @@ -909,6 +932,11 @@ export interface PathDeleteHeaders { version?: string; } +// @public +export interface PathDeleteIfExistsResponse extends PathDeleteResponse { + succeeded: boolean; +} + // @public (undocumented) export interface PathDeleteOptions extends CommonOptions { // (undocumented) diff --git a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts index 06c2446805a5..0593bfa0886e 100644 --- a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts +++ b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts @@ -30,7 +30,9 @@ import { Path, PublicAccessType, SignedIdentifier, - FileSystemListPathsResponse + FileSystemListPathsResponse, + FileSystemCreateIfNotExistsResponse, + FileSystemDeleteIfExistsResponse } from "./models"; import { newPipeline, Pipeline, StoragePipelineOptions } from "./Pipeline"; import { StorageClient } from "./StorageClient"; @@ -205,15 +207,17 @@ export class DataLakeFileSystemClient extends StorageClient { /** * Creates a new file system under the specified account. If the file system with - * the same name already exists, it is not changed and this operation returns null. + * the same name already exists, it is not changed. * * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-container * * @param {FileSystemCreateOptions} [options={}] - * @returns {Promise} + * @returns {Promise} * @memberof DataLakeFileSystemClient */ - public async createIfNotExists(options: FileSystemCreateOptions = {}): Promise { + public async createIfNotExists( + options: FileSystemCreateOptions = {} + ): Promise { const { span, spanOptions } = createSpan( "DataLakeFileSystemClient-createIfNotExists", options.tracingOptions @@ -303,10 +307,12 @@ export class DataLakeFileSystemClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-container * * @param {FileSystemDeleteOptions} [options={}] - * @returns {Promise} Returns null if the specified file system doesn't exists. + * @returns {Promise} * @memberof DataLakeFileSystemClient */ - public async deleteIfExists(options: FileSystemDeleteOptions = {}): Promise { + public async deleteIfExists( + options: FileSystemDeleteOptions = {} + ): Promise { const { span, spanOptions } = createSpan( "DataLakeFileSystemClient-deleteIfExists", options.tracingOptions diff --git a/sdk/storage/storage-file-datalake/src/clients.ts b/sdk/storage/storage-file-datalake/src/clients.ts index e435f5d74c78..df8801e7dbd9 100644 --- a/sdk/storage/storage-file-datalake/src/clients.ts +++ b/sdk/storage/storage-file-datalake/src/clients.ts @@ -50,7 +50,11 @@ import { PathSetMetadataOptions, PathSetMetadataResponse, PathSetPermissionsOptions, - PathSetPermissionsResponse + PathSetPermissionsResponse, + PathCreateIfNotExistsResponse, + PathDeleteIfExistsResponse, + DirectoryCreateIfNotExistsResponse, + FileCreateIfNotExistsResponse } from "./models"; import { newPipeline, Pipeline, StoragePipelineOptions } from "./Pipeline"; import { StorageClient } from "./StorageClient"; @@ -248,35 +252,45 @@ export class DataLakePathClient extends StorageClient { } /** - * Create a directory or file. If the resource already exists, it is not changed and this - * operation returns null. + * Create a directory or file. If the resource already exists, it is not changed. * * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param {PathResourceType} resourceType Resource type, "directory" or "file". * @param {PathCreateOptions} [options={}] - * @returns {Promise} + * @returns {Promise} * @memberof DataLakePathClient */ public async createIfNotExists( resourceType: PathResourceType, options: PathCreateIfNotExistsOptions = {} - ): Promise { - const { span, spanOptions } = createSpan("DataLakePathClient-createIfNotExists", options.tracingOptions); + ): Promise { + const { span, spanOptions } = createSpan( + "DataLakePathClient-createIfNotExists", + options.tracingOptions + ); try { const conditions = { ifNoneMatch: ETagAny }; - return await this.create(resourceType, { + const res = await this.create(resourceType, { ...options, conditions, tracingOptions: { ...options!.tracingOptions, spanOptions } - }) + }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "PathAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, message: "Expected exception when creating a blob only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -362,33 +376,44 @@ export class DataLakePathClient extends StorageClient { } /** - * Delete current path (directory or file) if it exists. - * - * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete - * - * @param {boolean} [recursive] Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be deleted. - * @param {PathDeleteOptions} [options={}] - * @returns {Promise} Returns null if the directory or file doesn't exists. - * @memberof DataLakePathClient - */ + * Delete current path (directory or file) if it exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete + * + * @param {boolean} [recursive] Required and valid only when the resource is a directory. If "true", all paths beneath the directory will be deleted. + * @param {PathDeleteOptions} [options={}] + * @returns {Promise} + * @memberof DataLakePathClient + */ public async deleteIfExists( recursive?: boolean, options: PathDeleteOptions = {} - ): Promise { + ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakePathClient-deleteIfExists", options.tracingOptions); + const { span, spanOptions } = createSpan( + "DataLakePathClient-deleteIfExists", + options.tracingOptions + ); try { - return await this.delete(recursive, { + const res = await this.delete(recursive, { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "PathNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, message: "Expected exception when deleting a directory or file only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -795,19 +820,19 @@ export class DataLakeDirectoryClient extends DataLakePathClient { } /** - * Create a directory if it doesn't already exists. - * - * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create - * - * @param {PathResourceType} resourceType Resource type, must be "directory" for DataLakeDirectoryClient. - * @param {PathCreateIfNotExistsOptions} [options] - * @returns {Promise} - * @memberof DataLakeDirectoryClient - */ + * Create a directory if it doesn't already exists. + * + * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create + * + * @param {PathResourceType} resourceType Resource type, must be "directory" for DataLakeDirectoryClient. + * @param {PathCreateIfNotExistsOptions} [options] + * @returns {Promise} + * @memberof DataLakeDirectoryClient + */ public async createIfNotExists( resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions - ): Promise; + ): Promise; /** * Create a directory if it doesn't already exists. @@ -815,27 +840,27 @@ export class DataLakeDirectoryClient extends DataLakePathClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param {DirectoryCreateIfNotExistsOptions} [options] - * @returns {Promise} + * @returns {Promise} * @memberof DataLakeDirectoryClient */ - public async createIfNotExists(options?: DirectoryCreateIfNotExistsOptions): Promise; + public async createIfNotExists( + options?: DirectoryCreateIfNotExistsOptions + ): Promise; public async createIfNotExists( resourceTypeOrOptions?: PathResourceType | PathCreateIfNotExistsOptions, options: PathCreateIfNotExistsOptions = {} - ): Promise { - if (resourceTypeOrOptions === PathResourceType.Directory) { - // FIXME: why don't we pass in the new tracingOptions here? - return super.createIfNotExists(resourceTypeOrOptions as PathResourceType, options); - } - + ): Promise { if (resourceTypeOrOptions === PathResourceType.File) { throw TypeError( `DataLakeDirectoryClient:createIfNotExists() resourceType cannot be ${PathResourceType.File}. Refer to DataLakeFileClient for file creation.` ); } - options = resourceTypeOrOptions || {}; + if (resourceTypeOrOptions !== PathResourceType.Directory) { + options = resourceTypeOrOptions || {}; + } + const { span, spanOptions } = createSpan( "DataLakeDirectoryClient-createIfNotExists", options.tracingOptions @@ -1038,13 +1063,13 @@ export class DataLakeFileClient extends DataLakePathClient { * * @param {PathResourceType} resourceType Resource type, must be "file" for DataLakeFileClient. * @param {PathCreateIfNotExistsOptions} [options] - * @returns {Promise} + * @returns {Promise} * @memberof DataLakeFileClient */ public async createIfNotExists( resourceType: PathResourceType, options?: PathCreateIfNotExistsOptions - ): Promise; + ): Promise; /** * Create a file if it doesn't already exists. @@ -1052,27 +1077,31 @@ export class DataLakeFileClient extends DataLakePathClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create * * @param {FileCreateIfNotExistsOptions} [options] Optional. Options when creating file. - * @returns {Promise} + * @returns {Promise} * @memberof DataLakeFileClient */ - public async createIfNotExists(options?: FileCreateIfNotExistsOptions): Promise; + public async createIfNotExists( + options?: FileCreateIfNotExistsOptions + ): Promise; public async createIfNotExists( resourceTypeOrOptions?: PathResourceType | PathCreateOptions, options: PathCreateIfNotExistsOptions = {} - ): Promise { - if (resourceTypeOrOptions === PathResourceType.File) { - return super.createIfNotExists(resourceTypeOrOptions as PathResourceType, options); - } - + ): Promise { if (resourceTypeOrOptions === PathResourceType.Directory) { throw TypeError( `DataLakeFileClient:createIfNotExists() resourceType cannot be ${PathResourceType.Directory}. Refer to DataLakeDirectoryClient for directory creation.` ); } - options = resourceTypeOrOptions || {}; - const { span, spanOptions } = createSpan("DataLakeFileClient-createIfNotExists", options.tracingOptions); + if (resourceTypeOrOptions !== PathResourceType.File) { + options = resourceTypeOrOptions || {}; + } + + const { span, spanOptions } = createSpan( + "DataLakeFileClient-createIfNotExists", + options.tracingOptions + ); try { return await super.createIfNotExists(PathResourceType.File, { ...options, @@ -1438,7 +1467,7 @@ export class DataLakeFileClient extends DataLakePathClient { if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The data's size is too big or the chunkSize is too small;` + - `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } diff --git a/sdk/storage/storage-file-datalake/src/models.ts b/sdk/storage/storage-file-datalake/src/models.ts index ec6f621c2dd7..3f7cabfaa32d 100644 --- a/sdk/storage/storage-file-datalake/src/models.ts +++ b/sdk/storage/storage-file-datalake/src/models.ts @@ -12,7 +12,8 @@ import { PathCreateResponse, PathGetPropertiesHeaders as PathGetPropertiesHeadersModel, FileSystemListPathsHeaders, - PathList as PathListModel + PathList as PathListModel, + PathDeleteResponse } from "./generated/src/models"; import { CommonOptions } from "./StorageClient"; @@ -260,12 +261,12 @@ export interface SignedIdentifier { export type FileSystemGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & FileSystemGetAccessPolicyHeaders & { - _response: HttpResponse & { - parsedHeaders: FileSystemGetAccessPolicyHeaders; - bodyAsText: string; - parsedBody: SignedIdentifier[]; + _response: HttpResponse & { + parsedHeaders: FileSystemGetAccessPolicyHeaders; + bodyAsText: string; + parsedBody: SignedIdentifier[]; + }; }; -}; export interface FileSystemSetAccessPolicyOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -342,6 +343,38 @@ export interface FileSystemExistsOptions extends CommonOptions { abortSignal?: AbortSignalLike; } +/** + * Contains response data for the {@link DataLakeFileSystemClient.createIfNotExists} operation. + * + * @export + * @interface FileSystemCreateIfNotExistsResponse + */ +export interface FileSystemCreateIfNotExistsResponse extends FileSystemCreateResponse { + /** + * Indicate whether the file system is successfully created. Is false when the file system is not changed as it already exists. + * + * @type {boolean} + * @memberof FileSystemCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link DataLakeFileSystemClient.deleteIfExists} operation. + * + * @export + * @interface FileSystemDeleteIfExistsResponse + */ +export interface FileSystemDeleteIfExistsResponse extends FileSystemDeleteResponse { + /** + * Indicate whether the file system is successfully deleted. Is false if the file system doesn't exist in the first place. + * + * @type {boolean} + * @memberof FileSystemDeleteIfExistsResponse + */ + succeeded: boolean; +} + /**********************************************************/ /** DataLakePathClient option and response related models */ /**********************************************************/ @@ -352,7 +385,7 @@ export interface Metadata { export interface DataLakeRequestConditions extends ModifiedAccessConditions, - LeaseAccessConditions { } + LeaseAccessConditions {} export interface RolePermissions { read: boolean; @@ -595,15 +628,49 @@ export interface PathExistsOptions extends CommonOptions { // customerProvidedKey?: CpkInfo; not supported yet } +/** + * Contains response data for the {@link DataLakePathClient.createIfNotExists} operation. + * + * @export + * @interface PathCreateIfNotExistsResponse + */ +export interface PathCreateIfNotExistsResponse extends PathCreateResponse { + /** + * Indicate whether the directory/file is successfully created. Is false when the directory/file is not changed as it already exists. + * + * @type {boolean} + * @memberof PathCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link DataLakePathClient.deleteIfExists} operation. + * + * @export + * @interface PathDeleteIfExistsResponse + */ +export interface PathDeleteIfExistsResponse extends PathDeleteResponse { + /** + * Indicate whether the directory/file is successfully deleted. Is false if the directory/file doesn't exist in the first place. + * + * @type {boolean} + * @memberof PathDeleteIfExistsResponse + */ + succeeded: boolean; +} + /****************************************************************/ /** DataLakeDirectoryClient option and response related models **/ /****************************************************************/ -export interface DirectoryCreateOptions extends PathCreateOptions { } +export interface DirectoryCreateOptions extends PathCreateOptions {} + +export interface DirectoryCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions {} -export interface DirectoryCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } +export interface DirectoryCreateResponse extends PathCreateResponse {} -export interface DirectoryCreateResponse extends PathCreateResponse { } +export interface DirectoryCreateIfNotExistsResponse extends PathCreateIfNotExistsResponse {} /***********************************************************/ /** DataLakeFileClient option and response related models **/ @@ -675,11 +742,13 @@ export interface FileFlushOptions extends CommonOptions { pathHttpHeaders?: PathHttpHeaders; } -export interface FileCreateOptions extends PathCreateOptions { } +export interface FileCreateOptions extends PathCreateOptions {} + +export interface FileCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions {} -export interface FileCreateIfNotExistsOptions extends PathCreateIfNotExistsOptions { } +export interface FileCreateResponse extends PathCreateResponse {} -export interface FileCreateResponse extends PathCreateResponse { } +export interface FileCreateIfNotExistsResponse extends PathCreateIfNotExistsResponse {} /** * Option interface for Data Lake file - Upload operations diff --git a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts index baab8c2d48d3..00e370a7952f 100644 --- a/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/filesystemclient.spec.ts @@ -20,7 +20,7 @@ describe("DataLakeFileSystemClient", () => { let recorder: Recorder; let serviceClient: DataLakeServiceClient; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); serviceClient = getDataLakeServiceClient(); fileSystemName = recorder.getUniqueName("filesystem"); @@ -28,7 +28,7 @@ describe("DataLakeFileSystemClient", () => { await fileSystemClient.create(); }); - afterEach(async function () { + afterEach(async function() { await fileSystemClient.delete(); recorder.stop(); }); @@ -127,20 +127,23 @@ describe("DataLakeFileSystemClient", () => { const metadata = { key: "value" }; const access = "filesystem"; const createRes = await cClient.createIfNotExists({ metadata, access }); - assert.notDeepStrictEqual(null, createRes); + assert.ok(createRes.succeeded); + assert.ok(createRes.etag); const createRes2 = await cClient.createIfNotExists({ metadata, access }); - assert.equal(null, createRes2); + assert.ok(!createRes2.succeeded); await cClient.delete(); }); it("deleteIfExists", async () => { const cClient = serviceClient.getFileSystemClient(recorder.getUniqueName(fileSystemName)); - assert.equal(null, await cClient.deleteIfExists()); + const res = await cClient.deleteIfExists(); + assert.ok(!res.succeeded); await cClient.create(); - assert.notDeepStrictEqual(null, await cClient.deleteIfExists()); + const res2 = await cClient.deleteIfExists(); + assert.ok(res2.succeeded); }); it("delete", (done) => { diff --git a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts index 91fa1dd91e0b..bf84cb084fe7 100644 --- a/sdk/storage/storage-file-datalake/test/pathclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/pathclient.spec.ts @@ -20,7 +20,7 @@ describe("DataLakePathClient", () => { let recorder: any; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); const serviceClient = getDataLakeServiceClient(); fileSystemName = recorder.getUniqueName("filesystem"); @@ -33,7 +33,7 @@ describe("DataLakePathClient", () => { await fileClient.flush(content.length); }); - afterEach(async function () { + afterEach(async function() { await fileSystemClient.delete(); recorder.stop(); }); @@ -336,20 +336,29 @@ describe("DataLakePathClient", () => { it("DataLakeDirectoryClient-createIfNotExists", async () => { const directoryName = recorder.getUniqueName("dir"); const directoryClient = fileSystemClient.getDirectoryClient(directoryName); - assert.notDeepStrictEqual(null, await directoryClient.createIfNotExists()); - assert.equal(null, await directoryClient.createIfNotExists()); + const res = await directoryClient.createIfNotExists(); + assert.ok(res.succeeded); + + const res2 = await directoryClient.createIfNotExists(); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "PathAlreadyExists"); }); it("DataLakeFileClient-createIfNotExists", async () => { - await fileClient.createIfNotExists(); + const res = await fileClient.createIfNotExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "PathAlreadyExists"); }); it("DataLakePathClient-deleteIfExists", async () => { const directoryName = recorder.getUniqueName("dir"); const directoryClient = fileSystemClient.getDirectoryClient(directoryName); - assert.equal(null, await directoryClient.deleteIfExists()); + const res = await directoryClient.deleteIfExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "PathNotFound"); await directoryClient.create(); - assert.notDeepStrictEqual(null, await directoryClient.deleteIfExists()); + const res2 = await directoryClient.deleteIfExists(); + assert.ok(res2.succeeded); }); }); From 8363db69d4bbbf50297347782ff22c40cc53f3c4 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 29 Jun 2020 18:00:59 +0800 Subject: [PATCH 11/12] change return type - file --- .../review/storage-file-share.api.md | 35 ++++++- .../storage-file-share/src/ShareClient.ts | 96 ++++++++++++++----- .../src/ShareDirectoryClient.ts | 68 +++++++++++-- .../storage-file-share/src/ShareFileClient.ts | 34 ++++++- .../test/directoryclient.spec.ts | 19 ++-- .../test/fileclient.spec.ts | 16 ++-- .../test/shareclient.spec.ts | 20 ++-- 7 files changed, 226 insertions(+), 62 deletions(-) diff --git a/sdk/storage/storage-file-share/review/storage-file-share.api.md b/sdk/storage/storage-file-share/review/storage-file-share.api.md index cece10fa0e5b..72b4bd5eb1f5 100644 --- a/sdk/storage/storage-file-share/review/storage-file-share.api.md +++ b/sdk/storage/storage-file-share/review/storage-file-share.api.md @@ -173,6 +173,11 @@ export interface DirectoryCreateHeaders { version?: string; } +// @public +export interface DirectoryCreateIfNotExistsResponse extends DirectoryCreateResponse { + succeeded: boolean; +} + // @public export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOptions, CommonOptions { abortSignal?: AbortSignalLike; @@ -195,6 +200,11 @@ export interface DirectoryDeleteHeaders { version?: string; } +// @public +export interface DirectoryDeleteIfExistsResponse extends DirectoryDeleteResponse { + succeeded: boolean; +} + // @public export interface DirectoryDeleteOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -494,6 +504,11 @@ export interface FileDeleteHeaders { version?: string; } +// @public +export interface FileDeleteIfExistsResponse extends FileDeleteResponse { + succeeded: boolean; +} + // @public export interface FileDeleteOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1296,13 +1311,13 @@ export class ShareClient extends StorageClient { fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse; }>; - createIfNotExists(options?: ShareCreateOptions): Promise; + createIfNotExists(options?: ShareCreateOptions): Promise; createPermission(filePermission: string, options?: ShareCreatePermissionOptions): Promise; createSnapshot(options?: ShareCreateSnapshotOptions): Promise; delete(options?: ShareDeleteMethodOptions): Promise; deleteDirectory(directoryName: string, options?: DirectoryDeleteOptions): Promise; deleteFile(fileName: string, options?: FileDeleteOptions): Promise; - deletIfExists(options?: ShareDeleteMethodOptions): Promise; + deleteIfExists(options?: ShareDeleteMethodOptions): Promise; exists(options?: ShareExistsOptions): Promise; getAccessPolicy(options?: ShareGetAccessPolicyOptions): Promise; getDirectoryClient(directoryName: string): ShareDirectoryClient; @@ -1328,6 +1343,11 @@ export interface ShareCreateHeaders { version?: string; } +// @public +export interface ShareCreateIfNotExistsResponse extends ShareCreateResponse { + succeeded: boolean; +} + // @public export interface ShareCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1402,6 +1422,11 @@ export interface ShareDeleteHeaders { version?: string; } +// @public +export interface ShareDeleteIfExistsResponse extends ShareDeleteResponse { + succeeded: boolean; +} + // @public export interface ShareDeleteMethodOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -1424,14 +1449,14 @@ export class ShareDirectoryClient extends StorageClient { fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse; }>; - createIfNotExists(options?: DirectoryCreateOptions): Promise; + createIfNotExists(options?: DirectoryCreateOptions): Promise; createSubdirectory(directoryName: string, options?: DirectoryCreateOptions): Promise<{ directoryClient: ShareDirectoryClient; directoryCreateResponse: DirectoryCreateResponse; }>; delete(options?: DirectoryDeleteOptions): Promise; deleteFile(fileName: string, options?: FileDeleteOptions): Promise; - deleteIfExists(options?: DirectoryDeleteOptions): Promise; + deleteIfExists(options?: DirectoryDeleteOptions): Promise; deleteSubdirectory(directoryName: string, options?: DirectoryDeleteOptions): Promise; exists(options?: DirectoryExistsOptions): Promise; forceCloseAllHandles(options?: DirectoryForceCloseHandlesSegmentOptions): Promise; @@ -1465,7 +1490,7 @@ export class ShareFileClient extends StorageClient { clearRange(offset: number, contentLength: number, options?: FileClearRangeOptions): Promise; create(size: number, options?: FileCreateOptions): Promise; delete(options?: FileDeleteOptions): Promise; - deleteIfExists(options?: FileDeleteOptions): Promise; + deleteIfExists(options?: FileDeleteOptions): Promise; download(offset?: number, count?: number, options?: FileDownloadOptions): Promise; downloadToBuffer(buffer: Buffer, offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise; downloadToBuffer(offset?: number, count?: number, options?: FileDownloadToBufferOptions): Promise; diff --git a/sdk/storage/storage-file-share/src/ShareClient.ts b/sdk/storage/storage-file-share/src/ShareClient.ts index a806757ed580..e64e532ae62c 100644 --- a/sdk/storage/storage-file-share/src/ShareClient.ts +++ b/sdk/storage/storage-file-share/src/ShareClient.ts @@ -258,24 +258,24 @@ export interface SignedIdentifier { export declare type ShareGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ShareGetAccessPolicyHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ShareGetAccessPolicyHeaders; /** - * The response body as text (string format) + * The underlying HTTP response. */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignedIdentifierModel[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: ShareGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; + }; }; -}; /** * Options to configure the {@link ShareClient.createSnapshot} operation. @@ -353,6 +353,38 @@ export type ShareGetStatisticsResponse = ShareGetStatisticsResponseModel & { shareUsage: number; }; +/** + * Contains response data for the {@link ShareClient.createIfNotExists} operation. + * + * @export + * @interface ShareCreateIfNotExistsResponse + */ +export interface ShareCreateIfNotExistsResponse extends ShareCreateResponse { + /** + * Indicate whether the share is successfully created. Is false when the share is not changed as it already exists. + * + * @type {boolean} + * @memberof ShareCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link ShareClient.deleteIfExists} operation. + * + * @export + * @interface ShareDeleteIfExistsResponse + */ +export interface ShareDeleteIfExistsResponse extends ShareDeleteResponse { + /** + * Indicate whether the share is successfully deleted. Is false if the share does not exist in the first place. + * + * @type {boolean} + * @memberof ShareDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A ShareClient represents a URL to the Azure Storage share allowing you to manipulate its directories and files. * @@ -523,32 +555,40 @@ export class ShareClient extends StorageClient { /** * Creates a new share under the specified account. If the share with - * the same name already exists, it is not changed and the operation returns null. + * the same name already exists, it is not changed. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-share * * @param {ShareCreateOptions} [options] - * @returns {Promise} If the share already exists, returns null. + * @returns {Promise} * @memberof ShareClient */ public async createIfNotExists( options: ShareCreateOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "ShareClient-createIfNotExists", options.tracingOptions ); try { - return await this.create({ + const res = await this.create({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ShareAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, message: "Expected exception when creating a share only if it doesn't already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -842,25 +882,33 @@ export class ShareClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-share * * @param {ShareDeleteMethodOptions} [options] - * @returns {Promise} Return null if the share does not exist. + * @returns {Promise} * @memberof ShareClient */ public async deleteIfExists( options: ShareDeleteMethodOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan("ShareClient-deleteIfExists", options.tracingOptions); try { - return await this.delete({ + const res = await this.delete({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ShareNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, message: "Expected exception when deleting a share only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts index 39e67d748854..ca018b60e0e3 100644 --- a/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts +++ b/sdk/storage/storage-file-share/src/ShareDirectoryClient.ts @@ -68,7 +68,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti export interface DirectoryProperties extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -362,6 +362,38 @@ export interface DirectoryForceCloseHandlesOptions extends CommonOptions { abortSignal?: AbortSignalLike; } +/** + * Contains response data for the {@link DirectoryClient.createIfNotExists} operation. + * + * @export + * @interface DirectoryCreateIfNotExistsResponse + */ +export interface DirectoryCreateIfNotExistsResponse extends DirectoryCreateResponse { + /** + * Indicate whether the directory is successfully created. Is false when the directory is not changed as it already exists. + * + * @type {boolean} + * @memberof DirectoryCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link DirectoryClient.deleteIfExists} operation. + * + * @export + * @interface DirectoryDeleteIfExistsResponse + */ +export interface DirectoryDeleteIfExistsResponse extends DirectoryDeleteResponse { + /** + * Indicate whether the directory is successfully deleted. Is false if the directory does not exist in the first place. + * + * @type {boolean} + * @memberof DirectoryDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A ShareDirectoryClient represents a URL to the Azure Storage directory allowing you to manipulate its files and directories. * @@ -513,32 +545,40 @@ export class ShareDirectoryClient extends StorageClient { /** * Creates a new directory under the specified share or parent directory if it does not already exists. - * If the directory already exists, it is not modified and this operation returns null. + * If the directory already exists, it is not modified. * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-directory * * @param {DirectoryCreateOptions} [options] - * @returns {Promise} Returns null if the directory with the same name already exists. + * @returns {Promise} * @memberof ShareDirectoryClient */ public async createIfNotExists( options: DirectoryCreateOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "ShareDirectoryClient-createIfNotExists", options.tracingOptions ); try { - return await this.create({ + const res = await this.create({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ResourceAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, message: "Expected exception when creating a directory only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -907,28 +947,36 @@ export class ShareDirectoryClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory * * @param {DirectoryDeleteOptions} [options] - * @returns {Promise} Returns null if the directory doesn't exists. + * @returns {Promise} * @memberof ShareDirectoryClient */ public async deleteIfExists( options: DirectoryDeleteOptions = {} - ): Promise { + ): Promise { const { span, spanOptions } = createSpan( "ShareDirectoryClient-deleteIfExists", options.tracingOptions ); try { - return await this.delete({ + const res = await this.delete({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ResourceNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, message: "Expected exception when deleting a directory only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-file-share/src/ShareFileClient.ts b/sdk/storage/storage-file-share/src/ShareFileClient.ts index 179097b56e11..fc62dee30d0a 100644 --- a/sdk/storage/storage-file-share/src/ShareFileClient.ts +++ b/sdk/storage/storage-file-share/src/ShareFileClient.ts @@ -888,6 +888,22 @@ export interface FileDownloadToBufferOptions extends CommonOptions { leaseAccessConditions?: LeaseAccessConditions; } +/** + * Contains response data for the {@link ShareFileClient.deleteIfExists} operation. + * + * @export + * @interface FileDeleteIfExistsResponse + */ +export interface FileDeleteIfExistsResponse extends FileDeleteResponse { + /** + * Indicate whether the file is successfully deleted. Is false if the file does not exist in the first place. + * + * @type {boolean} + * @memberof FileDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A ShareFileClient represents a URL to an Azure Storage file. * @@ -1378,26 +1394,36 @@ export class ShareFileClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2 * * @param {FileDeleteOptions} [options] - * @returns {Promise} Return null if the file does not exist. + * @returns {Promise} * @memberof ShareFileClient */ - public async deleteIfExists(options: FileDeleteOptions = {}): Promise { + public async deleteIfExists( + options: FileDeleteOptions = {} + ): Promise { const { span, spanOptions } = createSpan( "ShareFileClient-deleteIfExists", options.tracingOptions ); try { - return await this.delete({ + const res = await this.delete({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "ResourceNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, message: "Expected exception when deleting a file only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-file-share/test/directoryclient.spec.ts b/sdk/storage/storage-file-share/test/directoryclient.spec.ts index 8e88963770ef..827509d99849 100644 --- a/sdk/storage/storage-file-share/test/directoryclient.spec.ts +++ b/sdk/storage/storage-file-share/test/directoryclient.spec.ts @@ -28,7 +28,7 @@ describe("DirectoryClient", () => { fullDirAttributes.notContentIndexed = true; fullDirAttributes.noScrubData = true; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); const serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -49,7 +49,7 @@ describe("DirectoryClient", () => { assert.ok(defaultDirCreateResp.filePermissionKey!); }); - afterEach(async function () { + afterEach(async function() { await shareClient.delete(); recorder.stop(); }); @@ -153,19 +153,26 @@ describe("DirectoryClient", () => { }); it("createIfNotExists", async () => { - await dirClient.createIfNotExists(); + const res = await dirClient.createIfNotExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "ResourceAlreadyExists"); const dirClient2 = shareClient.getDirectoryClient(recorder.getUniqueName(dirName)); - await dirClient2.createIfNotExists(); + const res2 = await dirClient2.createIfNotExists(); + assert.ok(res2.succeeded); + await dirClient2.delete(); }); it("deleteIfExists", async () => { const dirClient2 = shareClient.getDirectoryClient(recorder.getUniqueName(dirName)); - await dirClient2.deleteIfExists(); + const res = await dirClient2.deleteIfExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "ResourceNotFound"); await dirClient2.create(); - await dirClient2.deleteIfExists(); + const res2 = await dirClient2.deleteIfExists(); + assert.ok(res2.succeeded); }); it("exists", async () => { diff --git a/sdk/storage/storage-file-share/test/fileclient.spec.ts b/sdk/storage/storage-file-share/test/fileclient.spec.ts index 7b85b45b79fc..fddd84646f4c 100644 --- a/sdk/storage/storage-file-share/test/fileclient.spec.ts +++ b/sdk/storage/storage-file-share/test/fileclient.spec.ts @@ -40,7 +40,7 @@ describe("FileClient", () => { fullFileAttributes.notContentIndexed = true; fullFileAttributes.noScrubData = true; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); const serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -56,7 +56,7 @@ describe("FileClient", () => { fileClient = dirClient.getFileClient(fileName); }); - afterEach(async function () { + afterEach(async function() { if (!this.currentTest?.isPending()) { await shareClient.delete(); recorder.stop(); @@ -289,9 +289,13 @@ describe("FileClient", () => { }); it("deleteIfExists", async () => { - await fileClient.deleteIfExists(); + const res = await fileClient.deleteIfExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "ResourceNotFound"); + await fileClient.create(content.length); - await fileClient.deleteIfExists(); + const res2 = await fileClient.deleteIfExists(); + assert.ok(res2.succeeded); }); it("exists", async () => { @@ -545,7 +549,7 @@ describe("FileClient", () => { await fileClient.create(content.length); await fileClient.uploadRange(content, 0, content.length); const result = await fileClient.download(0, undefined, { - onProgress: () => { } + onProgress: () => {} }); assert.deepStrictEqual(await bodyToString(result), content); }); @@ -582,7 +586,7 @@ describe("FileClient", () => { const rs = result.readableStreamBody!; // tslint:disable-next-line:no-empty - rs.on("data", () => { }); + rs.on("data", () => {}); rs.on("end", resolve); rs.on("error", reject); } else { diff --git a/sdk/storage/storage-file-share/test/shareclient.spec.ts b/sdk/storage/storage-file-share/test/shareclient.spec.ts index 7a84869e0398..0b32922940ba 100644 --- a/sdk/storage/storage-file-share/test/shareclient.spec.ts +++ b/sdk/storage/storage-file-share/test/shareclient.spec.ts @@ -12,7 +12,7 @@ describe("ShareClient", () => { let recorder: Recorder; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); serviceClient = getBSU(); shareName = recorder.getUniqueName("share"); @@ -20,7 +20,7 @@ describe("ShareClient", () => { await shareClient.create(); }); - afterEach(async function () { + afterEach(async function() { await shareClient.delete(); recorder.stop(); }); @@ -69,9 +69,12 @@ describe("ShareClient", () => { it("createIfNotExists", async () => { const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); const res = await shareClient2.createIfNotExists(); - assert.notDeepStrictEqual(null, res); + assert.ok(res.succeeded); + const res2 = await shareClient2.createIfNotExists(); - assert.equal(null, res2); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "ShareAlreadyExists"); + await shareClient2.delete(); }); @@ -83,10 +86,13 @@ describe("ShareClient", () => { it("deleteIfExists", async () => { const shareClient2 = serviceClient.getShareClient(recorder.getUniqueName(shareName)); await shareClient2.create(); - await shareClient2.deleteIfExists(); + const res = await shareClient2.deleteIfExists(); + assert.ok(res.succeeded); - const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName + '3')); - await shareClient3.deleteIfExists(); + const shareClient3 = serviceClient.getShareClient(recorder.getUniqueName(shareName + "3")); + const res2 = await shareClient3.deleteIfExists(); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "ShareNotFound"); }); it("setQuota", async () => { From b9cee550460eba70f10c161ecee66e2f9842e9a7 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Mon, 29 Jun 2020 18:18:18 +0800 Subject: [PATCH 12/12] change return type - queue --- .../recording_createifnotexists.json | 57 +++-- .../queueclient/recording_deleteifexists.json | 48 ++--- .../recording_createifnotexists.js | 56 +++-- .../queueclient/recording_deleteifexists.js | 46 ++-- .../storage-queue/review/storage-queue.api.md | 14 +- sdk/storage/storage-queue/src/QueueClient.ts | 204 +++++++++++------- .../storage-queue/test/queueclient.spec.ts | 20 +- 7 files changed, 279 insertions(+), 166 deletions(-) diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json index 5bcfa7fa70ed..a67c07c8305f 100644 --- a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_createifnotexists.json @@ -2,7 +2,7 @@ "recordings": [ { "method": "PUT", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577431909488", "query": { "timeout": "30" }, @@ -11,16 +11,16 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:42 GMT", + "date": "Mon, 29 Jun 2020 10:16:13 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "493c1131-ba4a-4a01-8b64-3f88aa2ccb48", - "x-ms-request-id": "3d8b7a45-5003-001e-1ed9-2c4ed7000000", + "x-ms-client-request-id": "be9b39d5-c3a5-42e4-b449-e71f048b74a8", + "x-ms-request-id": "70214e7f-e003-0056-1ffe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577431909488", "query": { "timeout": "30" }, @@ -29,36 +29,54 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:42 GMT", + "date": "Mon, 29 Jun 2020 10:16:14 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "844535f0-6ff1-4d10-9910-a511869c3d4d", - "x-ms-request-id": "3d8b7c83-5003-001e-55d9-2c4ed7000000", + "x-ms-client-request-id": "a2689949-2795-48e9-b819-df52d9141a9f", + "x-ms-request-id": "70214f19-e003-0056-2dfe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577431909488", "query": { "timeout": "30" }, "requestBody": null, "status": 409, - "response": "QueueAlreadyExistsThe specified queue already exists.\nRequestId:3d8b80f1-5003-001e-30d9-2c4ed7000000\nTime:2020-05-18T05:58:43.7722180Z", + "response": "QueueAlreadyExistsThe specified queue already exists.\nRequestId:70214fe5-e003-0056-70fe-4d53e0000000\nTime:2020-06-29T10:16:14.8719699Z", "responseHeaders": { "content-length": "222", "content-type": "application/xml", - "date": "Mon, 18 May 2020 05:58:43 GMT", + "date": "Mon, 29 Jun 2020 10:16:14 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "af893455-8680-4268-9537-be4456ec2f18", + "x-ms-client-request-id": "10a4138e-8f79-4c20-bb51-eda3a103b852", "x-ms-error-code": "QueueAlreadyExists", - "x-ms-request-id": "3d8b80f1-5003-001e-30d9-2c4ed7000000", + "x-ms-request-id": "70214fe5-e003-0056-70fe-4d53e0000000", + "x-ms-version": "2019-07-07" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue2159342577667204259", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Mon, 29 Jun 2020 10:16:15 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "7fbcf3f1-3fd3-4287-9aef-e5885a24ffd2", + "x-ms-request-id": "702150c7-e003-0056-41fe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152434109586", + "url": "https://fakestorageaccount.queue.core.windows.net/queue2159342577667204259", "query": { "timeout": "30" }, @@ -67,19 +85,20 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:44 GMT", + "date": "Mon, 29 Jun 2020 10:16:15 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "93e45113-0f50-4158-8647-b0862a123933", - "x-ms-request-id": "3d8b8641-5003-001e-64d9-2c4ed7000000", + "x-ms-client-request-id": "883cb114-d954-4df1-89a4-af8bda6177e7", + "x-ms-request-id": "702151b2-e003-0056-0cfe-4d53e0000000", "x-ms-version": "2019-07-07" } } ], "uniqueTestInfo": { "uniqueName": { - "queue": "queue158978152434109586" + "queue": "queue159342577431909488", + "queue2": "queue2159342577667204259" }, "newDate": {} }, - "hash": "2dfd66cca269eb00ecd875c757db0440" + "hash": "a03546c79508e1fb32e3ed422a9ed14b" } \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json index 37d5320f4f44..c0a102dee134 100644 --- a/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient/recording_deleteifexists.json @@ -2,7 +2,7 @@ "recordings": [ { "method": "PUT", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577785407667", "query": { "timeout": "30" }, @@ -11,36 +11,36 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:44 GMT", + "date": "Mon, 29 Jun 2020 10:16:16 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "72ff95af-5bfa-4dcc-9281-c61a876b4e49", - "x-ms-request-id": "3d8b899b-5003-001e-2fd9-2c4ed7000000", + "x-ms-client-request-id": "1dc86cb2-5a55-4c6e-aba6-d6773a40a26b", + "x-ms-request-id": "70215285-e003-0056-43fe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577785407667159342577843803140", "query": { "timeout": "30" }, "requestBody": null, "status": 404, - "response": "QueueNotFoundThe specified queue does not exist.\nRequestId:3d8b8dc3-5003-001e-45d9-2c4ed7000000\nTime:2020-05-18T05:58:45.5314591Z", + "response": "QueueNotFoundThe specified queue does not exist.\nRequestId:7021536a-e003-0056-0bfe-4d53e0000000\nTime:2020-06-29T10:16:17.2616685Z", "responseHeaders": { "content-length": "217", "content-type": "application/xml", - "date": "Mon, 18 May 2020 05:58:45 GMT", + "date": "Mon, 29 Jun 2020 10:16:16 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "88ed4a52-0c97-48ef-ab30-6aee7f949cd1", + "x-ms-client-request-id": "568f0f16-1dff-4368-b7de-2a4041397071", "x-ms-error-code": "QueueNotFound", - "x-ms-request-id": "3d8b8dc3-5003-001e-45d9-2c4ed7000000", + "x-ms-request-id": "7021536a-e003-0056-0bfe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "PUT", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577785407667159342577843803140", "query": { "timeout": "30" }, @@ -49,16 +49,16 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:45 GMT", + "date": "Mon, 29 Jun 2020 10:16:17 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "47ee701b-0405-4d75-9604-ae1c9daf3909", - "x-ms-request-id": "3d8b92a0-5003-001e-03d9-2c4ed7000000", + "x-ms-client-request-id": "85ad7e4b-51e3-4ade-b647-4025281847a9", + "x-ms-request-id": "7021545f-e003-0056-6dfe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367158978152698101446", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577785407667159342577843803140", "query": { "timeout": "30" }, @@ -67,16 +67,16 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:46 GMT", + "date": "Mon, 29 Jun 2020 10:16:18 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "b3fb7bad-d544-4d6d-baa4-118cc2589d6a", - "x-ms-request-id": "3d8b9706-5003-001e-50d9-2c4ed7000000", + "x-ms-client-request-id": "68e7f866-fa15-4890-816b-66b84e5d9df6", + "x-ms-request-id": "70215558-e003-0056-4ffe-4d53e0000000", "x-ms-version": "2019-07-07" } }, { "method": "DELETE", - "url": "https://fakestorageaccount.queue.core.windows.net/queue158978152639806367", + "url": "https://fakestorageaccount.queue.core.windows.net/queue159342577785407667", "query": { "timeout": "30" }, @@ -85,20 +85,20 @@ "response": "", "responseHeaders": { "content-length": "0", - "date": "Mon, 18 May 2020 05:58:46 GMT", + "date": "Mon, 29 Jun 2020 10:16:18 GMT", "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "fd9ba84f-6259-4438-8361-d2b2906337bf", - "x-ms-request-id": "3d8b9b2c-5003-001e-64d9-2c4ed7000000", + "x-ms-client-request-id": "fcc348bd-2382-4cdf-b72e-6abc54ec9eb8", + "x-ms-request-id": "702155fa-e003-0056-63fe-4d53e0000000", "x-ms-version": "2019-07-07" } } ], "uniqueTestInfo": { "uniqueName": { - "queue": "queue158978152639806367", - "queue158978152639806367": "queue158978152639806367158978152698101446" + "queue": "queue159342577785407667", + "queue159342577785407667": "queue159342577785407667159342577843803140" }, "newDate": {} }, - "hash": "6a4f2d1b9350f0624e76226aa5bccfa5" + "hash": "ff6b00b1231848e190fff196dcfe94df" } \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js b/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js index 701288ae4f78..5c93f93b371e 100644 --- a/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js +++ b/sdk/storage/storage-queue/recordings/node/queueclient/recording_createifnotexists.js @@ -1,11 +1,11 @@ let nock = require('nock'); -module.exports.hash = "40ed65f81a62b4b9c0e44b0c82d4a02e"; +module.exports.hash = "92bb428ef916f02881e1e1e65360e11c"; -module.exports.testInfo = {"uniqueName":{"queue":"queue158978149547700911"},"newDate":{}} +module.exports.testInfo = {"uniqueName":{"queue":"queue159342573372108514","queue2":"queue2159342573572002007"},"newDate":{}} nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .put('/queue158978149547700911') + .put('/queue159342573372108514') .query(true) .reply(201, "", [ 'Content-Length', @@ -13,17 +13,17 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46faa11-8003-0050-79d9-2c605f000000', + 'b4018d72-b003-0006-80fe-4d91b0000000', 'x-ms-client-request-id', - '0351f48a-f4c4-43d1-98f9-ff6b62df0751', + '45162f72-d550-4a1d-a568-55c8edff79bb', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:13 GMT' + 'Mon, 29 Jun 2020 10:15:32 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .put('/queue158978149547700911') + .put('/queue159342573372108514') .query(true) .reply(204, "", [ 'Content-Length', @@ -31,19 +31,19 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fab08-8003-0050-62d9-2c605f000000', + 'b4018e84-b003-0006-80fe-4d91b0000000', 'x-ms-client-request-id', - 'd96c803b-f773-4ece-b9af-18ad3b7a69e4', + '5db6d0d1-40d6-4f3e-a210-dd0ab54a45b7', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:13 GMT' + 'Mon, 29 Jun 2020 10:15:32 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .put('/queue158978149547700911') + .put('/queue159342573372108514') .query(true) - .reply(409, "QueueAlreadyExistsThe specified queue already exists.\nRequestId:f46fac03-8003-0050-52d9-2c605f000000\nTime:2020-05-18T05:58:14.3411781Z", [ + .reply(409, "QueueAlreadyExistsThe specified queue already exists.\nRequestId:b4018fad-b003-0006-22fe-4d91b0000000\nTime:2020-06-29T10:15:33.9408867Z", [ 'Content-Length', '222', 'Content-Type', @@ -51,19 +51,37 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fac03-8003-0050-52d9-2c605f000000', + 'b4018fad-b003-0006-22fe-4d91b0000000', 'x-ms-client-request-id', - 'a425cd6c-4a10-4ec0-b87c-916af7d39185', + '6f861410-8cd7-408d-91db-16772fdab949', 'x-ms-version', '2019-07-07', 'x-ms-error-code', 'QueueAlreadyExists', 'Date', - 'Mon, 18 May 2020 05:58:14 GMT' + 'Mon, 29 Jun 2020 10:15:33 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/queue158978149547700911') + .put('/queue2159342573572002007') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + 'b401912f-b003-0006-14fe-4d91b0000000', + 'x-ms-client-request-id', + '8335994f-950a-4ccf-8a81-55f3fbf17b92', + 'x-ms-version', + '2019-07-07', + 'Date', + 'Mon, 29 Jun 2020 10:15:33 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue2159342573572002007') .query(true) .reply(204, "", [ 'Content-Length', @@ -71,11 +89,11 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46facf2-8003-0050-36d9-2c605f000000', + 'b4019261-b003-0006-3dfe-4d91b0000000', 'x-ms-client-request-id', - '62b3bb18-cc28-4e10-b6e0-070d3e352bb4', + '6984a66e-60e3-479a-b355-f560742c5ecd', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:14 GMT' + 'Mon, 29 Jun 2020 10:15:33 GMT' ]); diff --git a/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js b/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js index 68b9f9ee9c3d..5bdd47db6eda 100644 --- a/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js +++ b/sdk/storage/storage-queue/recordings/node/queueclient/recording_deleteifexists.js @@ -1,11 +1,11 @@ let nock = require('nock'); -module.exports.hash = "1aaaf9d056b4eabfcaa061f70b932ee7"; +module.exports.hash = "0fe0ca4b1f953636dbf73ff0a3b3e6c1"; -module.exports.testInfo = {"uniqueName":{"queue":"queue158978149667203283","queue158978149667203283":"queue158978149667203283158978149696809280"},"newDate":{}} +module.exports.testInfo = {"uniqueName":{"queue":"queue159342573634603293","queue159342573634603293":"queue159342573634603293159342573664608502"},"newDate":{}} nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .put('/queue158978149667203283') + .put('/queue159342573634603293') .query(true) .reply(201, "", [ 'Content-Length', @@ -13,19 +13,19 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fadea-8003-0050-25d9-2c605f000000', + 'b401936b-b003-0006-40fe-4d91b0000000', 'x-ms-client-request-id', - '97dba666-e09c-43ff-a6e9-8d1264da40a2', + 'aa162b01-9a15-48ab-a0bc-1e4e7c004136', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:14 GMT' + 'Mon, 29 Jun 2020 10:15:34 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/queue158978149667203283158978149696809280') + .delete('/queue159342573634603293159342573664608502') .query(true) - .reply(404, "QueueNotFoundThe specified queue does not exist.\nRequestId:f46faf0c-8003-0050-3dd9-2c605f000000\nTime:2020-05-18T05:58:15.2348136Z", [ + .reply(404, "QueueNotFoundThe specified queue does not exist.\nRequestId:b4019487-b003-0006-4cfe-4d91b0000000\nTime:2020-06-29T10:15:35.1767529Z", [ 'Content-Length', '217', 'Content-Type', @@ -33,19 +33,19 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46faf0c-8003-0050-3dd9-2c605f000000', + 'b4019487-b003-0006-4cfe-4d91b0000000', 'x-ms-client-request-id', - 'f2a699b8-2645-4d28-9303-0b42f19c0d1c', + 'acf75a5a-3726-4b29-89e3-befc555c4b2b', 'x-ms-version', '2019-07-07', 'x-ms-error-code', 'QueueNotFound', 'Date', - 'Mon, 18 May 2020 05:58:15 GMT' + 'Mon, 29 Jun 2020 10:15:34 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .put('/queue158978149667203283158978149696809280') + .put('/queue159342573634603293159342573664608502') .query(true) .reply(201, "", [ 'Content-Length', @@ -53,17 +53,17 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fb02b-8003-0050-4dd9-2c605f000000', + 'b401955c-b003-0006-1cfe-4d91b0000000', 'x-ms-client-request-id', - '3487828b-b346-4b88-9ce9-8a39413172af', + '106f8138-0c66-475d-b1e6-6c1d518e1cd8', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:15 GMT' + 'Mon, 29 Jun 2020 10:15:34 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/queue158978149667203283158978149696809280') + .delete('/queue159342573634603293159342573664608502') .query(true) .reply(204, "", [ 'Content-Length', @@ -71,17 +71,17 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fb0f6-8003-0050-0ed9-2c605f000000', + 'b4019653-b003-0006-03fe-4d91b0000000', 'x-ms-client-request-id', - 'fa2a9c75-74c3-4c61-8eb7-3443a601389a', + '8e671c7b-3eda-4e77-930e-90009cc08c58', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:15 GMT' + 'Mon, 29 Jun 2020 10:15:35 GMT' ]); nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) - .delete('/queue158978149667203283') + .delete('/queue159342573634603293') .query(true) .reply(204, "", [ 'Content-Length', @@ -89,11 +89,11 @@ nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryPara 'Server', 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id', - 'f46fb1dd-8003-0050-71d9-2c605f000000', + 'b4019771-b003-0006-1dfe-4d91b0000000', 'x-ms-client-request-id', - '2512a572-210b-40a8-a697-5dd82fcc8041', + '9cf65e2e-d43c-41fa-b154-64d4879ae7e0', 'x-ms-version', '2019-07-07', 'Date', - 'Mon, 18 May 2020 05:58:15 GMT' + 'Mon, 29 Jun 2020 10:15:35 GMT' ]); diff --git a/sdk/storage/storage-queue/review/storage-queue.api.md b/sdk/storage/storage-queue/review/storage-queue.api.md index 69cb13a5d812..9ae7358f0acb 100644 --- a/sdk/storage/storage-queue/review/storage-queue.api.md +++ b/sdk/storage/storage-queue/review/storage-queue.api.md @@ -357,9 +357,9 @@ export class QueueClient extends StorageClient { constructor(url: string, pipeline: Pipeline); clearMessages(options?: QueueClearMessagesOptions): Promise; create(options?: QueueCreateOptions): Promise; - createIfNotExists(options?: QueueCreateOptions): Promise; + createIfNotExists(options?: QueueCreateOptions): Promise; delete(options?: QueueDeleteOptions): Promise; - deleteIfExists(options?: QueueDeleteOptions): Promise; + deleteIfExists(options?: QueueDeleteOptions): Promise; deleteMessage(messageId: string, popReceipt: string, options?: QueueDeleteMessageOptions): Promise; exists(options?: QueueExistsOptions): Promise; getAccessPolicy(options?: QueueGetAccessPolicyOptions): Promise; @@ -383,6 +383,11 @@ export interface QueueCreateHeaders { version?: string; } +// @public +export interface QueueCreateIfNotExistsResponse extends QueueCreateResponse { + succeeded: boolean; +} + // @public export interface QueueCreateOptions extends CommonOptions { abortSignal?: AbortSignalLike; @@ -406,6 +411,11 @@ export interface QueueDeleteHeaders { version?: string; } +// @public +export interface QueueDeleteIfExistsResponse extends QueueDeleteResponse { + succeeded: boolean; +} + // @public export interface QueueDeleteMessageOptions extends CommonOptions { abortSignal?: AbortSignalLike; diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index f374e30e895b..dddcfe982cfa 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -210,24 +210,24 @@ export interface SignedIdentifier { export declare type QueueGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & QueueGetAccessPolicyHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: QueueGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: SignedIdentifierModel[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: QueueGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; + }; }; -}; /** * Options to configure {@link QueueClient.clearMessages} operation @@ -253,7 +253,7 @@ export interface QueueClearMessagesOptions extends CommonOptions { * @interface QueueSendMessageOptions * @extends {MessagesEnqueueOptionalParams} */ -export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions { } +export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions {} /** * Options to configure {@link QueueClient.receiveMessages} operation @@ -262,7 +262,7 @@ export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, * @interface QueueReceiveMessageOptions * @extends {MessagesDequeueOptionalParams} */ -export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions { } +export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions {} /** * Options to configure {@link QueueClient.peekMessages} operation @@ -271,7 +271,7 @@ export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParam * @interface QueuePeekMessagesOptions * @extends {MessagesPeekOptionalParams} */ -export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions { } +export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions {} /** * Contains the response data for the {@link QueueClient.sendMessage} operation. @@ -303,24 +303,24 @@ export declare type QueueSendMessageResponse = { */ nextVisibleOn: Date; } & MessagesEnqueueHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesEnqueueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: EnqueuedMessage[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesEnqueueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: EnqueuedMessage[]; + }; }; -}; /** * The object returned in the `receivedMessageItems` array when calling {@link QueueClient.receiveMessages}. @@ -335,24 +335,24 @@ export declare type ReceivedMessageItem = DequeuedMessageItem; export declare type QueueReceiveMessageResponse = { receivedMessageItems: ReceivedMessageItem[]; } & MessagesDequeueHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesDequeueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: ReceivedMessageItem[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesDequeueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: ReceivedMessageItem[]; + }; }; -}; /** * Contains the response data for the {@link QueueClient.peekMessages} operation. @@ -360,24 +360,24 @@ export declare type QueueReceiveMessageResponse = { export declare type QueuePeekMessagesResponse = { peekedMessageItems: PeekedMessageItem[]; } & MessagesPeekHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesPeekHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: PeekedMessageItem[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesPeekHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: PeekedMessageItem[]; + }; }; -}; /** * Options to configure the {@link QueueClient.deleteMessage} operation @@ -428,6 +428,38 @@ export interface QueueUpdateMessageOptions extends CommonOptions { abortSignal?: AbortSignalLike; } +/** + * Contains response data for the {@link QueueClient.createIfNotExists} operation. + * + * @export + * @interface QueueCreateIfNotExistsResponse + */ +export interface QueueCreateIfNotExistsResponse extends QueueCreateResponse { + /** + * Indicate whether the queue is successfully created. Is false when the queue is not changed as it already exists. + * + * @type {boolean} + * @memberof QueueCreateIfNotExistsResponse + */ + succeeded: boolean; +} + +/** + * Contains response data for the {@link QueueClient.deleteIfExists} operation. + * + * @export + * @interface QueueDeleteIfExistsResponse + */ +export interface QueueDeleteIfExistsResponse extends QueueDeleteResponse { + /** + * Indicate whether the queue is successfully deleted. Is false if the queue does not exist in the first place. + * + * @type {boolean} + * @memberof QueueDeleteIfExistsResponse + */ + succeeded: boolean; +} + /** * A QueueClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages. * @@ -631,11 +663,16 @@ export class QueueClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-queue4 * * @param {QueueCreateOptions} [options] - * @returns {Promise} Returns null if the queue already exists. + * @returns {Promise} * @memberof QueueClient */ - public async createIfNotExists(options: QueueCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("QueueClient-createIfNotExists", options.tracingOptions); + public async createIfNotExists( + options: QueueCreateOptions = {} + ): Promise { + const { span, spanOptions } = createSpan( + "QueueClient-createIfNotExists", + options.tracingOptions + ); try { const response = await this.create({ ...options, @@ -646,17 +683,28 @@ export class QueueClient extends StorageClient { // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned. // If the existing metadata does not match, the operation fails and status code 409 (Conflict) is returned. if (response._response.status == 204) { - return null; + return { + succeeded: false, + ...response + }; } - return response; + return { + succeeded: true, + ...response + }; } catch (e) { if (e.details?.errorCode === "QueueAlreadyExists") { span.setStatus({ code: CanonicalCode.ALREADY_EXISTS, message: "Expected exception when creating a queue only if it does not already exist." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } + span.setStatus({ code: CanonicalCode.UNKNOWN, message: e.message @@ -672,23 +720,33 @@ export class QueueClient extends StorageClient { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-queue3 * * @param {QueueDeleteOptions} [options] - * @returns {Promise} Returns null if the queue doesn't exists. + * @returns {Promise} * @memberof QueueClient */ - public async deleteIfExists(options: QueueDeleteOptions = {}): Promise { + public async deleteIfExists( + options: QueueDeleteOptions = {} + ): Promise { const { span, spanOptions } = createSpan("QueueClient-deleteIfExists", options.tracingOptions); try { - return await this.delete({ + const res = await this.delete({ ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } }); + return { + succeeded: true, + ...res + }; } catch (e) { if (e.details?.errorCode === "QueueNotFound") { span.setStatus({ code: CanonicalCode.NOT_FOUND, message: "Expected exception when deleting a queue only if it exists." }); - return null; + return { + succeeded: false, + ...e.response?.parsedHeaders, + _response: e.response + }; } span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-queue/test/queueclient.spec.ts b/sdk/storage/storage-queue/test/queueclient.spec.ts index d322e6281fdb..0d1d850cbfdd 100644 --- a/sdk/storage/storage-queue/test/queueclient.spec.ts +++ b/sdk/storage/storage-queue/test/queueclient.spec.ts @@ -15,7 +15,7 @@ describe("QueueClient", () => { let recorder: Recorder; - beforeEach(async function () { + beforeEach(async function() { recorder = record(this, recorderEnvSetup); queueServiceClient = getQSU(); queueName = recorder.getUniqueName("queue"); @@ -23,7 +23,7 @@ describe("QueueClient", () => { await queueClient.create(); }); - afterEach(async function () { + afterEach(async function() { await queueClient.delete(); recorder.stop(); }); @@ -105,19 +105,27 @@ describe("QueueClient", () => { it("createIfNotExists", async () => { const res = await queueClient.createIfNotExists(); - assert.equal(null, res); + assert.ok(!res.succeeded); const metadata = { key: "value" }; const res2 = await queueClient.createIfNotExists({ metadata }); - assert.equal(null, res2); + assert.ok(!res2.succeeded); + assert.equal(res2.errorCode, "QueueAlreadyExists"); + + queueClient = queueServiceClient.getQueueClient(recorder.getUniqueName("queue2")); + const res3 = await queueClient.createIfNotExists(); + assert.ok(res3.succeeded); }); it("deleteIfExists", async () => { const qClient = queueServiceClient.getQueueClient(recorder.getUniqueName(queueName)); - await qClient.deleteIfExists(); + const res = await qClient.deleteIfExists(); + assert.ok(!res.succeeded); + assert.equal(res.errorCode, "QueueNotFound"); await qClient.create(); - await qClient.deleteIfExists(); + const res2 = await qClient.deleteIfExists(); + assert.ok(res2.succeeded); }); it("delete", (done) => {