From 42c165c312c987fac39ccbcc70d6131479573015 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Mon, 29 Apr 2019 15:55:18 -0700 Subject: [PATCH 1/2] Rename clients from *URL => *Client --- sdk/storage/storage-blob/README.md | 34 +-- .../samples/javascript/advanced.js | 32 +-- .../storage-blob/samples/javascript/basic.js | 34 +-- .../samples/typescript/advanced.ts | 32 +-- .../storage-blob/samples/typescript/basic.ts | 32 +-- sdk/storage/storage-blob/src/Aborter.ts | 12 +- .../{AppendBlobURL.ts => AppendBlobClient.ts} | 79 +++---- .../src/{BlobURL.ts => BlobClient.ts} | 90 ++++---- .../{BlockBlobURL.ts => BlockBlobClient.ts} | 83 ++++---- .../{ContainerURL.ts => ContainerClient.ts} | 73 +++---- .../src/{PageBlobURL.ts => PageBlobClient.ts} | 91 ++++---- sdk/storage/storage-blob/src/Pipeline.ts | 4 +- .../src/{ServiceURL.ts => ServiceClient.ts} | 42 ++-- .../src/{StorageURL.ts => StorageClient.ts} | 16 +- .../src/credentials/TokenCredential.ts | 4 +- .../storage-blob/src/highlevel.browser.ts | 18 +- .../storage-blob/src/highlevel.common.ts | 2 +- .../storage-blob/src/highlevel.node.ts | 36 ++-- sdk/storage/storage-blob/src/index.browser.ts | 14 +- sdk/storage/storage-blob/src/index.ts | 14 +- .../storage-blob/src/utils/utils.common.ts | 6 +- sdk/storage/storage-blob/test/aborter.test.ts | 20 +- .../storage-blob/test/appendbloburl.test.ts | 34 +-- sdk/storage/storage-blob/test/bloburl.test.ts | 170 +++++++-------- .../storage-blob/test/blockbloburl.test.ts | 109 +++++----- .../test/browser/highlevel.browser.test.ts | 44 ++-- .../storage-blob/test/containerurl.test.ts | 192 +++++++++-------- .../test/node/blockbloburl.test.ts | 34 +-- .../test/node/containerurl.test.ts | 20 +- .../test/node/highlevel.node.test.ts | 149 ++++++++------ .../test/node/pagebloburl.test.ts | 59 +++--- .../storage-blob/test/node/sas.test.ts | 144 ++++++------- .../storage-blob/test/pagebloburl.test.ts | 102 ++++----- .../storage-blob/test/retrypolicy.test.ts | 42 ++-- .../storage-blob/test/serviceurl.test.ts | 50 ++--- .../storage-blob/test/specialnaming.test.ts | 194 +++++++++--------- .../storage-blob/test/utils/index.browser.ts | 14 +- sdk/storage/storage-blob/test/utils/index.ts | 14 +- 38 files changed, 1103 insertions(+), 1036 deletions(-) rename sdk/storage/storage-blob/src/{AppendBlobURL.ts => AppendBlobClient.ts} (72%) rename sdk/storage/storage-blob/src/{BlobURL.ts => BlobClient.ts} (92%) rename sdk/storage/storage-blob/src/{BlockBlobURL.ts => BlockBlobClient.ts} (85%) rename sdk/storage/storage-blob/src/{ContainerURL.ts => ContainerClient.ts} (93%) rename sdk/storage/storage-blob/src/{PageBlobURL.ts => PageBlobClient.ts} (86%) rename sdk/storage/storage-blob/src/{ServiceURL.ts => ServiceClient.ts} (87%) rename sdk/storage/storage-blob/src/{StorageURL.ts => StorageClient.ts} (91%) diff --git a/sdk/storage/storage-blob/README.md b/sdk/storage/storage-blob/README.md index 73fbabf9cd45..ee9344d4a128 100644 --- a/sdk/storage/storage-blob/README.md +++ b/sdk/storage/storage-blob/README.md @@ -118,7 +118,7 @@ For example, you can create following CORS settings for debugging. But please cu The Azure Storage SDK for JavaScript provides low-level and high-level APIs. -- ServiceURL, ContainerURL and BlobURL objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). +- BlobServiceClient, ContainerClient and BlobClient objects provide the low-level API functionality and map one-to-one to the [Azure Storage Blob REST APIs](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api). - The high-level APIs provide convenience abstractions such as uploading a large stream to a block blob (using multiple PutBlock requests). @@ -127,11 +127,11 @@ The Azure Storage SDK for JavaScript provides low-level and high-level APIs. ```javascript const { Aborter, - BlobURL, - BlockBlobURL, - ContainerURL, - ServiceURL, - StorageURL, + BlobClient, + BlobServiceClient, + BlockBlobClient, + ContainerClient, + StorageClient, SharedKeyCredential, AnonymousCredential, TokenCredential @@ -153,10 +153,10 @@ async function main() { const anonymousCredential = new AnonymousCredential(); // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline - const pipeline = StorageURL.newPipeline(sharedKeyCredential); + const pipeline = StorageClient.newPipeline(sharedKeyCredential); // List containers - const serviceURL = new ServiceURL( + const blobServiceClient = new BlobServiceClient( // When using AnonymousCredential, following url should include a valid SAS or support public access `https://${account}.blob.core.windows.net`, pipeline @@ -164,7 +164,7 @@ async function main() { let marker; do { - const listContainersResponse = await serviceURL.listContainersSegment( + const listContainersResponse = await blobServiceClient.listContainersSegment( Aborter.none, marker ); @@ -177,9 +177,9 @@ async function main() { // Create a container const containerName = `newcontainer${new Date().getTime()}`; - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - const createContainerResponse = await containerURL.create(Aborter.none); + const createContainerResponse = await containerClient.create(Aborter.none); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -188,9 +188,9 @@ async function main() { // Create a blob const content = "hello"; const blobName = "newblob" + new Date().getTime(); - const blobURL = BlobURL.fromContainerURL(containerURL, blobName); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - const uploadBlobResponse = await blockBlobURL.upload( + const blobClient = BlobClient.fromContainerClient(containerClient, blobName); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + const uploadBlobResponse = await blockBlobClient.upload( Aborter.none, content, content.length @@ -203,7 +203,7 @@ async function main() { // List blobs marker = undefined; do { - const listBlobsResponse = await containerURL.listBlobFlatSegment( + const listBlobsResponse = await containerClient.listBlobFlatSegment( Aborter.none, marker ); @@ -217,14 +217,14 @@ async function main() { // Get blob content from position 0 to the end // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody - const downloadBlockBlobResponse = await blobURL.download(Aborter.none, 0); + const downloadBlockBlobResponse = await blobClient.download(Aborter.none, 0); console.log( "Downloaded blob content", await streamToString(downloadBlockBlobResponse.readableStreamBody) ); // Delete container - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/javascript/advanced.js b/sdk/storage/storage-blob/samples/javascript/advanced.js index a605271784f0..5fff6be96e40 100644 --- a/sdk/storage/storage-blob/samples/javascript/advanced.js +++ b/sdk/storage/storage-blob/samples/javascript/advanced.js @@ -10,11 +10,11 @@ const { uploadFileToBlockBlob, uploadStreamToBlockBlob, Aborter, - BlobURL, - BlockBlobURL, - ContainerURL, - ServiceURL, - StorageURL + BlobClient, + BlobServiceClient, + BlockBlobClient, + ContainerClient, + StorageClient } = require("../.."); // Change to "@azure/storage-blob" in your package async function main() { @@ -23,31 +23,31 @@ async function main() { const accountSas = ""; const localFilePath = ""; - const pipeline = StorageURL.newPipeline(new AnonymousCredential(), { + const pipeline = StorageClient.newPipeline(new AnonymousCredential(), { // httpClient: MyHTTPClient, // A customized HTTP client implementing IHttpClient interface // logger: MyLogger, // A customized logger implementing IHttpPipelineLogger interface retryOptions: { maxTries: 4 }, // Retry options telemetry: { value: "HighLevelSample V1.0.0" } // Customized telemetry string }); - const serviceURL = new ServiceURL( + const blobServiceClient = new BlobServiceClient( `https://${account}.blob.core.windows.net${accountSas}`, pipeline ); // Create a container const containerName = `newcontainer${new Date().getTime()}`; - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); + await containerClient.create(Aborter.none); // Create a blob const blobName = "newblob" + new Date().getTime(); - const blobURL = BlobURL.fromContainerURL(containerURL, blobName); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + const blobClient = BlobClient.fromContainerClient(containerClient, blobName); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); // Parallel uploading with uploadFileToBlockBlob in Node.js runtime // uploadFileToBlockBlob is only available in Node.js - await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobURL, { + await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -59,7 +59,7 @@ async function main() { await uploadStreamToBlockBlob( Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), - blockBlobURL, + blockBlobClient, 4 * 1024 * 1024, 20, { @@ -72,7 +72,7 @@ async function main() { // Uncomment following code in browsers because uploadBrowserDataToBlockBlob is only available in browsers /* const browserFile = document.getElementById("fileinput").files[0]; - await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobURL, { + await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -86,7 +86,7 @@ async function main() { await downloadBlobToBuffer( Aborter.timeout(30 * 60 * 1000), buffer, - blockBlobURL, + blockBlobClient, 0, undefined, { @@ -98,7 +98,7 @@ async function main() { console.log("downloadBlobToBuffer success"); // Delete container - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/javascript/basic.js b/sdk/storage/storage-blob/samples/javascript/basic.js index e753d2d0850d..13f3ad085eae 100644 --- a/sdk/storage/storage-blob/samples/javascript/basic.js +++ b/sdk/storage/storage-blob/samples/javascript/basic.js @@ -4,11 +4,11 @@ const { Aborter, - BlobURL, - BlockBlobURL, - ContainerURL, - ServiceURL, - StorageURL, + BlobClient, + BlockBlobClient, + ContainerClient, + BlobServiceClient, + StorageClient, SharedKeyCredential, AnonymousCredential, TokenCredential @@ -30,10 +30,10 @@ async function main() { const anonymousCredential = new AnonymousCredential(); // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline - const pipeline = StorageURL.newPipeline(sharedKeyCredential); + const pipeline = StorageClient.newPipeline(sharedKeyCredential); // List containers - const serviceURL = new ServiceURL( + const blobServiceClient = new BlobServiceClient( // When using AnonymousCredential, following url should include a valid SAS or support public access `https://${account}.blob.core.windows.net`, pipeline @@ -41,7 +41,7 @@ async function main() { let marker; do { - const listContainersResponse = await serviceURL.listContainersSegment( + const listContainersResponse = await blobServiceClient.listContainersSegment( Aborter.none, marker ); @@ -54,9 +54,9 @@ async function main() { // Create a container const containerName = `newcontainer${new Date().getTime()}`; - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + const containerClient = ContainerClient.fromBlobServiceClient(blobServiceClient, containerName); - const createContainerResponse = await containerURL.create(Aborter.none); + const createContainerResponse = await containerClient.create(Aborter.none); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -65,9 +65,9 @@ async function main() { // Create a blob const content = "hello"; const blobName = "newblob" + new Date().getTime(); - const blobURL = BlobURL.fromContainerURL(containerURL, blobName); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - const uploadBlobResponse = await blockBlobURL.upload( + const blobClient = BlobClient.fromContainerClient(containerClient, blobName); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + const uploadBlobResponse = await blockBlobClient.upload( Aborter.none, content, content.length @@ -80,7 +80,7 @@ async function main() { // List blobs marker = undefined; do { - const listBlobsResponse = await containerURL.listBlobFlatSegment( + const listBlobsResponse = await containerClient.listBlobFlatSegment( Aborter.none, marker ); @@ -94,14 +94,14 @@ async function main() { // Get blob content from position 0 to the end // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody - const downloadBlockBlobResponse = await blobURL.download(Aborter.none, 0); + const downloadBlockBlobResponse = await blobClient.download(Aborter.none, 0); console.log( "Downloaded blob content", await streamToString(downloadBlockBlobResponse.readableStreamBody) ); // Delete container - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); console.log("deleted container"); } @@ -127,4 +127,4 @@ main() }) .catch(err => { console.log(err.message); - }); \ No newline at end of file + }); diff --git a/sdk/storage/storage-blob/samples/typescript/advanced.ts b/sdk/storage/storage-blob/samples/typescript/advanced.ts index c9081e0c5717..da783201abb0 100644 --- a/sdk/storage/storage-blob/samples/typescript/advanced.ts +++ b/sdk/storage/storage-blob/samples/typescript/advanced.ts @@ -9,11 +9,11 @@ import { uploadFileToBlockBlob, uploadStreamToBlockBlob, Aborter, - BlobURL, - BlockBlobURL, - ContainerURL, - ServiceURL, - StorageURL + BlobClient, + BlockBlobClient, + ContainerClient, + ServiceClient, + StorageClient } from "../.."; // Change to "@azure/storage-blob" in your package async function main() { @@ -22,31 +22,31 @@ async function main() { const accountSas = ""; const localFilePath = ""; - const pipeline = StorageURL.newPipeline(new AnonymousCredential(), { + const pipeline = StorageClient.newPipeline(new AnonymousCredential(), { // httpClient: MyHTTPClient, // A customized HTTP client implementing IHttpClient interface // logger: MyLogger, // A customized logger implementing IHttpPipelineLogger interface retryOptions: { maxTries: 4 }, // Retry options telemetry: { value: "HighLevelSample V1.0.0" } // Customized telemetry string }); - const serviceURL = new ServiceURL( + const serviceClient = new ServiceClient( `https://${account}.blob.core.windows.net${accountSas}`, pipeline ); // Create a container const containerName = `newcontainer${new Date().getTime()}`; - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); // Create a blob const blobName = "newblob" + new Date().getTime(); - const blobURL = BlobURL.fromContainerURL(containerURL, blobName); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + const blobClient = BlobClient.fromContainerClient(containerClient, blobName); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); // Parallel uploading with uploadFileToBlockBlob in Node.js runtime // uploadFileToBlockBlob is only available in Node.js - await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobURL, { + await uploadFileToBlockBlob(Aborter.none, localFilePath, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -58,7 +58,7 @@ async function main() { await uploadStreamToBlockBlob( Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins fs.createReadStream(localFilePath), - blockBlobURL, + blockBlobClient, 4 * 1024 * 1024, 20, { @@ -71,7 +71,7 @@ async function main() { // Uncomment following code in browsers because uploadBrowserDataToBlockBlob is only available in browsers /* const browserFile = document.getElementById("fileinput").files[0]; - await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobURL, { + await uploadBrowserDataToBlockBlob(Aborter.none, browserFile, blockBlobClient, { blockSize: 4 * 1024 * 1024, // 4MB block size parallelism: 20, // 20 concurrency progress: ev => console.log(ev) @@ -85,7 +85,7 @@ async function main() { await downloadBlobToBuffer( Aborter.timeout(30 * 60 * 1000), buffer, - blockBlobURL, + blockBlobClient, 0, undefined, { @@ -97,7 +97,7 @@ async function main() { console.log("downloadBlobToBuffer success"); // Delete container - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/samples/typescript/basic.ts b/sdk/storage/storage-blob/samples/typescript/basic.ts index 4ca2bb6ed06d..0c98557acb18 100644 --- a/sdk/storage/storage-blob/samples/typescript/basic.ts +++ b/sdk/storage/storage-blob/samples/typescript/basic.ts @@ -4,11 +4,11 @@ import { Aborter, - BlobURL, - BlockBlobURL, - ContainerURL, - ServiceURL, - StorageURL, + BlobClient, + BlockBlobClient, + ContainerClient, + ServiceClient, + StorageClient, SharedKeyCredential, TokenCredential, Models @@ -30,10 +30,10 @@ async function main() { // const anonymousCredential = new AnonymousCredential(); // Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline - const pipeline = StorageURL.newPipeline(sharedKeyCredential); + const pipeline = StorageClient.newPipeline(sharedKeyCredential); // List containers - const serviceURL = new ServiceURL( + const serviceClient = new ServiceClient( // When using AnonymousCredential, following url should include a valid SAS or support public access `https://${account}.blob.core.windows.net`, pipeline @@ -41,7 +41,7 @@ async function main() { let marker; do { - const listContainersResponse: Models.ServiceListContainersSegmentResponse = await serviceURL.listContainersSegment( + const listContainersResponse: Models.ServiceListContainersSegmentResponse = await serviceClient.listContainersSegment( Aborter.none, marker ); @@ -54,9 +54,9 @@ async function main() { // Create a container const containerName = `newcontainer${new Date().getTime()}`; - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); - const createContainerResponse = await containerURL.create(Aborter.none); + const createContainerResponse = await containerClient.create(Aborter.none); console.log( `Create container ${containerName} successfully`, createContainerResponse.requestId @@ -65,9 +65,9 @@ async function main() { // Create a blob const content = "hello"; const blobName = "newblob" + new Date().getTime(); - const blobURL = BlobURL.fromContainerURL(containerURL, blobName); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - const uploadBlobResponse = await blockBlobURL.upload( + const blobClient = BlobClient.fromContainerClient(containerClient, blobName); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + const uploadBlobResponse = await blockBlobClient.upload( Aborter.none, content, content.length @@ -80,7 +80,7 @@ async function main() { // List blobs marker = undefined; do { - const listBlobsResponse: Models.ContainerListBlobFlatSegmentResponse = await containerURL.listBlobFlatSegment( + const listBlobsResponse: Models.ContainerListBlobFlatSegmentResponse = await containerClient.listBlobFlatSegment( Aborter.none, marker ); @@ -94,7 +94,7 @@ async function main() { // Get blob content from position 0 to the end // In Node.js, get downloaded data by accessing downloadBlockBlobResponse.readableStreamBody // In browsers, get downloaded data by accessing downloadBlockBlobResponse.blobBody - const downloadBlockBlobResponse: Models.BlobDownloadResponse = await blobURL.download( + const downloadBlockBlobResponse: Models.BlobDownloadResponse = await blobClient.download( Aborter.none, 0 ); @@ -104,7 +104,7 @@ async function main() { ); // Delete container - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); console.log("deleted container"); } diff --git a/sdk/storage/storage-blob/src/Aborter.ts b/sdk/storage/storage-blob/src/Aborter.ts index f4048e0cd6c1..4b3d3d8e42e4 100644 --- a/sdk/storage/storage-blob/src/Aborter.ts +++ b/sdk/storage/storage-blob/src/Aborter.ts @@ -14,18 +14,18 @@ import { AbortSignalLike, isNode } from "@azure/ms-rest-js"; * * @example * // Abort without timeout - * await blockBlobURL.upload(Aborter.none, buf, buf.length); + * await blockBlobClient.upload(Aborter.none, buf, buf.length); * * @example * // Abort container create in 1000ms - * await blockBlobURL.upload(Aborter.timeout(1000), buf, buf.length); + * await blockBlobClient.upload(Aborter.timeout(1000), buf, buf.length); * * @example * // Share aborter cross multiple operations in 30s * // Upload the same data to 2 different data centers at the same time, abort another when any of them is finished * const aborter = Aborter.timeout(30 * 1000); - * blockBlobURL1.upload(aborter, buf, buf.length).then(aborter.abort); - * blockBlobURL2.upload(aborter, buf, buf.length).then(aborter.abort); + * blockBlobClient1.upload(aborter, buf, buf.length).then(aborter.abort); + * blockBlobClient2.upload(aborter, buf, buf.length).then(aborter.abort); * * @example * // Cascaded aborting @@ -33,8 +33,8 @@ import { AbortSignalLike, isNode } from "@azure/ms-rest-js"; * const aborter = Aborter.timeout(30 * 1000); * * // Following 2 operations can't take more than 25 seconds - * await blockBlobURL.upload(aborter.withTimeout(25 * 1000), buf, buf.length); - * await blockBlobURL.upload(aborter.withTimeout(25 * 1000), buf, buf.length); + * await blockBlobClient.upload(aborter.withTimeout(25 * 1000), buf, buf.length); + * await blockBlobClient.upload(aborter.withTimeout(25 * 1000), buf, buf.length); * * @export * @class Aborter diff --git a/sdk/storage/storage-blob/src/AppendBlobURL.ts b/sdk/storage/storage-blob/src/AppendBlobClient.ts similarity index 72% rename from sdk/storage/storage-blob/src/AppendBlobURL.ts rename to sdk/storage/storage-blob/src/AppendBlobClient.ts index 2965e9620ab9..bac431bc2219 100644 --- a/sdk/storage/storage-blob/src/AppendBlobURL.ts +++ b/sdk/storage/storage-blob/src/AppendBlobClient.ts @@ -1,9 +1,9 @@ import { HttpRequestBody, TransferProgressEvent } from "@azure/ms-rest-js"; -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; -import { BlobURL } from "./BlobURL"; -import { ContainerURL } from "./ContainerURL"; +import { BlobClient } from "./BlobClient"; +import { ContainerClient } from "./ContainerClient"; import { AppendBlob } from "./generated/lib/operations"; import { IAppendBlobAccessConditions, IBlobAccessConditions, IMetadata } from "./models"; import { Pipeline } from "./Pipeline"; @@ -23,39 +23,42 @@ export interface IAppendBlobAppendBlockOptions { } /** - * AppendBlobURL defines a set of operations applicable to append blobs. + * AppendBlobClient defines a set of operations applicable to append blobs. * * @export - * @class AppendBlobURL - * @extends {StorageURL} + * @class AppendBlobClient + * @extends {StorageClient} */ -export class AppendBlobURL extends BlobURL { +export class AppendBlobClient extends BlobClient { /** - * Creates a AppendBlobURL object from ContainerURL instance. + * Creates a AppendBlobClient object from ContainerClient instance. * * @static - * @param {ContainerURL} containerURL A ContainerURL object + * @param {ContainerClient} containerClient A ContainerClient object * @param {string} blobName An append blob name - * @returns {AppendBlobURL} - * @memberof AppendBlobURL + * @returns {AppendBlobClient} + * @memberof AppendBlobClient */ - public static fromContainerURL(containerURL: ContainerURL, blobName: string): AppendBlobURL { - return new AppendBlobURL( - appendToURLPath(containerURL.url, encodeURIComponent(blobName)), - containerURL.pipeline + public static fromContainerClient( + containerClient: ContainerClient, + blobName: string + ): AppendBlobClient { + return new AppendBlobClient( + appendToURLPath(containerClient.url, encodeURIComponent(blobName)), + containerClient.pipeline ); } /** - * Creates a AppendBlobURL object from BlobURL instance. + * Creates a AppendBlobClient object from BlobClient instance. * * @static - * @param {BlobURL} blobURL - * @returns {AppendBlobURL} - * @memberof AppendBlobURL + * @param {BlobClient} blobClient + * @returns {AppendBlobClient} + * @memberof AppendBlobClient */ - public static fromBlobURL(blobURL: BlobURL): AppendBlobURL { - return new AppendBlobURL(blobURL.url, blobURL.pipeline); + public static fromBlobClient(blobClient: BlobClient): AppendBlobClient { + return new AppendBlobClient(blobClient.url, blobClient.pipeline); } /** @@ -63,12 +66,12 @@ export class AppendBlobURL extends BlobURL { * * @private * @type {AppendBlobs} - * @memberof AppendBlobURL + * @memberof AppendBlobClient */ private appendBlobContext: AppendBlob; /** - * Creates an instance of AppendBlobURL. + * Creates an instance of AppendBlobClient. * This method accepts an encoded URL or non-encoded URL pointing to an append blob. * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * If a blob name includes ? or %, blob name must be encoded in the URL. @@ -81,9 +84,9 @@ export class AppendBlobURL extends BlobURL { * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * However, if a blob name includes ? or %, blob name must be encoded in the URL. * Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof AppendBlobURL + * @memberof AppendBlobClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -91,28 +94,28 @@ export class AppendBlobURL extends BlobURL { } /** - * Creates a new AppendBlobURL object identical to the source but with the + * Creates a new AppendBlobClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {AppendBlobURL} - * @memberof AppendBlobURL + * @returns {AppendBlobClient} + * @memberof AppendBlobClient */ - public withPipeline(pipeline: Pipeline): AppendBlobURL { - return new AppendBlobURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): AppendBlobClient { + return new AppendBlobClient(this.url, pipeline); } /** - * Creates a new AppendBlobURL object identical to the source but with the + * Creates a new AppendBlobClient object identical to the source but with the * specified snapshot timestamp. - * Provide "" will remove the snapshot and return a URL to the base blob. + * Provide "" will remove the snapshot and return a Client to the base blob. * * @param {string} snapshot - * @returns {AppendBlobURL} - * @memberof AppendBlobURL + * @returns {AppendBlobClient} + * @memberof AppendBlobClient */ - public withSnapshot(snapshot: string): AppendBlobURL { - return new AppendBlobURL( + public withSnapshot(snapshot: string): AppendBlobClient { + return new AppendBlobClient( setURLParameter( this.url, URLConstants.Parameters.SNAPSHOT, @@ -130,7 +133,7 @@ export class AppendBlobURL extends BlobURL { * goto documents of Aborter for more examples about request cancellation * @param {IAppendBlobCreateOptions} [options] * @returns {Promise} - * @memberof AppendBlobURL + * @memberof AppendBlobClient */ public async create( aborter: Aborter, @@ -156,7 +159,7 @@ export class AppendBlobURL extends BlobURL { * @param {number} contentLength * @param {IAppendBlobAppendBlockOptions} [options] * @returns {Promise} - * @memberof AppendBlobURL + * @memberof AppendBlobClient */ public async appendBlock( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/BlobURL.ts b/sdk/storage/storage-blob/src/BlobClient.ts similarity index 92% rename from sdk/storage/storage-blob/src/BlobURL.ts rename to sdk/storage/storage-blob/src/BlobClient.ts index 469de7fe1d74..78a63365b6ca 100644 --- a/sdk/storage/storage-blob/src/BlobURL.ts +++ b/sdk/storage/storage-blob/src/BlobClient.ts @@ -1,14 +1,14 @@ import { isNode, TransferProgressEvent } from "@azure/ms-rest-js"; -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; import { BlobDownloadResponse } from "./BlobDownloadResponse"; -import { ContainerURL } from "./ContainerURL"; +import { ContainerClient } from "./ContainerClient"; import { Blob } from "./generated/lib/operations"; import { rangeToString } from "./IRange"; import { IBlobAccessConditions, IMetadata } from "./models"; import { Pipeline } from "./Pipeline"; -import { StorageURL } from "./StorageURL"; +import { StorageClient } from "./StorageClient"; import { DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, URLConstants } from "./utils/constants"; import { appendToURLPath, setURLParameter } from "./utils/utils.common"; @@ -25,7 +25,7 @@ export interface IBlobDownloadOptions { * Above kind of ends will not trigger retry policy defined in a pipeline, * because they doesn't emit network errors. * - * With this option, every additional retry means an additional FileURL.download() request will be made + * With this option, every additional retry means an additional FileClient.download() request will be made * from the broken point, until the requested range has been successfully downloaded or maxRetryRequests is reached. * * Default value is 5, please set a larger value when loading large files in poor network. @@ -93,27 +93,27 @@ export interface IBlobSetTierOptions { } /** - * A BlobURL represents a URL to an Azure Storage blob; the blob may be a block blob, + * A BlobClient represents a URL to an Azure Storage blob; the blob may be a block blob, * append blob, or page blob. * * @export - * @class BlobURL - * @extends {StorageURL} + * @class BlobClient + * @extends {StorageClient} */ -export class BlobURL extends StorageURL { +export class BlobClient extends StorageClient { /** - * Creates a BlobURL object from an ContainerURL object. + * Creates a BlobClient object from an ContainerClient object. * * @static - * @param {ContainerURL} containerURL A ContainerURL object + * @param {ContainerClient} containerClient A ContainerClient object * @param {string} blobName A blob name * @returns - * @memberof BlobURL + * @memberof BlobClient */ - public static fromContainerURL(containerURL: ContainerURL, blobName: string) { - return new BlobURL( - appendToURLPath(containerURL.url, encodeURIComponent(blobName)), - containerURL.pipeline + public static fromContainerClient(containerClient: ContainerClient, blobName: string) { + return new BlobClient( + appendToURLPath(containerClient.url, encodeURIComponent(blobName)), + containerClient.pipeline ); } @@ -122,12 +122,12 @@ export class BlobURL extends StorageURL { * * @private * @type {Blobs} - * @memberof BlobURL + * @memberof BlobClient */ private blobContext: Blob; /** - * Creates an instance of BlobURL. + * Creates an instance of BlobClient. * This method accepts an encoded URL or non-encoded URL pointing to a blob. * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * If a blob name includes ? or %, blob name must be encoded in the URL. @@ -140,9 +140,9 @@ export class BlobURL extends StorageURL { * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * However, if a blob name includes ? or %, blob name must be encoded in the URL. * Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof BlobURL + * @memberof BlobClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -150,27 +150,27 @@ export class BlobURL extends StorageURL { } /** - * Creates a new BlobURL object identical to the source but with the + * Creates a new BlobClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {BlobURL} - * @memberof BlobURL + * @returns {BlobClient} + * @memberof BlobClient */ - public withPipeline(pipeline: Pipeline): BlobURL { - return new BlobURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): BlobClient { + return new BlobClient(this.url, pipeline); } /** - * Creates a new BlobURL object identical to the source but with the specified snapshot timestamp. - * Provide "" will remove the snapshot and return a URL to the base blob. + * Creates a new BlobClient object identical to the source but with the specified snapshot timestamp. + * Provide "" will remove the snapshot and return a Client to the base blob. * * @param {string} snapshot - * @returns {BlobURL} A new BlobURL object identical to the source but with the specified snapshot timestamp - * @memberof BlobURL + * @returns {BlobClient} A new BlobClient object identical to the source but with the specified snapshot timestamp + * @memberof BlobClient */ - public withSnapshot(snapshot: string): BlobURL { - return new BlobURL( + public withSnapshot(snapshot: string): BlobClient { + return new BlobClient( setURLParameter( this.url, URLConstants.Parameters.SNAPSHOT, @@ -195,7 +195,7 @@ export class BlobURL extends StorageURL { * @param {number} [count] How much data to be downloaded, > 0. Will download to the end when undefined * @param {IBlobDownloadOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async download( aborter: Aborter, @@ -291,7 +291,7 @@ export class BlobURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IBlobGetPropertiesOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async getProperties( aborter: Aborter, @@ -316,7 +316,7 @@ export class BlobURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IBlobDeleteOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async delete( aborter: Aborter, @@ -340,7 +340,7 @@ export class BlobURL extends StorageURL { * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async undelete(aborter: Aborter): Promise { return this.blobContext.undelete({ @@ -362,7 +362,7 @@ export class BlobURL extends StorageURL { * headers without a value will be cleared. * @param {IBlobSetHTTPHeadersOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async setHTTPHeaders( aborter: Aborter, @@ -391,7 +391,7 @@ export class BlobURL extends StorageURL { * If no value provided the existing metadata will be removed. * @param {IBlobSetMetadataOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async setMetadata( aborter: Aborter, @@ -419,7 +419,7 @@ export class BlobURL extends StorageURL { * @param {number} duration The lock duration can be 15 to 60 seconds, or can be infinite * @param {IBlobAcquireLeaseOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async acquireLease( aborter: Aborter, @@ -445,7 +445,7 @@ export class BlobURL extends StorageURL { * @param {string} leaseId * @param {IBlobReleaseLeaseOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async releaseLease( aborter: Aborter, @@ -467,7 +467,7 @@ export class BlobURL extends StorageURL { * @param {string} leaseId * @param {IBlobRenewLeaseOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async renewLease( aborter: Aborter, @@ -490,7 +490,7 @@ export class BlobURL extends StorageURL { * @param {string} proposedLeaseId * @param {IBlobChangeLeaseOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async changeLease( aborter: Aborter, @@ -514,7 +514,7 @@ export class BlobURL extends StorageURL { * @param {number} [breakPeriod] * @param {IBlobBreakLeaseOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async breakLease( aborter: Aborter, @@ -536,7 +536,7 @@ export class BlobURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IBlobCreateSnapshotOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async createSnapshot( aborter: Aborter, @@ -566,7 +566,7 @@ export class BlobURL extends StorageURL { * @param {string} copySource * @param {IBlobStartCopyFromURLOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async startCopyFromURL( aborter: Aborter, @@ -600,7 +600,7 @@ export class BlobURL extends StorageURL { * @param {string} copyId * @param {IBlobAbortCopyFromURLOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async abortCopyFromURL( aborter: Aborter, @@ -626,7 +626,7 @@ export class BlobURL extends StorageURL { * @param {Models.AccessTier} tier * @param {IBlobSetTierOptions} [options] * @returns {Promise} - * @memberof BlobURL + * @memberof BlobClient */ public async setTier( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/BlockBlobURL.ts b/sdk/storage/storage-blob/src/BlockBlobClient.ts similarity index 85% rename from sdk/storage/storage-blob/src/BlockBlobURL.ts rename to sdk/storage/storage-blob/src/BlockBlobClient.ts index d8a2c09d3475..6460323e3978 100644 --- a/sdk/storage/storage-blob/src/BlockBlobURL.ts +++ b/sdk/storage/storage-blob/src/BlockBlobClient.ts @@ -1,9 +1,9 @@ import { HttpRequestBody, TransferProgressEvent } from "@azure/ms-rest-js"; -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; -import { BlobURL } from "./BlobURL"; -import { ContainerURL } from "./ContainerURL"; +import { BlobClient } from "./BlobClient"; +import { ContainerClient } from "./ContainerClient"; import { BlockBlob } from "./generated/lib/operations"; import { IRange, rangeToString } from "./IRange"; import { IBlobAccessConditions, IMetadata } from "./models"; @@ -41,39 +41,42 @@ export interface IBlockBlobGetBlockListOptions { } /** - * BlockBlobURL defines a set of operations applicable to block blobs. + * BlockBlobClient defines a set of operations applicable to block blobs. * * @export - * @class BlockBlobURL - * @extends {StorageURL} + * @class BlockBlobClient + * @extends {StorageClient} */ -export class BlockBlobURL extends BlobURL { +export class BlockBlobClient extends BlobClient { /** - * Creates a BlockBlobURL object from ContainerURL instance. + * Creates a BlockBlobClient object from ContainerClient instance. * * @static - * @param {ContainerURL} containerURL A ContainerURL object + * @param {ContainerClient} containerClient A ContainerClient object * @param {string} blobName A block blob name - * @returns {BlockBlobURL} - * @memberof BlockBlobURL + * @returns {BlockBlobClient} + * @memberof BlockBlobClient */ - public static fromContainerURL(containerURL: ContainerURL, blobName: string): BlockBlobURL { - return new BlockBlobURL( - appendToURLPath(containerURL.url, encodeURIComponent(blobName)), - containerURL.pipeline + public static fromContainerClient( + containerClient: ContainerClient, + blobName: string + ): BlockBlobClient { + return new BlockBlobClient( + appendToURLPath(containerClient.url, encodeURIComponent(blobName)), + containerClient.pipeline ); } /** - * Creates a BlockBlobURL object from BlobURL instance. + * Creates a BlockBlobClient object from BlobClient instance. * * @static - * @param {BlobURL} blobURL - * @returns {BlockBlobURL} - * @memberof BlockBlobURL + * @param {BlobClient} blobClient + * @returns {BlockBlobClient} + * @memberof BlockBlobClient */ - public static fromBlobURL(blobURL: BlobURL): BlockBlobURL { - return new BlockBlobURL(blobURL.url, blobURL.pipeline); + public static fromBlobClient(blobClient: BlobClient): BlockBlobClient { + return new BlockBlobClient(blobClient.url, blobClient.pipeline); } /** @@ -81,12 +84,12 @@ export class BlockBlobURL extends BlobURL { * * @private * @type {BlockBlobs} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ private blockBlobContext: BlockBlob; /** - * Creates an instance of BlockBlobURL. + * Creates an instance of BlockBlobClient. * This method accepts an encoded URL or non-encoded URL pointing to a block blob. * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * If a blob name includes ? or %, blob name must be encoded in the URL. @@ -99,9 +102,9 @@ export class BlockBlobURL extends BlobURL { * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * However, if a blob name includes ? or %, blob name must be encoded in the URL. * Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -109,28 +112,28 @@ export class BlockBlobURL extends BlobURL { } /** - * Creates a new BlockBlobURL object identical to the source but with the + * Creates a new BlockBlobClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {BlockBlobURL} - * @memberof BlockBlobURL + * @returns {BlockBlobClient} + * @memberof BlockBlobClient */ - public withPipeline(pipeline: Pipeline): BlockBlobURL { - return new BlockBlobURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): BlockBlobClient { + return new BlockBlobClient(this.url, pipeline); } /** - * Creates a new BlockBlobURL object identical to the source but with the + * Creates a new BlockBlobClient object identical to the source but with the * specified snapshot timestamp. * Provide "" will remove the snapshot and return a URL to the base blob. * * @param {string} snapshot - * @returns {BlockBlobURL} - * @memberof BlockBlobURL + * @returns {BlockBlobClient} + * @memberof BlockBlobClient */ - public withSnapshot(snapshot: string): BlockBlobURL { - return new BlockBlobURL( + public withSnapshot(snapshot: string): BlockBlobClient { + return new BlockBlobClient( setURLParameter( this.url, URLConstants.Parameters.SNAPSHOT, @@ -161,7 +164,7 @@ export class BlockBlobURL extends BlobURL { * string including non non-Base64/Hex-encoded characters. * @param {IBlockBlobUploadOptions} [options] * @returns {Promise} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ public async upload( aborter: Aborter, @@ -192,7 +195,7 @@ export class BlockBlobURL extends BlobURL { * @param {number} contentLength * @param {IBlockBlobStageBlockOptions} [options] * @returns {Promise} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ public async stageBlock( aborter: Aborter, @@ -231,7 +234,7 @@ export class BlockBlobURL extends BlobURL { * @param {number} [count] How much data to be downloaded, > 0. Will download to the end when undefined * @param {IBlockBlobStageBlockFromURLOptions} [options={}] * @returns {Promise} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ public async stageBlockFromURL( aborter: Aborter, @@ -262,7 +265,7 @@ export class BlockBlobURL extends BlobURL { * @param {string[]} blocks Array of 64-byte value that is base64-encoded * @param {IBlockBlobCommitBlockListOptions} [options] * @returns {Promise} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ public async commitBlockList( aborter: Aborter, @@ -292,7 +295,7 @@ export class BlockBlobURL extends BlobURL { * @param {Models.BlockListType} listType * @param {IBlockBlobGetBlockListOptions} [options] * @returns {Promise} - * @memberof BlockBlobURL + * @memberof BlockBlobClient */ public async getBlockList( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/ContainerURL.ts b/sdk/storage/storage-blob/src/ContainerClient.ts similarity index 93% rename from sdk/storage/storage-blob/src/ContainerURL.ts rename to sdk/storage/storage-blob/src/ContainerClient.ts index 8d6b4a2b6ae9..2428e74d62e8 100644 --- a/sdk/storage/storage-blob/src/ContainerURL.ts +++ b/sdk/storage/storage-blob/src/ContainerClient.ts @@ -1,11 +1,11 @@ import { HttpResponse } from "@azure/ms-rest-js"; -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; import { Container } from "./generated/lib/operations"; import { IContainerAccessConditions, IMetadata } from "./models"; import { Pipeline } from "./Pipeline"; -import { ServiceURL } from "./ServiceURL"; -import { StorageURL } from "./StorageURL"; +import { ServiceClient } from "./ServiceClient"; +import { StorageClient } from "./StorageClient"; import { ETagNone } from "./utils/constants"; import { appendToURLPath, truncatedISO8061Date } from "./utils/utils.common"; @@ -125,23 +125,26 @@ export interface IContainerListBlobsSegmentOptions { } /** - * A ContainerURL represents a URL to the Azure Storage container allowing you to manipulate its blobs. + * A ContainerClient represents a URL to the Azure Storage container allowing you to manipulate its blobs. * * @export - * @class ContainerURL - * @extends {StorageURL} + * @class ContainerClient + * @extends {StorageClient} */ -export class ContainerURL extends StorageURL { +export class ContainerClient extends StorageClient { /** - * Creates a ContainerURL object from ServiceURL + * Creates a ContainerClient object from ServiceClient * - * @param serviceURL A ServiceURL object + * @param serviceClient A ServiceClient object * @param containerName A container name */ - public static fromServiceURL(serviceURL: ServiceURL, containerName: string): ContainerURL { - return new ContainerURL( - appendToURLPath(serviceURL.url, encodeURIComponent(containerName)), - serviceURL.pipeline + public static fromServiceClient( + serviceClient: ServiceClient, + containerName: string + ): ContainerClient { + return new ContainerClient( + appendToURLPath(serviceClient.url, encodeURIComponent(containerName)), + serviceClient.pipeline ); } @@ -150,19 +153,19 @@ export class ContainerURL extends StorageURL { * * @private * @type {Containers} - * @memberof ContainerURL + * @memberof ContainerClient */ private containerContext: Container; /** - * Creates an instance of ContainerURL. + * Creates an instance of ContainerClient. * @param {string} url A URL string pointing to Azure Storage blob container, such as * "https://myaccount.blob.core.windows.net/mycontainer". You can * append a SAS if using AnonymousCredential, such as * "https://myaccount.blob.core.windows.net/mycontainer?sasString". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof ContainerURL + * @memberof ContainerClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -170,15 +173,15 @@ export class ContainerURL extends StorageURL { } /** - * Creates a new ContainerURL object identical to the source but with the + * Creates a new ContainerClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {ContainerURL} - * @memberof ContainerURL + * @returns {ContainerClient} + * @memberof ContainerClient */ - public withPipeline(pipeline: Pipeline): ContainerURL { - return new ContainerURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): ContainerClient { + return new ContainerClient(this.url, pipeline); } /** @@ -190,7 +193,7 @@ export class ContainerURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IContainerCreateOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async create( aborter: Aborter, @@ -213,7 +216,7 @@ export class ContainerURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IContainersGetPropertiesOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async getProperties( aborter: Aborter, @@ -238,7 +241,7 @@ export class ContainerURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {Models.ContainersDeleteMethodOptionalParams} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async delete( aborter: Aborter, @@ -289,7 +292,7 @@ export class ContainerURL extends StorageURL { * If no value provided the existing metadata will be removed. * @param {IContainerSetMetadataOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async setMetadata( aborter: Aborter, @@ -342,7 +345,7 @@ export class ContainerURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {IContainerGetAccessPolicyOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async getAccessPolicy( aborter: Aborter, @@ -398,7 +401,7 @@ export class ContainerURL extends StorageURL { * @param {ISignedIdentifier[]} [containerAcl] * @param {IContainerSetAccessPolicyOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async setAccessPolicy( aborter: Aborter, @@ -439,7 +442,7 @@ export class ContainerURL extends StorageURL { * @param {number} duration Must be between 15 to 60 seconds, or infinite (-1) * @param {IContainerAcquireLeaseOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async acquireLease( aborter: Aborter, @@ -465,7 +468,7 @@ export class ContainerURL extends StorageURL { * @param {string} leaseId * @param {IContainerReleaseLeaseOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async releaseLease( aborter: Aborter, @@ -487,7 +490,7 @@ export class ContainerURL extends StorageURL { * @param {string} leaseId * @param {IContainerRenewLeaseOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async renewLease( aborter: Aborter, @@ -510,7 +513,7 @@ export class ContainerURL extends StorageURL { * @param {number} period break period * @param {IContainerBreakLeaseOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async breakLease( aborter: Aborter, @@ -534,7 +537,7 @@ export class ContainerURL extends StorageURL { * @param {string} proposedLeaseId * @param {IContainerChangeLeaseOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async changeLease( aborter: Aborter, @@ -560,7 +563,7 @@ export class ContainerURL extends StorageURL { * @param {string} [marker] * @param {IContainerListBlobsSegmentOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async listBlobFlatSegment( aborter: Aborter, @@ -586,7 +589,7 @@ export class ContainerURL extends StorageURL { * @param {string} delimiter * @param {IContainerListBlobsSegmentOptions} [options] * @returns {Promise} - * @memberof ContainerURL + * @memberof ContainerClient */ public async listBlobHierarchySegment( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/PageBlobURL.ts b/sdk/storage/storage-blob/src/PageBlobClient.ts similarity index 86% rename from sdk/storage/storage-blob/src/PageBlobURL.ts rename to sdk/storage/storage-blob/src/PageBlobClient.ts index 78888dc9409d..9e2a49d2d67f 100644 --- a/sdk/storage/storage-blob/src/PageBlobURL.ts +++ b/sdk/storage/storage-blob/src/PageBlobClient.ts @@ -1,9 +1,9 @@ import { HttpRequestBody, TransferProgressEvent } from "@azure/ms-rest-js"; -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; -import { BlobURL } from "./BlobURL"; -import { ContainerURL } from "./ContainerURL"; +import { BlobClient } from "./BlobClient"; +import { ContainerClient } from "./ContainerClient"; import { PageBlob } from "./generated/lib/operations"; import { rangeToString } from "./IRange"; import { IBlobAccessConditions, IMetadata, IPageBlobAccessConditions } from "./models"; @@ -50,39 +50,42 @@ export interface IPageBlobStartCopyIncrementalOptions { } /** - * PageBlobURL defines a set of operations applicable to page blobs. + * PageBlobClient defines a set of operations applicable to page blobs. * * @export - * @class PageBlobURL - * @extends {StorageURL} + * @class PageBlobClient + * @extends {StorageClient} */ -export class PageBlobURL extends BlobURL { +export class PageBlobClient extends BlobClient { /** - * Creates a PageBlobURL object from ContainerURL instance. + * Creates a PageBlobClient object from ContainerClient instance. * * @static - * @param {ContainerURL} containerURL A ContainerURL object + * @param {ContainerClient} containerClient A ContainerClient object * @param {string} blobName A page blob name - * @returns {PageBlobURL} - * @memberof PageBlobURL + * @returns {PageBlobClient} + * @memberof PageBlobClient */ - public static fromContainerURL(containerURL: ContainerURL, blobName: string): PageBlobURL { - return new PageBlobURL( - appendToURLPath(containerURL.url, encodeURIComponent(blobName)), - containerURL.pipeline + public static fromContainerClient( + containerClient: ContainerClient, + blobName: string + ): PageBlobClient { + return new PageBlobClient( + appendToURLPath(containerClient.url, encodeURIComponent(blobName)), + containerClient.pipeline ); } /** - * Creates a PageBlobURL object from BlobURL instance. + * Creates a PageBlobClient object from BlobClient instance. * * @static - * @param {BlobURL} blobURL - * @returns {PageBlobURL} - * @memberof PageBlobURL + * @param {BlobClient} blobClient + * @returns {PageBlobClient} + * @memberof PageBlobClient */ - public static fromBlobURL(blobURL: BlobURL): PageBlobURL { - return new PageBlobURL(blobURL.url, blobURL.pipeline); + public static fromBlobClient(blobClient: BlobClient): PageBlobClient { + return new PageBlobClient(blobClient.url, blobClient.pipeline); } /** @@ -90,12 +93,12 @@ export class PageBlobURL extends BlobURL { * * @private * @type {PageBlobs} - * @memberof PageBlobURL + * @memberof PageBlobClient */ private pageBlobContext: PageBlob; /** - * Creates an instance of PageBlobURL. + * Creates an instance of PageBlobClient. * This method accepts an encoded URL or non-encoded URL pointing to a page blob. * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * If a blob name includes ? or %, blob name must be encoded in the URL. @@ -108,9 +111,9 @@ export class PageBlobURL extends BlobURL { * Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. * However, if a blob name includes ? or %, blob name must be encoded in the URL. * Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof PageBlobURL + * @memberof PageBlobClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -118,28 +121,28 @@ export class PageBlobURL extends BlobURL { } /** - * Creates a new PageBlobURL object identical to the source but with the + * Creates a new PageBlobClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {PageBlobURL} - * @memberof PageBlobURL + * @returns {PageBlobClient} + * @memberof PageBlobClient */ - public withPipeline(pipeline: Pipeline): PageBlobURL { - return new PageBlobURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): PageBlobClient { + return new PageBlobClient(this.url, pipeline); } /** - * Creates a new PageBlobURL object identical to the source but with the + * Creates a new PageBlobClient object identical to the source but with the * specified snapshot timestamp. - * Provide "" will remove the snapshot and return a URL to the base blob. + * Provide "" will remove the snapshot and return a Client to the base blob. * * @param {string} snapshot - * @returns {PageBlobURL} - * @memberof PageBlobURL + * @returns {PageBlobClient} + * @memberof PageBlobClient */ - public withSnapshot(snapshot: string): PageBlobURL { - return new PageBlobURL( + public withSnapshot(snapshot: string): PageBlobClient { + return new PageBlobClient( setURLParameter( this.url, URLConstants.Parameters.SNAPSHOT, @@ -159,7 +162,7 @@ export class PageBlobURL extends BlobURL { * @param {number} size * @param {IPageBlobCreateOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async create( aborter: Aborter, @@ -188,7 +191,7 @@ export class PageBlobURL extends BlobURL { * @param {number} count Content length of body, also how many bytes to be uploaded * @param {IPageBlobUploadPagesOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async uploadPages( aborter: Aborter, @@ -219,7 +222,7 @@ export class PageBlobURL extends BlobURL { * @param {number} count * @param {IPageBlobClearPagesOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async clearPages( aborter: Aborter, @@ -247,7 +250,7 @@ export class PageBlobURL extends BlobURL { * @param {number} count * @param {IPageBlobGetPageRangesOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async getPageRanges( aborter: Aborter, @@ -275,7 +278,7 @@ export class PageBlobURL extends BlobURL { * @param {string} prevSnapshot * @param {IPageBlobGetPageRangesDiffOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async getPageRangesDiff( aborter: Aborter, @@ -303,7 +306,7 @@ export class PageBlobURL extends BlobURL { * @param {number} size * @param {IPageBlobResizeOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async resize( aborter: Aborter, @@ -328,7 +331,7 @@ export class PageBlobURL extends BlobURL { * @param {number} [sequenceNumber] Required if sequenceNumberAction is max or update * @param {IPageBlobUpdateSequenceNumberOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async updateSequenceNumber( aborter: Aborter, @@ -359,7 +362,7 @@ export class PageBlobURL extends BlobURL { * https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot= * @param {IPageBlobStartCopyIncrementalOptions} [options] * @returns {Promise} - * @memberof PageBlobURL + * @memberof PageBlobClient */ public async startCopyIncremental( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/Pipeline.ts b/sdk/storage/storage-blob/src/Pipeline.ts index eada177ac894..3e6f2e560472 100644 --- a/sdk/storage/storage-blob/src/Pipeline.ts +++ b/sdk/storage/storage-blob/src/Pipeline.ts @@ -42,9 +42,9 @@ export interface IPipelineOptions { /** * A Pipeline class containing HTTP request policies. - * You can create a default Pipeline by calling StorageURL.newPipeline(). + * You can create a default Pipeline by calling StorageClient.newPipeline(). * Or you can create a Pipeline with your own policies by the constructor of Pipeline. - * Refer to StorageURL.newPipeline() and provided policies as reference before + * Refer to StorageClient.newPipeline() and provided policies as reference before * implementing your customized Pipeline. * * @export diff --git a/sdk/storage/storage-blob/src/ServiceURL.ts b/sdk/storage/storage-blob/src/ServiceClient.ts similarity index 87% rename from sdk/storage/storage-blob/src/ServiceURL.ts rename to sdk/storage/storage-blob/src/ServiceClient.ts index e484136589a6..206af50b5515 100644 --- a/sdk/storage/storage-blob/src/ServiceURL.ts +++ b/sdk/storage/storage-blob/src/ServiceClient.ts @@ -1,9 +1,9 @@ -import * as Models from "../src/generated/lib/models"; +import * as Models from "./generated/lib/models"; import { Aborter } from "./Aborter"; import { ListContainersIncludeType } from "./generated/lib/models/index"; import { Service } from "./generated/lib/operations"; import { Pipeline } from "./Pipeline"; -import { StorageURL } from "./StorageURL"; +import { StorageClient } from "./StorageClient"; export interface IServiceListContainersSegmentOptions { /** @@ -30,32 +30,32 @@ export interface IServiceListContainersSegmentOptions { } /** - * A ServiceURL represents a URL to the Azure Storage Blob service allowing you + * A ServiceClient represents a Client to the Azure Storage Blob service allowing you * to manipulate blob containers. * * @export - * @class ServiceURL - * @extends {StorageURL} + * @class ServiceClient + * @extends {StorageClient} */ -export class ServiceURL extends StorageURL { +export class ServiceClient extends StorageClient { /** * serviceContext provided by protocol layer. * * @private * @type {Service} - * @memberof ServiceURL + * @memberof ServiceClient */ private serviceContext: Service; /** - * Creates an instance of ServiceURL. + * Creates an instance of ServiceClient. * - * @param {string} url A URL string pointing to Azure Storage blob service, such as + * @param {string} url A Client string pointing to Azure Storage blob service, such as * "https://myaccount.blob.core.windows.net". You can append a SAS * if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString". - * @param {Pipeline} pipeline Call StorageURL.newPipeline() to create a default + * @param {Pipeline} pipeline Call StorageClient.newPipeline() to create a default * pipeline, or provide a customized pipeline. - * @memberof ServiceURL + * @memberof ServiceClient */ constructor(url: string, pipeline: Pipeline) { super(url, pipeline); @@ -63,15 +63,15 @@ export class ServiceURL extends StorageURL { } /** - * Creates a new ServiceURL object identical to the source but with the + * Creates a new ServiceClient object identical to the source but with the * specified request policy pipeline. * * @param {Pipeline} pipeline - * @returns {ServiceURL} - * @memberof ServiceURL + * @returns {ServiceClient} + * @memberof ServiceClient */ - public withPipeline(pipeline: Pipeline): ServiceURL { - return new ServiceURL(this.url, pipeline); + public withPipeline(pipeline: Pipeline): ServiceClient { + return new ServiceClient(this.url, pipeline); } /** @@ -82,7 +82,7 @@ export class ServiceURL extends StorageURL { * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @returns {Promise} - * @memberof ServiceURL + * @memberof ServiceClient */ public async getProperties(aborter: Aborter): Promise { return this.serviceContext.getProperties({ @@ -99,7 +99,7 @@ export class ServiceURL extends StorageURL { * goto documents of Aborter for more examples about request cancellation * @param {Models.StorageServiceProperties} properties * @returns {Promise} - * @memberof ServiceURL + * @memberof ServiceClient */ public async setProperties( aborter: Aborter, @@ -119,7 +119,7 @@ export class ServiceURL extends StorageURL { * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @returns {Promise} - * @memberof ServiceURL + * @memberof ServiceClient */ public async getStatistics(aborter: Aborter): Promise { return this.serviceContext.getStatistics({ @@ -137,7 +137,7 @@ export class ServiceURL extends StorageURL { * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @returns {Promise} - * @memberof ServiceURL + * @memberof ServiceClient */ public async getAccountInfo(aborter: Aborter): Promise { return this.serviceContext.getAccountInfo({ @@ -160,7 +160,7 @@ export class ServiceURL extends StorageURL { * items. The marker value is opaque to the client. * @param {IServiceListContainersSegmentOptions} [options] * @returns {Promise} - * @memberof ServiceURL + * @memberof ServiceClient */ public async listContainersSegment( aborter: Aborter, diff --git a/sdk/storage/storage-blob/src/StorageURL.ts b/sdk/storage/storage-blob/src/StorageClient.ts similarity index 91% rename from sdk/storage/storage-blob/src/StorageURL.ts rename to sdk/storage/storage-blob/src/StorageClient.ts index 394574a06ce6..7ae054ae2f39 100644 --- a/sdk/storage/storage-blob/src/StorageURL.ts +++ b/sdk/storage/storage-blob/src/StorageClient.ts @@ -33,12 +33,12 @@ export interface INewPipelineOptions { } /** - * A ServiceURL represents a based URL class for ServiceURL, ContainerURL and etc. + * A ServiceClient represents a based URL class for ServiceClient, ContainerClient and etc. * * @export - * @class StorageURL + * @class StorageClient */ -export abstract class StorageURL { +export abstract class StorageClient { /** * A static method used to create a new Pipeline object with Credential provided. * @@ -76,7 +76,7 @@ export abstract class StorageURL { * * @internal * @type {Pipeline} - * @memberof StorageURL + * @memberof StorageClient */ public readonly pipeline: Pipeline; @@ -84,7 +84,7 @@ export abstract class StorageURL { * Encoded URL string value. * * @type {string} - * @memberof StorageURL + * @memberof StorageClient */ public readonly url: string; @@ -94,15 +94,15 @@ export abstract class StorageURL { * * @protected * @type {StorageClient} - * @memberof StorageURL + * @memberof StorageClient */ protected readonly storageClientContext: StorageClientContext; /** - * Creates an instance of StorageURL. + * Creates an instance of StorageClient. * @param {string} url * @param {Pipeline} pipeline - * @memberof StorageURL + * @memberof StorageClient */ protected constructor(url: string, pipeline: Pipeline) { // URL should be encoded and only once, protocol layer shouldn't encode URL again diff --git a/sdk/storage/storage-blob/src/credentials/TokenCredential.ts b/sdk/storage/storage-blob/src/credentials/TokenCredential.ts index eb3715bc25c0..0d59c497e6f1 100644 --- a/sdk/storage/storage-blob/src/credentials/TokenCredential.ts +++ b/sdk/storage/storage-blob/src/credentials/TokenCredential.ts @@ -9,10 +9,10 @@ import { TokenCredentialPolicy } from "../policies/TokenCredentialPolicy"; * * @example * const tokenCredential = new TokenCredential("token"); - * const pipeline = StorageURL.newPipeline(tokenCredential); + * const pipeline = StorageClient.newPipeline(tokenCredential); * * // List containers - * const serviceURL = new ServiceURL("https://mystorageaccount.blob.core.windows.net", pipeline); + * const serviceClient = new ServiceClient("https://mystorageaccount.blob.core.windows.net", pipeline); * * // Set up a timer to refresh the token * const timerID = setInterval(() => { diff --git a/sdk/storage/storage-blob/src/highlevel.browser.ts b/sdk/storage/storage-blob/src/highlevel.browser.ts index 664866779f63..4995f3a806cc 100644 --- a/sdk/storage/storage-blob/src/highlevel.browser.ts +++ b/sdk/storage/storage-blob/src/highlevel.browser.ts @@ -1,7 +1,7 @@ import { generateUuid } from "@azure/ms-rest-js"; import { Aborter } from "./Aborter"; -import { BlockBlobURL } from "./BlockBlobURL"; +import { BlockBlobClient } from "./BlockBlobClient"; import { BlobUploadCommonResponse, IUploadToBlockBlobOptions } from "./highlevel.common"; import { Batch } from "./utils/Batch"; import { @@ -25,14 +25,14 @@ import { generateBlockID } from "./utils/utils.common"; * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @param {Blob | ArrayBuffer | ArrayBufferView} browserData Blob, File, ArrayBuffer or ArrayBufferView - * @param {BlockBlobURL} blockBlobURL + * @param {BlockBlobClient} blockBlobClient * @param {IUploadToBlockBlobOptions} [options] * @returns {Promise} */ export async function uploadBrowserDataToBlockBlob( aborter: Aborter, browserData: Blob | ArrayBuffer | ArrayBufferView, - blockBlobURL: BlockBlobURL, + blockBlobClient: BlockBlobClient, options?: IUploadToBlockBlobOptions ): Promise { const browserBlob = new Blob([browserData]); @@ -42,7 +42,7 @@ export async function uploadBrowserDataToBlockBlob( return browserBlob.slice(offset, offset + size); }, browserBlob.size, - blockBlobURL, + blockBlobClient, options ); } @@ -61,7 +61,7 @@ export async function uploadBrowserDataToBlockBlob( * goto documents of Aborter for more examples about request cancellation * @param {(offset: number, size: number) => Blob} blobFactory * @param {number} size - * @param {BlockBlobURL} blockBlobURL + * @param {BlockBlobClient} blockBlobClient * @param {IUploadToBlockBlobOptions} [options] * @returns {Promise} */ @@ -69,7 +69,7 @@ async function UploadSeekableBlobToBlockBlob( aborter: Aborter, blobFactory: (offset: number, size: number) => Blob, size: number, - blockBlobURL: BlockBlobURL, + blockBlobClient: BlockBlobClient, options: IUploadToBlockBlobOptions = {} ): Promise { if (!options.blockSize) { @@ -112,7 +112,7 @@ async function UploadSeekableBlobToBlockBlob( } if (size <= options.maxSingleShotSize) { - return blockBlobURL.upload(aborter, blobFactory(0, size), size, options); + return blockBlobClient.upload(aborter, blobFactory(0, size), size, options); } const numBlocks: number = Math.floor((size - 1) / options.blockSize) + 1; @@ -136,7 +136,7 @@ async function UploadSeekableBlobToBlockBlob( const end = i === numBlocks - 1 ? size : start + options.blockSize!; const contentLength = end - start; blockList.push(blockID); - await blockBlobURL.stageBlock( + await blockBlobClient.stageBlock( aborter, blockID, blobFactory(start, contentLength), @@ -158,5 +158,5 @@ async function UploadSeekableBlobToBlockBlob( } await batch.do(); - return blockBlobURL.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(aborter, blockList, options); } diff --git a/sdk/storage/storage-blob/src/highlevel.common.ts b/sdk/storage/storage-blob/src/highlevel.common.ts index 6f7468928043..19391e146b0b 100644 --- a/sdk/storage/storage-blob/src/highlevel.common.ts +++ b/sdk/storage/storage-blob/src/highlevel.common.ts @@ -108,7 +108,7 @@ export interface IDownloadFromBlobOptions { * Above kind of ends will not trigger retry policy defined in a pipeline, * because they doesn't emit network errors. * - * With this option, every additional retry means an additional FileURL.download() request will be made + * With this option, every additional retry means an additional FileClient.download() request will be made * from the broken point, until the requested block has been successfully downloaded or * maxRetryRequestsPerBlock is reached. * diff --git a/sdk/storage/storage-blob/src/highlevel.node.ts b/sdk/storage/storage-blob/src/highlevel.node.ts index d2f34fa8dd08..c94132c126ec 100644 --- a/sdk/storage/storage-blob/src/highlevel.node.ts +++ b/sdk/storage/storage-blob/src/highlevel.node.ts @@ -3,8 +3,8 @@ import { generateUuid, TransferProgressEvent } from "@azure/ms-rest-js"; import { Readable } from "stream"; import { Aborter } from "./Aborter"; -import { BlobURL } from "./BlobURL"; -import { BlockBlobURL } from "./BlockBlobURL"; +import { BlobClient } from "./BlobClient"; +import { BlockBlobClient } from "./BlockBlobClient"; import { BlobHTTPHeaders } from "./generated/lib/models"; import { BlobUploadCommonResponse, @@ -36,14 +36,14 @@ import { streamToBuffer } from "./utils/utils.node"; * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @param {string} filePath Full path of local file - * @param {BlockBlobURL} blockBlobURL BlockBlobURL + * @param {BlockBlobClient} blockBlobClient BlockBlobClient * @param {IUploadToBlockBlobOptions} [options] IUploadToBlockBlobOptions * @returns {(Promise)} ICommonResponse */ export async function uploadFileToBlockBlob( aborter: Aborter, filePath: string, - blockBlobURL: BlockBlobURL, + blockBlobClient: BlockBlobClient, options?: IUploadToBlockBlobOptions ): Promise { const size = fs.statSync(filePath).size; @@ -56,7 +56,7 @@ export async function uploadFileToBlockBlob( start: offset }), size, - blockBlobURL, + blockBlobClient, options ); } @@ -78,7 +78,7 @@ export async function uploadFileToBlockBlob( * @param {(offset: number) => NodeJS.ReadableStream} streamFactory Returns a Node.js Readable stream starting * from the offset defined * @param {number} size Size of the block blob - * @param {BlockBlobURL} blockBlobURL BlockBlobURL + * @param {BlockBlobClient} blockBlobClient BlockBlobClient * @param {IUploadToBlockBlobOptions} [options] IUploadToBlockBlobOptions * @returns {(Promise)} ICommonResponse */ @@ -86,7 +86,7 @@ async function uploadResetableStreamToBlockBlob( aborter: Aborter, streamFactory: (offset: number, count?: number) => NodeJS.ReadableStream, size: number, - blockBlobURL: BlockBlobURL, + blockBlobClient: BlockBlobClient, options: IUploadToBlockBlobOptions = {} ): Promise { if (!options.blockSize) { @@ -129,7 +129,7 @@ async function uploadResetableStreamToBlockBlob( } if (size <= options.maxSingleShotSize) { - return blockBlobURL.upload(aborter, () => streamFactory(0), size, options); + return blockBlobClient.upload(aborter, () => streamFactory(0), size, options); } const numBlocks: number = Math.floor((size - 1) / options.blockSize) + 1; @@ -153,7 +153,7 @@ async function uploadResetableStreamToBlockBlob( const end = i === numBlocks - 1 ? size : start + options.blockSize!; const contentLength = end - start; blockList.push(blockID); - await blockBlobURL.stageBlock( + await blockBlobClient.stageBlock( aborter, blockID, () => streamFactory(start, contentLength), @@ -172,7 +172,7 @@ async function uploadResetableStreamToBlockBlob( } await batch.do(); - return blockBlobURL.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(aborter, blockList, options); } /** @@ -185,7 +185,7 @@ async function uploadResetableStreamToBlockBlob( * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @param {Buffer} buffer Buffer to be fill, must have length larger than count - * @param {BlobURL} blobURL A BlobURL object + * @param {BlobClient} blobClient A BlobClient object * @param {number} offset From which position of the block blob to download * @param {number} [count] How much data to be downloaded. Will download to the end when passing undefined * @param {IDownloadFromBlobOptions} [options] IDownloadFromBlobOptions @@ -194,7 +194,7 @@ async function uploadResetableStreamToBlockBlob( export async function downloadBlobToBuffer( aborter: Aborter, buffer: Buffer, - blobURL: BlobURL, + blobClient: BlobClient, offset: number, count?: number, options: IDownloadFromBlobOptions = {} @@ -223,7 +223,7 @@ export async function downloadBlobToBuffer( // Customer doesn't specify length, get it if (!count) { - const response = await blobURL.getProperties(aborter, options); + const response = await blobClient.getProperties(aborter, options); count = response.contentLength! - offset; if (count < 0) { throw new RangeError( @@ -243,7 +243,7 @@ export async function downloadBlobToBuffer( for (let off = offset; off < offset + count; off = off + options.blockSize) { batch.addOperation(async () => { const chunkEnd = off + options.blockSize! < count! ? off + options.blockSize! : count!; - const response = await blobURL.download(aborter, off, chunkEnd - off + 1, { + const response = await blobClient.download(aborter, off, chunkEnd - off + 1, { blobAccessConditions: options.blobAccessConditions, maxRetryRequests: options.maxRetryRequestsPerBlock }); @@ -313,7 +313,7 @@ export interface IUploadStreamToBlockBlobOptions { * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation * @param {Readable} stream Node.js Readable stream - * @param {BlockBlobURL} blockBlobURL A BlockBlobURL instance + * @param {BlockBlobClient} blockBlobClient A BlockBlobClient instance * @param {number} bufferSize Size of every buffer allocated, also the block size in the uploaded block blob * @param {number} maxBuffers Max buffers will allocate during uploading, positive correlation * with max uploading concurrency @@ -323,7 +323,7 @@ export interface IUploadStreamToBlockBlobOptions { export async function uploadStreamToBlockBlob( aborter: Aborter, stream: Readable, - blockBlobURL: BlockBlobURL, + blockBlobClient: BlockBlobClient, bufferSize: number, maxBuffers: number, options: IUploadStreamToBlockBlobOptions = {} @@ -349,7 +349,7 @@ export async function uploadStreamToBlockBlob( blockList.push(blockID); blockNum++; - await blockBlobURL.stageBlock(aborter, blockID, buffer, buffer.length, { + await blockBlobClient.stageBlock(aborter, blockID, buffer, buffer.length, { leaseAccessConditions: options.accessConditions!.leaseAccessConditions }); @@ -367,5 +367,5 @@ export async function uploadStreamToBlockBlob( ); await scheduler.do(); - return blockBlobURL.commitBlockList(aborter, blockList, options); + return blockBlobClient.commitBlockList(aborter, blockList, options); } diff --git a/sdk/storage/storage-blob/src/index.browser.ts b/sdk/storage/storage-blob/src/index.browser.ts index 6ced8ae2e9d2..c0f086cec767 100644 --- a/sdk/storage/storage-blob/src/index.browser.ts +++ b/sdk/storage/storage-blob/src/index.browser.ts @@ -3,11 +3,11 @@ import { RestError } from "@azure/ms-rest-js"; import * as Models from "../src/generated/lib/models"; export * from "./Aborter"; -export * from "./AppendBlobURL"; -export * from "./BlobURL"; -export * from "./BlockBlobURL"; +export * from "./AppendBlobClient"; +export * from "./BlobClient"; +export * from "./BlockBlobClient"; export * from "./BrowserPolicyFactory"; -export * from "./ContainerURL"; +export * from "./ContainerClient"; export * from "./credentials/AnonymousCredential"; export * from "./credentials/Credential"; export * from "./credentials/TokenCredential"; @@ -15,7 +15,7 @@ export * from "./highlevel.browser"; export * from "./highlevel.common"; export { IIPRange } from "./IIPRange"; export { IRange } from "./IRange"; -export * from "./PageBlobURL"; +export * from "./PageBlobClient"; export * from "./Pipeline"; export * from "./policies/AnonymousCredentialPolicy"; export * from "./policies/CredentialPolicy"; @@ -24,6 +24,6 @@ export * from "./LoggingPolicyFactory"; export * from "./TelemetryPolicyFactory"; export * from "./policies/TokenCredentialPolicy"; export * from "./UniqueRequestIDPolicyFactory"; -export * from "./ServiceURL"; -export * from "./StorageURL"; +export * from "./ServiceClient"; +export * from "./StorageClient"; export { Models, RestError }; diff --git a/sdk/storage/storage-blob/src/index.ts b/sdk/storage/storage-blob/src/index.ts index ee27a16f9b42..5a8a07fd78f7 100644 --- a/sdk/storage/storage-blob/src/index.ts +++ b/sdk/storage/storage-blob/src/index.ts @@ -7,14 +7,14 @@ export * from "./AccountSASPermissions"; export * from "./AccountSASResourceTypes"; export * from "./AccountSASServices"; export * from "./IAccountSASSignatureValues"; -export * from "./AppendBlobURL"; +export * from "./AppendBlobClient"; export * from "./BlobSASPermissions"; export * from "./IBlobSASSignatureValues"; -export * from "./BlobURL"; -export * from "./BlockBlobURL"; +export * from "./BlobClient"; +export * from "./BlockBlobClient"; export * from "./BrowserPolicyFactory"; export * from "./ContainerSASPermissions"; -export * from "./ContainerURL"; +export * from "./ContainerClient"; export * from "./credentials/AnonymousCredential"; export * from "./credentials/Credential"; export * from "./credentials/SharedKeyCredential"; @@ -24,7 +24,7 @@ export * from "./highlevel.common"; export * from "./highlevel.node"; export { IIPRange } from "./IIPRange"; export { IRange } from "./IRange"; -export * from "./PageBlobURL"; +export * from "./PageBlobClient"; export * from "./Pipeline"; export * from "./policies/AnonymousCredentialPolicy"; export * from "./policies/CredentialPolicy"; @@ -34,7 +34,7 @@ export * from "./policies/SharedKeyCredentialPolicy"; export * from "./TelemetryPolicyFactory"; export * from "./policies/TokenCredentialPolicy"; export * from "./UniqueRequestIDPolicyFactory"; -export * from "./ServiceURL"; -export * from "./StorageURL"; +export * from "./ServiceClient"; +export * from "./StorageClient"; export * from "./SASQueryParameters"; export { Models, RestError }; diff --git a/sdk/storage/storage-blob/src/utils/utils.common.ts b/sdk/storage/storage-blob/src/utils/utils.common.ts index 6ecb8cec24f0..d5e80791ea53 100644 --- a/sdk/storage/storage-blob/src/utils/utils.common.ts +++ b/sdk/storage/storage-blob/src/utils/utils.common.ts @@ -5,9 +5,9 @@ import { isNode, URLBuilder } from "@azure/ms-rest-js"; * * ## URL encode and escape strategy for JSv10 SDKs * - * When customers pass a URL string into XXXURL classes constrcutor, the URL string may already be URL encoded or not. + * When customers pass a URL string into XxxClient classes constrcutor, the URL string may already be URL encoded or not. * But before sending to Azure Storage server, the URL must be encoded. However, it's hard for a SDK to guess whether the URL - * string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XXXURL constructors. + * string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XxxClient constructors. * * ### Strategy One: Assume the customer URL string is not encoded, and always encode URL string in SDK. * @@ -43,7 +43,7 @@ import { isNode, URLBuilder } from "@azure/ms-rest-js"; * * Another special character is "?", use "%2F" to represent a blob name with "?" in a URL string. * - * ### Strategy for containerName, blobName or other specific XXXName parameters in methods such as `BlobURL.fromContainerURL(containerURL, blobName)` + * ### Strategy for containerName, blobName or other specific XXXName parameters in methods such as `BlobClient.fromContainerClient(containerURL, blobName)` * * We will apply strategy one, and call encodeURIComponent for these parameters like blobName. Because what customers passes in is a plain name instead of a URL. * diff --git a/sdk/storage/storage-blob/test/aborter.test.ts b/sdk/storage/storage-blob/test/aborter.test.ts index 057adb6c2daf..0764b3bf4aee 100644 --- a/sdk/storage/storage-blob/test/aborter.test.ts +++ b/sdk/storage/storage-blob/test/aborter.test.ts @@ -1,20 +1,20 @@ import * as assert from "assert"; import { Aborter } from "../src/Aborter"; -import { ContainerURL } from "../src/ContainerURL"; +import { ContainerClient } from "../src/ContainerClient"; import { getBSU, getUniqueName } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); // tslint:disable:no-empty describe("Aborter", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); }); it("should set value and get value successfully", async () => { @@ -23,12 +23,12 @@ describe("Aborter", () => { }); it("Should not abort after calling abort()", async () => { - await containerURL.create(Aborter.none); + await containerClient.create(Aborter.none); }); it("Should abort when calling abort() before request finishes", async () => { const aborter = Aborter.none; - const response = containerURL.create(aborter); + const response = containerClient.create(aborter); aborter.abort(); try { await response; @@ -38,13 +38,13 @@ describe("Aborter", () => { it("Should not abort when calling abort() after request finishes", async () => { const aborter = Aborter.none; - await containerURL.create(aborter); + await containerClient.create(aborter); aborter.abort(); }); it("Should abort after aborter timeout", async () => { try { - await containerURL.create(Aborter.timeout(1)); + await containerClient.create(Aborter.timeout(1)); assert.fail(); } catch (err) {} }); @@ -52,7 +52,7 @@ describe("Aborter", () => { it("Should abort after father aborter calls abort()", async () => { try { const aborter = Aborter.none; - const response = containerURL.create(aborter.withTimeout(10 * 60 * 1000)); + const response = containerClient.create(aborter.withTimeout(10 * 60 * 1000)); aborter.abort(); await response; assert.fail(); @@ -62,7 +62,7 @@ describe("Aborter", () => { it("Should abort after father aborter timeout", async () => { try { const aborter = Aborter.timeout(1); - const response = containerURL.create(aborter.withTimeout(10 * 60 * 1000)); + const response = containerClient.create(aborter.withTimeout(10 * 60 * 1000)); await response; assert.fail(); } catch (err) {} diff --git a/sdk/storage/storage-blob/test/appendbloburl.test.ts b/sdk/storage/storage-blob/test/appendbloburl.test.ts index f67884618f38..5b7b65f7b7fc 100644 --- a/sdk/storage/storage-blob/test/appendbloburl.test.ts +++ b/sdk/storage/storage-blob/test/appendbloburl.test.ts @@ -1,34 +1,34 @@ import * as assert from "assert"; import { Aborter } from "../src/Aborter"; -import { AppendBlobURL } from "../src/AppendBlobURL"; -import { ContainerURL } from "../src/ContainerURL"; +import { AppendBlobClient } from "../src/AppendBlobClient"; +import { ContainerClient } from "../src/ContainerClient"; import { bodyToString, getBSU, getUniqueName } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("AppendBlobURL", () => { - const serviceURL = getBSU(); +describe("AppendBlobClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let appendBlobURL = AppendBlobURL.fromContainerURL(containerURL, blobName); + let appendBlobClient = AppendBlobClient.fromContainerClient(containerClient, blobName); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - appendBlobURL = AppendBlobURL.fromContainerURL(containerURL, blobName); + appendBlobClient = AppendBlobClient.fromContainerClient(containerClient, blobName); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("create with default parameters", async () => { - await appendBlobURL.create(Aborter.none); - await appendBlobURL.download(Aborter.none, 0); + await appendBlobClient.create(Aborter.none); + await appendBlobClient.download(Aborter.none, 0); }); it("create with parameters configured", async () => { @@ -45,8 +45,8 @@ describe("AppendBlobURL", () => { key2: "valb" } }; - await appendBlobURL.create(Aborter.none, options); - const properties = await appendBlobURL.getProperties(Aborter.none); + await appendBlobClient.create(Aborter.none, options); + const properties = await appendBlobClient.getProperties(Aborter.none); assert.equal(properties.cacheControl, options.blobHTTPHeaders.blobCacheControl); assert.equal(properties.contentDisposition, options.blobHTTPHeaders.blobContentDisposition); assert.equal(properties.contentEncoding, options.blobHTTPHeaders.blobContentEncoding); @@ -57,12 +57,12 @@ describe("AppendBlobURL", () => { }); it("appendBlock", async () => { - await appendBlobURL.create(Aborter.none); + await appendBlobClient.create(Aborter.none); const content = "Hello World!"; - await appendBlobURL.appendBlock(Aborter.none, content, content.length); + await appendBlobClient.appendBlock(Aborter.none, content, content.length); - const downloadResponse = await appendBlobURL.download(Aborter.none, 0); + const downloadResponse = await appendBlobClient.download(Aborter.none, 0); assert.equal(await bodyToString(downloadResponse, content.length), content); assert.equal(downloadResponse.contentLength!, content.length); }); diff --git a/sdk/storage/storage-blob/test/bloburl.test.ts b/sdk/storage/storage-blob/test/bloburl.test.ts index 852764137b14..0ad4b4406470 100644 --- a/sdk/storage/storage-blob/test/bloburl.test.ts +++ b/sdk/storage/storage-blob/test/bloburl.test.ts @@ -2,42 +2,42 @@ import * as assert from "assert"; import { isNode } from "@azure/ms-rest-js"; import { Aborter } from "../src/Aborter"; -import { BlobURL } from "../src/BlobURL"; -import { BlockBlobURL } from "../src/BlockBlobURL"; -import { ContainerURL } from "../src/ContainerURL"; +import { BlobClient } from "../src/BlobClient"; +import { BlockBlobClient } from "../src/BlockBlobClient"; +import { ContainerClient } from "../src/ContainerClient"; import { bodyToString, getBSU, getUniqueName, sleep } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("BlobURL", () => { - const serviceURL = getBSU(); +describe("BlobClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); const content = "Hello World"; beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - await blockBlobURL.upload(Aborter.none, content, content.length); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + await blockBlobClient.upload(Aborter.none, content, content.length); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("download with with default parameters", async () => { - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, content.length), content); }); it("download all parameters set", async () => { - const result = await blobURL.download(Aborter.none, 0, 1, { + const result = await blobClient.download(Aborter.none, 0, 1, { rangeGetContentMD5: true }); assert.deepStrictEqual(await bodyToString(result, 1), content[0]); @@ -48,8 +48,8 @@ describe("BlobURL", () => { a: "a", b: "b" }; - await blobURL.setMetadata(Aborter.none, metadata); - const result = await blobURL.getProperties(Aborter.none); + await blobClient.setMetadata(Aborter.none, metadata); + const result = await blobClient.getProperties(Aborter.none); assert.deepStrictEqual(result.metadata, metadata); }); @@ -58,18 +58,18 @@ describe("BlobURL", () => { a: "a", b: "b" }; - await blobURL.setMetadata(Aborter.none, metadata); - const result = await blobURL.getProperties(Aborter.none); + await blobClient.setMetadata(Aborter.none, metadata); + const result = await blobClient.getProperties(Aborter.none); assert.deepStrictEqual(result.metadata, metadata); - await blobURL.setMetadata(Aborter.none); - const result2 = await blobURL.getProperties(Aborter.none); + await blobClient.setMetadata(Aborter.none); + const result2 = await blobClient.getProperties(Aborter.none); assert.deepStrictEqual(result2.metadata, {}); }); it("setHTTPHeaders with default parameters", async () => { - await blobURL.setHTTPHeaders(Aborter.none, {}); - const result = await blobURL.getProperties(Aborter.none); + await blobClient.setHTTPHeaders(Aborter.none, {}); + const result = await blobClient.getProperties(Aborter.none); assert.deepStrictEqual(result.blobType, "BlockBlob"); assert.ok(result.lastModified); @@ -91,8 +91,8 @@ describe("BlobURL", () => { blobContentMD5: isNode ? Buffer.from([1, 2, 3, 4]) : new Uint8Array([1, 2, 3, 4]), blobContentType: "blobContentType" }; - await blobURL.setHTTPHeaders(Aborter.none, headers); - const result = await blobURL.getProperties(Aborter.none); + await blobClient.setHTTPHeaders(Aborter.none, headers); + const result = await blobClient.getProperties(Aborter.none); assert.ok(result.date); assert.deepStrictEqual(result.blobType, "BlockBlob"); assert.ok(result.lastModified); @@ -108,113 +108,113 @@ describe("BlobURL", () => { it("acquireLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 30; - await blobURL.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(Aborter.none, guid, duration); - const result = await blobURL.getProperties(Aborter.none); + const result = await blobClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobURL.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(Aborter.none, guid); }); it("releaseLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = -1; - await blobURL.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(Aborter.none, guid, duration); - const result = await blobURL.getProperties(Aborter.none); + const result = await blobClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "infinite"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobURL.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(Aborter.none, guid); }); it("renewLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobURL.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(Aborter.none, guid, duration); - const result = await blobURL.getProperties(Aborter.none); + const result = await blobClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); await sleep(20 * 1000); - const result2 = await blobURL.getProperties(Aborter.none); + const result2 = await blobClient.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "expired"); assert.equal(result2.leaseStatus, "unlocked"); - await blobURL.renewLease(Aborter.none, guid); - const result3 = await blobURL.getProperties(Aborter.none); + await blobClient.renewLease(Aborter.none, guid); + const result3 = await blobClient.getProperties(Aborter.none); assert.equal(result3.leaseDuration, "fixed"); assert.equal(result3.leaseState, "leased"); assert.equal(result3.leaseStatus, "locked"); - await blobURL.releaseLease(Aborter.none, guid); + await blobClient.releaseLease(Aborter.none, guid); }); it("changeLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobURL.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(Aborter.none, guid, duration); - const result = await blobURL.getProperties(Aborter.none); + const result = await blobClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); const newGuid = "3c7e72ebb4304526bc53d8ecef03798f"; - await blobURL.changeLease(Aborter.none, guid, newGuid); + await blobClient.changeLease(Aborter.none, guid, newGuid); - await blobURL.getProperties(Aborter.none); - await blobURL.releaseLease(Aborter.none, newGuid); + await blobClient.getProperties(Aborter.none); + await blobClient.releaseLease(Aborter.none, newGuid); }); it("breakLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await blobURL.acquireLease(Aborter.none, guid, duration); + await blobClient.acquireLease(Aborter.none, guid, duration); - const result = await blobURL.getProperties(Aborter.none); + const result = await blobClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await blobURL.breakLease(Aborter.none, 5); + await blobClient.breakLease(Aborter.none, 5); - const result2 = await blobURL.getProperties(Aborter.none); + const result2 = await blobClient.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "breaking"); assert.equal(result2.leaseStatus, "locked"); await sleep(5 * 1000); - const result3 = await blobURL.getProperties(Aborter.none); + const result3 = await blobClient.getProperties(Aborter.none); assert.ok(!result3.leaseDuration); assert.equal(result3.leaseState, "broken"); assert.equal(result3.leaseStatus, "unlocked"); }); it("delete", async () => { - await blobURL.delete(Aborter.none); + await blobClient.delete(Aborter.none); }); // The following code illustrates deleting a snapshot after creating one it("delete snapshot", async () => { - const result = await blobURL.createSnapshot(Aborter.none); + const result = await blobClient.createSnapshot(Aborter.none); assert.ok(result.snapshot); - const blobSnapshotURL = blobURL.withSnapshot(result.snapshot!); - await blobSnapshotURL.getProperties(Aborter.none); + const blobSnapshotClient = blobClient.withSnapshot(result.snapshot!); + await blobSnapshotClient.getProperties(Aborter.none); - await blobSnapshotURL.delete(Aborter.none); - await blobURL.delete(Aborter.none); + await blobSnapshotClient.delete(Aborter.none); + await blobClient.delete(Aborter.none); - const result2 = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + const result2 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["snapshots"] }); @@ -223,13 +223,13 @@ describe("BlobURL", () => { }); it("createSnapshot", async () => { - const result = await blobURL.createSnapshot(Aborter.none); + const result = await blobClient.createSnapshot(Aborter.none); assert.ok(result.snapshot); - const blobSnapshotURL = blobURL.withSnapshot(result.snapshot!); - await blobSnapshotURL.getProperties(Aborter.none); + const blobSnapshotClient = blobClient.withSnapshot(result.snapshot!); + await blobSnapshotClient.getProperties(Aborter.none); - const result3 = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + const result3 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["snapshots"] }); @@ -252,9 +252,9 @@ describe("BlobURL", () => { }); it("undelete", async () => { - const properties = await serviceURL.getProperties(Aborter.none); + const properties = await serviceClient.getProperties(Aborter.none); if (!properties.deleteRetentionPolicy!.enabled) { - await serviceURL.setProperties(Aborter.none, { + await serviceClient.setProperties(Aborter.none, { deleteRetentionPolicy: { days: 7, enabled: true @@ -263,42 +263,48 @@ describe("BlobURL", () => { await sleep(15 * 1000); } - await blobURL.delete(Aborter.none); + await blobClient.delete(Aborter.none); - const result = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + const result = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["deleted"] }); assert.ok(result.segment.blobItems![0].deleted); - await blobURL.undelete(Aborter.none); - const result2 = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blobClient.undelete(Aborter.none); + const result2 = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["deleted"] }); assert.ok(!result2.segment.blobItems![0].deleted); }); - it("startCopyFromURL", async () => { - const newBlobURL = BlobURL.fromContainerURL(containerURL, getUniqueName("copiedblob")); - const result = await newBlobURL.startCopyFromURL(Aborter.none, blobURL.url); + it("startCopyFromClient", async () => { + const newBlobClient = BlobClient.fromContainerClient( + containerClient, + getUniqueName("copiedblob") + ); + const result = await newBlobClient.startCopyFromURL(Aborter.none, blobClient.url); assert.ok(result.copyId); - const properties1 = await blobURL.getProperties(Aborter.none); - const properties2 = await newBlobURL.getProperties(Aborter.none); + const properties1 = await blobClient.getProperties(Aborter.none); + const properties2 = await newBlobClient.getProperties(Aborter.none); assert.deepStrictEqual(properties1.contentMD5, properties2.contentMD5); assert.deepStrictEqual(properties2.copyId, result.copyId); - assert.deepStrictEqual(properties2.copySource, blobURL.url); + assert.deepStrictEqual(properties2.copySource, blobClient.url); }); - it("abortCopyFromURL should failed for a completed copy operation", async () => { - const newBlobURL = BlobURL.fromContainerURL(containerURL, getUniqueName("copiedblob")); - const result = await newBlobURL.startCopyFromURL(Aborter.none, blobURL.url); + it("abortCopyFromClient should failed for a completed copy operation", async () => { + const newBlobClient = BlobClient.fromContainerClient( + containerClient, + getUniqueName("copiedblob") + ); + const result = await newBlobClient.startCopyFromURL(Aborter.none, blobClient.url); assert.ok(result.copyId); sleep(1 * 1000); try { - await newBlobURL.abortCopyFromURL(Aborter.none, result.copyId!); + await newBlobClient.startCopyFromURL(Aborter.none, result.copyId!); assert.fail( - "AbortCopyFromURL should be failed and throw exception for an completed copy operation." + "AbortCopyFromClient should be failed and throw exception for an completed copy operation." ); } catch (err) { assert.ok(true); @@ -306,18 +312,18 @@ describe("BlobURL", () => { }); it("setTier set default to cool", async () => { - await blockBlobURL.setTier(Aborter.none, "Cool"); - const properties = await blockBlobURL.getProperties(Aborter.none); + await blockBlobClient.setTier(Aborter.none, "Cool"); + const properties = await blockBlobClient.getProperties(Aborter.none); assert.equal(properties.accessTier!.toLowerCase(), "cool"); }); it("setTier set archive to hot", async () => { - await blockBlobURL.setTier(Aborter.none, "Archive"); - let properties = await blockBlobURL.getProperties(Aborter.none); + await blockBlobClient.setTier(Aborter.none, "Archive"); + let properties = await blockBlobClient.getProperties(Aborter.none); assert.equal(properties.accessTier!.toLowerCase(), "archive"); - await blockBlobURL.setTier(Aborter.none, "Hot"); - properties = await blockBlobURL.getProperties(Aborter.none); + await blockBlobClient.setTier(Aborter.none, "Hot"); + properties = await blockBlobClient.getProperties(Aborter.none); if (properties.archiveStatus) { assert.equal(properties.archiveStatus.toLowerCase(), "rehydrate-pending-to-hot"); } diff --git a/sdk/storage/storage-blob/test/blockbloburl.test.ts b/sdk/storage/storage-blob/test/blockbloburl.test.ts index 003e59cc4f68..0895ec92b889 100644 --- a/sdk/storage/storage-blob/test/blockbloburl.test.ts +++ b/sdk/storage/storage-blob/test/blockbloburl.test.ts @@ -1,38 +1,38 @@ import * as assert from "assert"; import { Aborter } from "../src/Aborter"; -import { BlobURL } from "../src/BlobURL"; -import { BlockBlobURL } from "../src/BlockBlobURL"; -import { ContainerURL } from "../src/ContainerURL"; +import { BlobClient } from "../src/BlobClient"; +import { BlockBlobClient } from "../src/BlockBlobClient"; +import { ContainerClient } from "../src/ContainerClient"; import { base64encode, bodyToString, getBSU, getUniqueName } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("BlockBlobURL", () => { - const serviceURL = getBSU(); +describe("BlockBlobClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("upload with string body and default parameters", async () => { const body: string = getUniqueName("randomstring"); - await blockBlobURL.upload(Aborter.none, body, body.length); - const result = await blobURL.download(Aborter.none, 0); + await blockBlobClient.upload(Aborter.none, body, body.length); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, body.length), body); }); @@ -49,11 +49,11 @@ describe("BlockBlobURL", () => { keyb: "valb" } }; - await blockBlobURL.upload(Aborter.none, body, body.length, { + await blockBlobClient.upload(Aborter.none, body, body.length, { blobHTTPHeaders: options, metadata: options.metadata }); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, body.length), body); assert.deepStrictEqual(result.cacheControl, options.blobCacheControl); assert.deepStrictEqual(result.contentDisposition, options.blobContentDisposition); @@ -65,9 +65,9 @@ describe("BlockBlobURL", () => { it("stageBlock", async () => { const body = "HelloWorld"; - await blockBlobURL.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobURL.stageBlock(Aborter.none, base64encode("2"), body, body.length); - const listResponse = await blockBlobURL.getBlockList(Aborter.none, "uncommitted"); + await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); + const listResponse = await blockBlobClient.getBlockList(Aborter.none, "uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 2); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, body.length); @@ -77,22 +77,27 @@ describe("BlockBlobURL", () => { it("stageBlockFromURL copy source blob as single block", async () => { const body = "HelloWorld"; - await blockBlobURL.upload(Aborter.none, body, body.length); + await blockBlobClient.upload(Aborter.none, body, body.length); // When testing is in Node.js environment with shared key, setAccessPolicy will work // But in browsers testing with SAS tokens, below will throw an exception, ignore it try { - await containerURL.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy(Aborter.none, "container"); // tslint:disable-next-line:no-empty } catch (err) {} - const newBlockBlobURL = BlockBlobURL.fromContainerURL( - containerURL, + const newBlockBlobClient = BlockBlobClient.fromContainerClient( + containerClient, getUniqueName("newblockblob") ); - await newBlockBlobURL.stageBlockFromURL(Aborter.none, base64encode("1"), blockBlobURL.url, 0); + await newBlockBlobClient.stageBlockFromURL( + Aborter.none, + base64encode("1"), + blockBlobClient.url, + 0 + ); - const listResponse = await newBlockBlobURL.getBlockList(Aborter.none, "uncommitted"); + const listResponse = await newBlockBlobClient.getBlockList(Aborter.none, "uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 1); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, body.length); @@ -100,42 +105,42 @@ describe("BlockBlobURL", () => { it("stageBlockFromURL copy source blob as separate blocks", async () => { const body = "HelloWorld"; - await blockBlobURL.upload(Aborter.none, body, body.length); + await blockBlobClient.upload(Aborter.none, body, body.length); // When testing is in Node.js environment with shared key, setAccessPolicy will work // But in browsers testing with SAS tokens, below will throw an exception, ignore it try { - await containerURL.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy(Aborter.none, "container"); // tslint:disable-next-line:no-empty } catch (err) {} - const newBlockBlobURL = BlockBlobURL.fromContainerURL( - containerURL, + const newBlockBlobClient = BlockBlobClient.fromContainerClient( + containerClient, getUniqueName("newblockblob") ); - await newBlockBlobURL.stageBlockFromURL( + await newBlockBlobClient.stageBlockFromURL( Aborter.none, base64encode("1"), - blockBlobURL.url, + blockBlobClient.url, 0, 4 ); - await newBlockBlobURL.stageBlockFromURL( + await newBlockBlobClient.stageBlockFromURL( Aborter.none, base64encode("2"), - blockBlobURL.url, + blockBlobClient.url, 4, 4 ); - await newBlockBlobURL.stageBlockFromURL( + await newBlockBlobClient.stageBlockFromURL( Aborter.none, base64encode("3"), - blockBlobURL.url, + blockBlobClient.url, 8, 2 ); - const listResponse = await newBlockBlobURL.getBlockList(Aborter.none, "uncommitted"); + const listResponse = await newBlockBlobClient.getBlockList(Aborter.none, "uncommitted"); assert.equal(listResponse.uncommittedBlocks!.length, 3); assert.equal(listResponse.uncommittedBlocks![0].name, base64encode("1")); assert.equal(listResponse.uncommittedBlocks![0].size, 4); @@ -144,22 +149,22 @@ describe("BlockBlobURL", () => { assert.equal(listResponse.uncommittedBlocks![2].name, base64encode("3")); assert.equal(listResponse.uncommittedBlocks![2].size, 2); - await newBlockBlobURL.commitBlockList(Aborter.none, [ + await newBlockBlobClient.commitBlockList(Aborter.none, [ base64encode("1"), base64encode("2"), base64encode("3") ]); - const downloadResponse = await newBlockBlobURL.download(Aborter.none, 0); + const downloadResponse = await newBlockBlobClient.download(Aborter.none, 0); assert.equal(await bodyToString(downloadResponse, 10), body); }); it("commitBlockList", async () => { const body = "HelloWorld"; - await blockBlobURL.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobURL.stageBlock(Aborter.none, base64encode("2"), body, body.length); - await blockBlobURL.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")]); - const listResponse = await blockBlobURL.getBlockList(Aborter.none, "committed"); + await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); + await blockBlobClient.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")]); + const listResponse = await blockBlobClient.getBlockList(Aborter.none, "committed"); assert.equal(listResponse.committedBlocks!.length, 2); assert.equal(listResponse.committedBlocks![0].name, base64encode("1")); assert.equal(listResponse.committedBlocks![0].size, body.length); @@ -169,8 +174,8 @@ describe("BlockBlobURL", () => { it("commitBlockList with all parameters set", async () => { const body = "HelloWorld"; - await blockBlobURL.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobURL.stageBlock(Aborter.none, base64encode("2"), body, body.length); + await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); const options = { blobCacheControl: "blobCacheControl", @@ -183,19 +188,19 @@ describe("BlockBlobURL", () => { keyb: "valb" } }; - await blockBlobURL.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")], { + await blockBlobClient.commitBlockList(Aborter.none, [base64encode("1"), base64encode("2")], { blobHTTPHeaders: options, metadata: options.metadata }); - const listResponse = await blockBlobURL.getBlockList(Aborter.none, "committed"); + const listResponse = await blockBlobClient.getBlockList(Aborter.none, "committed"); assert.equal(listResponse.committedBlocks!.length, 2); assert.equal(listResponse.committedBlocks![0].name, base64encode("1")); assert.equal(listResponse.committedBlocks![0].size, body.length); assert.equal(listResponse.committedBlocks![1].name, base64encode("2")); assert.equal(listResponse.committedBlocks![1].size, body.length); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, body.repeat(2).length), body.repeat(2)); assert.deepStrictEqual(result.cacheControl, options.blobCacheControl); assert.deepStrictEqual(result.contentDisposition, options.blobContentDisposition); @@ -207,10 +212,10 @@ describe("BlockBlobURL", () => { it("getBlockList", async () => { const body = "HelloWorld"; - await blockBlobURL.stageBlock(Aborter.none, base64encode("1"), body, body.length); - await blockBlobURL.stageBlock(Aborter.none, base64encode("2"), body, body.length); - await blockBlobURL.commitBlockList(Aborter.none, [base64encode("2")]); - const listResponse = await blockBlobURL.getBlockList(Aborter.none, "all"); + await blockBlobClient.stageBlock(Aborter.none, base64encode("1"), body, body.length); + await blockBlobClient.stageBlock(Aborter.none, base64encode("2"), body, body.length); + await blockBlobClient.commitBlockList(Aborter.none, [base64encode("2")]); + const listResponse = await blockBlobClient.getBlockList(Aborter.none, "all"); assert.equal(listResponse.committedBlocks!.length, 1); assert.equal(listResponse.uncommittedBlocks!.length, 0); assert.equal(listResponse.committedBlocks![0].name, base64encode("2")); diff --git a/sdk/storage/storage-blob/test/browser/highlevel.browser.test.ts b/sdk/storage/storage-blob/test/browser/highlevel.browser.test.ts index 3d9cae9b2a15..fbfbbbd5cce1 100644 --- a/sdk/storage/storage-blob/test/browser/highlevel.browser.test.ts +++ b/sdk/storage/storage-blob/test/browser/highlevel.browser.test.ts @@ -1,9 +1,9 @@ import * as assert from "assert"; import { Aborter } from "../../src/Aborter"; -import { BlobURL } from "../../src/BlobURL"; -import { BlockBlobURL } from "../../src/BlockBlobURL"; -import { ContainerURL } from "../../src/ContainerURL"; +import { BlobClient } from "../../src/BlobClient"; +import { BlockBlobClient } from "../../src/BlockBlobClient"; +import { ContainerClient } from "../../src/ContainerClient"; import { uploadBrowserDataToBlockBlob } from "../../src/highlevel.browser"; import { arrayBufferEqual, @@ -18,12 +18,12 @@ import { // tslint:disable:no-empty describe("Highelvel", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); let containerName = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); let tempFile1: File; const tempFile1Length: number = 257 * 1024 * 1024 - 1; let tempFile2: File; @@ -31,15 +31,15 @@ describe("Highelvel", () => { beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); before(async () => { @@ -53,7 +53,7 @@ describe("Highelvel", () => { const aborter = Aborter.timeout(1); try { - await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobURL); + await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobClient); assert.fail(); } catch (err) { assert.ok((err.code as string).toLowerCase().includes("abort")); @@ -64,7 +64,7 @@ describe("Highelvel", () => { const aborter = Aborter.timeout(1); try { - await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobURL, { + await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2 }); @@ -79,7 +79,7 @@ describe("Highelvel", () => { const aborter = Aborter.none; try { - await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobURL, { + await uploadBrowserDataToBlockBlob(aborter, tempFile1, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2, progress: (ev) => { @@ -97,7 +97,7 @@ describe("Highelvel", () => { const aborter = Aborter.none; try { - await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobURL, { + await uploadBrowserDataToBlockBlob(aborter, tempFile2, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2, progress: (ev) => { @@ -111,12 +111,12 @@ describe("Highelvel", () => { }); it("uploadBrowserDataToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobURL, { + await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadedString = await bodyToString(downloadResponse); const uploadedString = await blobToString(tempFile2); @@ -124,12 +124,12 @@ describe("Highelvel", () => { }); it("uploadBrowserDataToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES and configured maxSingleShotSize", async () => { - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobURL, { + await uploadBrowserDataToBlockBlob(Aborter.none, tempFile2, blockBlobClient, { blockSize: 512 * 1024, maxSingleShotSize: 0 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadedString = await bodyToString(downloadResponse); const uploadedString = await blobToString(tempFile2); @@ -145,12 +145,12 @@ describe("Highelvel", () => { return; } - await uploadBrowserDataToBlockBlob(Aborter.none, tempFile1, blockBlobURL, { + await uploadBrowserDataToBlockBlob(Aborter.none, tempFile1, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 2 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const buf1 = await blobToArrayBuffer(await downloadResponse.blobBody!); const buf2 = await blobToArrayBuffer(tempFile1); diff --git a/sdk/storage/storage-blob/test/containerurl.test.ts b/sdk/storage/storage-blob/test/containerurl.test.ts index d95bfd74bfe5..1749700a7df9 100644 --- a/sdk/storage/storage-blob/test/containerurl.test.ts +++ b/sdk/storage/storage-blob/test/containerurl.test.ts @@ -1,26 +1,26 @@ import * as assert from "assert"; import { Aborter } from "../src/Aborter"; -import { BlobURL } from "../src/BlobURL"; -import { BlockBlobURL } from "../src/BlockBlobURL"; -import { ContainerURL } from "../src/ContainerURL"; +import { BlobClient } from "../src/BlobClient"; +import { BlockBlobClient } from "../src/BlockBlobClient"; +import { ContainerClient } from "../src/ContainerClient"; import { getBSU, getUniqueName, sleep } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("ContainerURL", () => { - const serviceURL = getBSU(); +describe("ContainerClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("setMetadata", async () => { @@ -29,14 +29,14 @@ describe("ContainerURL", () => { keya: "vala", keyb: "valb" }; - await containerURL.setMetadata(Aborter.none, metadata); + await containerClient.setMetadata(Aborter.none, metadata); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.deepEqual(result.metadata, metadata); }); it("getProperties", async () => { - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.ok(result.eTag!.length > 0); assert.ok(result.lastModified); assert.ok(!result.leaseDuration); @@ -54,11 +54,11 @@ describe("ContainerURL", () => { }); it("create with all parameters configured", async () => { - const cURL = ContainerURL.fromServiceURL(serviceURL, getUniqueName(containerName)); + const cClient = ContainerClient.fromServiceClient(serviceClient, getUniqueName(containerName)); const metadata = { key: "value" }; const access = "container"; - await cURL.create(Aborter.none, { metadata, access }); - const result = await cURL.getProperties(Aborter.none); + await cClient.create(Aborter.none, { metadata, access }); + const result = await cClient.getProperties(Aborter.none); assert.deepEqual(result.blobPublicAccess, access); assert.deepEqual(result.metadata, metadata); }); @@ -71,190 +71,199 @@ describe("ContainerURL", () => { it("acquireLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 30; - await containerURL.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(Aborter.none, guid, duration); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerURL.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(Aborter.none, guid); }); it("releaseLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = -1; - await containerURL.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(Aborter.none, guid, duration); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "infinite"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerURL.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(Aborter.none, guid); }); it("renewLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerURL.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(Aborter.none, guid, duration); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); await sleep(16 * 1000); - const result2 = await containerURL.getProperties(Aborter.none); + const result2 = await containerClient.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "expired"); assert.equal(result2.leaseStatus, "unlocked"); - await containerURL.renewLease(Aborter.none, guid); - const result3 = await containerURL.getProperties(Aborter.none); + await containerClient.renewLease(Aborter.none, guid); + const result3 = await containerClient.getProperties(Aborter.none); assert.equal(result3.leaseDuration, "fixed"); assert.equal(result3.leaseState, "leased"); assert.equal(result3.leaseStatus, "locked"); - await containerURL.releaseLease(Aborter.none, guid); + await containerClient.releaseLease(Aborter.none, guid); }); it("changeLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerURL.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(Aborter.none, guid, duration); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); const newGuid = "3c7e72ebb4304526bc53d8ecef03798f"; - await containerURL.changeLease(Aborter.none, guid, newGuid); + await containerClient.changeLease(Aborter.none, guid, newGuid); - await containerURL.getProperties(Aborter.none); - await containerURL.releaseLease(Aborter.none, newGuid); + await containerClient.getProperties(Aborter.none); + await containerClient.releaseLease(Aborter.none, newGuid); }); it("breakLease", async () => { const guid = "ca761232ed4211cebacd00aa0057b223"; const duration = 15; - await containerURL.acquireLease(Aborter.none, guid, duration); + await containerClient.acquireLease(Aborter.none, guid, duration); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.equal(result.leaseDuration, "fixed"); assert.equal(result.leaseState, "leased"); assert.equal(result.leaseStatus, "locked"); - await containerURL.breakLease(Aborter.none, 3); + await containerClient.breakLease(Aborter.none, 3); - const result2 = await containerURL.getProperties(Aborter.none); + const result2 = await containerClient.getProperties(Aborter.none); assert.ok(!result2.leaseDuration); assert.equal(result2.leaseState, "breaking"); assert.equal(result2.leaseStatus, "locked"); await sleep(3 * 1000); - const result3 = await containerURL.getProperties(Aborter.none); + const result3 = await containerClient.getProperties(Aborter.none); assert.ok(!result3.leaseDuration); assert.equal(result3.leaseState, "broken"); assert.equal(result3.leaseStatus, "unlocked"); }); it("listBlobFlatSegment with default parameters", async () => { - const blobURLs = []; + const blobClients = []; for (let i = 0; i < 3; i++) { - const blobURL = BlobURL.fromContainerURL(containerURL, getUniqueName(`blockblob/${i}`)); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - await blockBlobURL.upload(Aborter.none, "", 0); - blobURLs.push(blobURL); + const blobClient = BlobClient.fromContainerClient( + containerClient, + getUniqueName(`blockblob/${i}`) + ); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + await blockBlobClient.upload(Aborter.none, "", 0); + blobClients.push(blobClient); } - const result = await containerURL.listBlobFlatSegment(Aborter.none); + const result = await containerClient.listBlobFlatSegment(Aborter.none); assert.ok(result.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result.containerName)); + assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.nextMarker, ""); - assert.deepStrictEqual(result.segment.blobItems!.length, blobURLs.length); - assert.ok(blobURLs[0].url.indexOf(result.segment.blobItems![0].name)); + assert.deepStrictEqual(result.segment.blobItems!.length, blobClients.length); + assert.ok(blobClients[0].url.indexOf(result.segment.blobItems![0].name)); - for (const blob of blobURLs) { + for (const blob of blobClients) { await blob.delete(Aborter.none); } }); it("listBlobFlatSegment with all parameters configured", async () => { - const blobURLs = []; + const blobClients = []; const prefix = "blockblob"; const metadata = { keya: "a", keyb: "c" }; for (let i = 0; i < 2; i++) { - const blobURL = BlobURL.fromContainerURL(containerURL, getUniqueName(`${prefix}/${i}`)); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - await blockBlobURL.upload(Aborter.none, "", 0, { + const blobClient = BlobClient.fromContainerClient( + containerClient, + getUniqueName(`${prefix}/${i}`) + ); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + await blockBlobClient.upload(Aborter.none, "", 0, { metadata }); - blobURLs.push(blobURL); + blobClients.push(blobClient); } - const result = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + const result = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["snapshots", "metadata", "uncommittedblobs", "copy", "deleted"], maxresults: 1, prefix }); assert.ok(result.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result.containerName)); + assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.segment.blobItems!.length, 1); - assert.ok(blobURLs[0].url.indexOf(result.segment.blobItems![0].name)); + assert.ok(blobClients[0].url.indexOf(result.segment.blobItems![0].name)); assert.deepStrictEqual(result.segment.blobItems![0].metadata, metadata); - const result2 = await containerURL.listBlobFlatSegment(Aborter.none, result.nextMarker, { + const result2 = await containerClient.listBlobFlatSegment(Aborter.none, result.nextMarker, { include: ["snapshots", "metadata", "uncommittedblobs", "copy", "deleted"], maxresults: 2, prefix }); assert.ok(result2.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result2.containerName)); + assert.ok(containerClient.url.indexOf(result2.containerName)); assert.deepStrictEqual(result2.segment.blobItems!.length, 1); - assert.ok(blobURLs[0].url.indexOf(result2.segment.blobItems![0].name)); + assert.ok(blobClients[0].url.indexOf(result2.segment.blobItems![0].name)); assert.deepStrictEqual(result2.segment.blobItems![0].metadata, metadata); - for (const blob of blobURLs) { + for (const blob of blobClients) { await blob.delete(Aborter.none); } }); it("listBlobHierarchySegment with default parameters", async () => { - const blobURLs = []; + const blobClients = []; for (let i = 0; i < 3; i++) { - const blobURL = BlobURL.fromContainerURL(containerURL, getUniqueName(`blockblob${i}/${i}`)); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - await blockBlobURL.upload(Aborter.none, "", 0); - blobURLs.push(blobURL); + const blobClient = BlobClient.fromContainerClient( + containerClient, + getUniqueName(`blockblob${i}/${i}`) + ); + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + await blockBlobClient.upload(Aborter.none, "", 0); + blobClients.push(blobClient); } const delimiter = "/"; - const result = await containerURL.listBlobHierarchySegment(Aborter.none, delimiter); + const result = await containerClient.listBlobHierarchySegment(Aborter.none, delimiter); assert.ok(result.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result.containerName)); + assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.nextMarker, ""); assert.deepStrictEqual(result.delimiter, delimiter); - assert.deepStrictEqual(result.segment.blobPrefixes!.length, blobURLs.length); + assert.deepStrictEqual(result.segment.blobPrefixes!.length, blobClients.length); - for (const blob of blobURLs) { + for (const blob of blobClients) { let i = 0; assert.ok(blob.url.indexOf(result.segment.blobPrefixes![i++].name)); } - for (const blob of blobURLs) { + for (const blob of blobClients) { await blob.delete(Aborter.none); } }); it("listBlobHierarchySegment with all parameters configured", async () => { - const blobURLs = []; + const blobClients = []; const prefix = "blockblob"; const metadata = { keya: "a", @@ -262,29 +271,34 @@ describe("ContainerURL", () => { }; const delimiter = "/"; for (let i = 0; i < 2; i++) { - const blobURL = BlobURL.fromContainerURL( - containerURL, + const blobClient = BlobClient.fromContainerClient( + containerClient, getUniqueName(`${prefix}${i}${delimiter}${i}`) ); - const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); - await blockBlobURL.upload(Aborter.none, "", 0, { + const blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); + await blockBlobClient.upload(Aborter.none, "", 0, { metadata }); - blobURLs.push(blobURL); + blobClients.push(blobClient); } - const result = await containerURL.listBlobHierarchySegment(Aborter.none, delimiter, undefined, { - include: ["metadata", "uncommittedblobs", "copy", "deleted"], - maxresults: 1, - prefix - }); + const result = await containerClient.listBlobHierarchySegment( + Aborter.none, + delimiter, + undefined, + { + include: ["metadata", "uncommittedblobs", "copy", "deleted"], + maxresults: 1, + prefix + } + ); assert.ok(result.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result.containerName)); + assert.ok(containerClient.url.indexOf(result.containerName)); assert.deepStrictEqual(result.segment.blobPrefixes!.length, 1); assert.deepStrictEqual(result.segment.blobItems!.length, 0); - assert.ok(blobURLs[0].url.indexOf(result.segment.blobPrefixes![0].name)); + assert.ok(blobClients[0].url.indexOf(result.segment.blobPrefixes![0].name)); - const result2 = await containerURL.listBlobHierarchySegment( + const result2 = await containerClient.listBlobHierarchySegment( Aborter.none, delimiter, result.nextMarker, @@ -295,12 +309,12 @@ describe("ContainerURL", () => { } ); assert.ok(result2.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result2.containerName)); + assert.ok(containerClient.url.indexOf(result2.containerName)); assert.deepStrictEqual(result2.segment.blobPrefixes!.length, 1); assert.deepStrictEqual(result2.segment.blobItems!.length, 0); - assert.ok(blobURLs[0].url.indexOf(result2.segment.blobPrefixes![0].name)); + assert.ok(blobClients[0].url.indexOf(result2.segment.blobPrefixes![0].name)); - const result3 = await containerURL.listBlobHierarchySegment( + const result3 = await containerClient.listBlobHierarchySegment( Aborter.none, delimiter, undefined, @@ -311,14 +325,14 @@ describe("ContainerURL", () => { } ); assert.ok(result3.serviceEndpoint.length > 0); - assert.ok(containerURL.url.indexOf(result3.containerName)); + assert.ok(containerClient.url.indexOf(result3.containerName)); assert.deepStrictEqual(result3.nextMarker, ""); assert.deepStrictEqual(result3.delimiter, delimiter); assert.deepStrictEqual(result3.segment.blobItems!.length, 1); assert.deepStrictEqual(result3.segment.blobItems![0].metadata, metadata); - assert.ok(blobURLs[0].url.indexOf(result3.segment.blobItems![0].name)); + assert.ok(blobClients[0].url.indexOf(result3.segment.blobItems![0].name)); - for (const blob of blobURLs) { + for (const blob of blobClients) { await blob.delete(Aborter.none); } }); diff --git a/sdk/storage/storage-blob/test/node/blockbloburl.test.ts b/sdk/storage/storage-blob/test/node/blockbloburl.test.ts index 23dcb33e2fe4..a1d1c5d59b1a 100644 --- a/sdk/storage/storage-blob/test/node/blockbloburl.test.ts +++ b/sdk/storage/storage-blob/test/node/blockbloburl.test.ts @@ -1,38 +1,38 @@ import * as assert from "assert"; import { Aborter } from "../../src/Aborter"; -import { BlobURL } from "../../src/BlobURL"; -import { BlockBlobURL } from "../../src/BlockBlobURL"; -import { ContainerURL } from "../../src/ContainerURL"; +import { BlobClient } from "../../src/BlobClient"; +import { BlockBlobClient } from "../../src/BlockBlobClient"; +import { ContainerClient } from "../../src/ContainerClient"; import { bodyToString, getBSU, getUniqueName } from "../utils"; -describe("BlockBlobURL Node.js only", () => { - const serviceURL = getBSU(); +describe("BlockBlobClient Node.js only", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("upload with Readable stream body and default parameters", async () => { const body: string = getUniqueName("randomstring"); const bodyBuffer = Buffer.from(body); - await blockBlobURL.upload(Aborter.none, bodyBuffer, body.length); - const result = await blobURL.download(Aborter.none, 0); + await blockBlobClient.upload(Aborter.none, bodyBuffer, body.length); + const result = await blobClient.download(Aborter.none, 0); const downloadedBody = await new Promise((resolve, reject) => { const buffer: string[] = []; @@ -50,8 +50,8 @@ describe("BlockBlobURL Node.js only", () => { it("upload with Chinese string body and default parameters", async () => { const body: string = getUniqueName("randomstring你好"); - await blockBlobURL.upload(Aborter.none, body, Buffer.byteLength(body)); - const result = await blobURL.download(Aborter.none, 0); + await blockBlobClient.upload(Aborter.none, body, Buffer.byteLength(body)); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, Buffer.byteLength(body)), body); }); }); diff --git a/sdk/storage/storage-blob/test/node/containerurl.test.ts b/sdk/storage/storage-blob/test/node/containerurl.test.ts index 7317edee4eda..645d16721902 100644 --- a/sdk/storage/storage-blob/test/node/containerurl.test.ts +++ b/sdk/storage/storage-blob/test/node/containerurl.test.ts @@ -1,27 +1,27 @@ import * as assert from "assert"; import { Aborter } from "../../src/Aborter"; -import { ContainerURL } from "../../src/ContainerURL"; +import { ContainerClient } from "../../src/ContainerClient"; import { getBSU, getUniqueName } from "../utils"; import { PublicAccessType } from "../../src/generated/lib/models/index"; -describe("ContainerURL", () => { - const serviceURL = getBSU(); +describe("ContainerClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("getAccessPolicy", async () => { - const result = await containerURL.getAccessPolicy(Aborter.none); + const result = await containerClient.getAccessPolicy(Aborter.none); assert.ok(result.eTag!.length > 0); assert.ok(result.lastModified); assert.ok(result.requestId); @@ -42,8 +42,8 @@ describe("ContainerURL", () => { } ]; - await containerURL.setAccessPolicy(Aborter.none, access, containerAcl); - const result = await containerURL.getAccessPolicy(Aborter.none); + await containerClient.setAccessPolicy(Aborter.none, access, containerAcl); + const result = await containerClient.getAccessPolicy(Aborter.none); assert.deepEqual(result.signedIdentifiers, containerAcl); assert.deepEqual(result.blobPublicAccess, access); }); diff --git a/sdk/storage/storage-blob/test/node/highlevel.node.test.ts b/sdk/storage/storage-blob/test/node/highlevel.node.test.ts index 840dc21b4e88..1c79b37fdff8 100644 --- a/sdk/storage/storage-blob/test/node/highlevel.node.test.ts +++ b/sdk/storage/storage-blob/test/node/highlevel.node.test.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; import * as path from "path"; import { PassThrough } from "stream"; -import { BlobURL, BlockBlobURL, ContainerURL } from "../../src"; +import { BlobClient, BlockBlobClient, ContainerClient } from "../../src"; import { Aborter } from "../../src/Aborter"; import { downloadBlobToBuffer, @@ -15,12 +15,12 @@ import { createRandomLocalFile, getBSU, getUniqueName, readStreamToLocalFile } f // tslint:disable:no-empty describe("Highlevel", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); let containerName = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); let tempFileSmall: string; let tempFileSmallLength: number; let tempFileLarge: string; @@ -29,15 +29,15 @@ describe("Highlevel", () => { beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - blockBlobURL = BlockBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + blockBlobClient = BlockBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); before(async () => { @@ -56,12 +56,12 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob >= BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileLarge, blockBlobURL, { + await uploadFileToBlockBlob(Aborter.none, tempFileLarge, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -73,12 +73,12 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { + await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -90,11 +90,11 @@ describe("Highlevel", () => { }); it("uploadFileToBlockBlob should success when blob < BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES and configured maxSingleShotSize", async () => { - await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { + await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobClient, { maxSingleShotSize: 0 }); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadedFile); @@ -109,7 +109,7 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobURL, { + await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); @@ -123,7 +123,7 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobURL, { + await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20 }); @@ -138,7 +138,7 @@ describe("Highlevel", () => { const aborter = Aborter.none; try { - await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobURL, { + await uploadFileToBlockBlob(aborter, tempFileLarge, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20, progress: (ev) => { @@ -156,7 +156,7 @@ describe("Highlevel", () => { const aborter = Aborter.none; try { - await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobURL, { + await uploadFileToBlockBlob(aborter, tempFileSmall, blockBlobClient, { blockSize: 4 * 1024 * 1024, parallelism: 20, progress: (ev) => { @@ -171,9 +171,9 @@ describe("Highlevel", () => { it("uploadStreamToBlockBlob should success", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobURL, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadFilePath = path.join(tempFolderPath, getUniqueName("downloadFile")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadFilePath); @@ -190,9 +190,9 @@ describe("Highlevel", () => { const bufferStream = new PassThrough(); bufferStream.end(buf); - await uploadStreamToBlockBlob(Aborter.none, bufferStream, blockBlobURL, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(Aborter.none, bufferStream, blockBlobClient, 4 * 1024 * 1024, 20); - const downloadResponse = await blockBlobURL.download(Aborter.none, 0); + const downloadResponse = await blockBlobClient.download(Aborter.none, 0); const downloadFilePath = path.join(tempFolderPath, getUniqueName("downloadFile")); await readStreamToLocalFile(downloadResponse.readableStreamBody!, downloadFilePath); @@ -208,7 +208,7 @@ describe("Highlevel", () => { const aborter = Aborter.timeout(1); try { - await uploadStreamToBlockBlob(aborter, rs, blockBlobURL, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(aborter, rs, blockBlobClient, 4 * 1024 * 1024, 20); assert.fail(); } catch (err) { assert.ok((err.code as string).toLowerCase().includes("abort")); @@ -219,7 +219,7 @@ describe("Highlevel", () => { const rs = fs.createReadStream(tempFileLarge); let eventTriggered = false; - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobURL, 4 * 1024 * 1024, 20, { + await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20, { progress: (ev) => { assert.ok(ev.loadedBytes); eventTriggered = true; @@ -230,10 +230,10 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should success", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobURL, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); const buf = Buffer.alloc(tempFileLargeLength); - await downloadBlobToBuffer(Aborter.none, buf, blockBlobURL, 0, undefined, { + await downloadBlobToBuffer(Aborter.none, buf, blockBlobClient, 0, undefined, { blockSize: 4 * 1024 * 1024, maxRetryRequestsPerBlock: 5, parallelism: 20 @@ -245,11 +245,11 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should abort", async () => { const rs = fs.createReadStream(tempFileLarge); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobURL, 4 * 1024 * 1024, 20); + await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 20); try { const buf = Buffer.alloc(tempFileLargeLength); - await downloadBlobToBuffer(Aborter.timeout(1), buf, blockBlobURL, 0, undefined, { + await downloadBlobToBuffer(Aborter.timeout(1), buf, blockBlobClient, 0, undefined, { blockSize: 4 * 1024 * 1024, maxRetryRequestsPerBlock: 5, parallelism: 20 @@ -262,13 +262,13 @@ describe("Highlevel", () => { it("downloadBlobToBuffer should update progress event", async () => { const rs = fs.createReadStream(tempFileSmall); - await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobURL, 4 * 1024 * 1024, 10); + await uploadStreamToBlockBlob(Aborter.none, rs, blockBlobClient, 4 * 1024 * 1024, 10); let eventTriggered = false; const buf = Buffer.alloc(tempFileSmallLength); const aborter = Aborter.none; try { - await downloadBlobToBuffer(aborter, buf, blockBlobURL, 0, undefined, { + await downloadBlobToBuffer(aborter, buf, blockBlobClient, 0, undefined, { blockSize: 1 * 1024, maxRetryRequestsPerBlock: 5, parallelism: 1, @@ -281,14 +281,19 @@ describe("Highlevel", () => { assert.ok(eventTriggered); }); - it("bloburl.download should success when internal stream unexcepted ends at the stream end", async () => { - const uploadResponse = await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { - blockSize: 4 * 1024 * 1024, - parallelism: 20 - }); + it("blobclient.download should success when internal stream unexcepted ends at the stream end", async () => { + const uploadResponse = await uploadFileToBlockBlob( + Aborter.none, + tempFileSmall, + blockBlobClient, + { + blockSize: 4 * 1024 * 1024, + parallelism: 20 + } + ); let retirableReadableStreamOptions: IRetriableReadableStreamOptions; - const downloadResponse = await blockBlobURL.download(Aborter.none, 0, undefined, { + const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag @@ -314,15 +319,20 @@ describe("Highlevel", () => { assert.ok(downloadedData.equals(uploadedData)); }); - it("bloburl.download should download full data successfully when internal stream unexcepted ends", async () => { - const uploadResponse = await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { - blockSize: 4 * 1024 * 1024, - parallelism: 20 - }); + it("blobclient.download should download full data successfully when internal stream unexcepted ends", async () => { + const uploadResponse = await uploadFileToBlockBlob( + Aborter.none, + tempFileSmall, + blockBlobClient, + { + blockSize: 4 * 1024 * 1024, + parallelism: 20 + } + ); let retirableReadableStreamOptions: IRetriableReadableStreamOptions; let injectedErrors = 0; - const downloadResponse = await blockBlobURL.download(Aborter.none, 0, undefined, { + const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag @@ -348,17 +358,22 @@ describe("Highlevel", () => { assert.ok(downloadedData.equals(uploadedData)); }); - it("bloburl.download should download partial data when internal stream unexcepted ends", async () => { - const uploadResponse = await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { - blockSize: 4 * 1024 * 1024, - parallelism: 20 - }); + it("blobclient.download should download partial data when internal stream unexcepted ends", async () => { + const uploadResponse = await uploadFileToBlockBlob( + Aborter.none, + tempFileSmall, + blockBlobClient, + { + blockSize: 4 * 1024 * 1024, + parallelism: 20 + } + ); const partialSize = 500 * 1024; let retirableReadableStreamOptions: IRetriableReadableStreamOptions; let injectedErrors = 0; - const downloadResponse = await blockBlobURL.download(Aborter.none, 0, partialSize, { + const downloadResponse = await blockBlobClient.download(Aborter.none, 0, partialSize, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag @@ -384,11 +399,16 @@ describe("Highlevel", () => { assert.ok(downloadedData.slice(0, partialSize).equals(uploadedData.slice(0, partialSize))); }); - it("bloburl.download should download data failed when exceeding max stream retry requests", async () => { - const uploadResponse = await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { - blockSize: 4 * 1024 * 1024, - parallelism: 20 - }); + it("blobclient.download should download data failed when exceeding max stream retry requests", async () => { + const uploadResponse = await uploadFileToBlockBlob( + Aborter.none, + tempFileSmall, + blockBlobClient, + { + blockSize: 4 * 1024 * 1024, + parallelism: 20 + } + ); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); @@ -397,7 +417,7 @@ describe("Highlevel", () => { let expectedError = false; try { - const downloadResponse = await blockBlobURL.download(Aborter.none, 0, undefined, { + const downloadResponse = await blockBlobClient.download(Aborter.none, 0, undefined, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag @@ -420,11 +440,16 @@ describe("Highlevel", () => { fs.unlinkSync(downloadedFile); }); - it("bloburl.download should abort after retrys", async () => { - const uploadResponse = await uploadFileToBlockBlob(Aborter.none, tempFileSmall, blockBlobURL, { - blockSize: 4 * 1024 * 1024, - parallelism: 20 - }); + it("blobclient.download should abort after retrys", async () => { + const uploadResponse = await uploadFileToBlockBlob( + Aborter.none, + tempFileSmall, + blockBlobClient, + { + blockSize: 4 * 1024 * 1024, + parallelism: 20 + } + ); const downloadedFile = path.join(tempFolderPath, getUniqueName("downloadfile.")); @@ -434,7 +459,7 @@ describe("Highlevel", () => { try { const aborter = Aborter.none; - const downloadResponse = await blockBlobURL.download(aborter, 0, undefined, { + const downloadResponse = await blockBlobClient.download(aborter, 0, undefined, { blobAccessConditions: { modifiedAccessConditions: { ifMatch: uploadResponse.eTag diff --git a/sdk/storage/storage-blob/test/node/pagebloburl.test.ts b/sdk/storage/storage-blob/test/node/pagebloburl.test.ts index 75464294e997..55919b87de93 100644 --- a/sdk/storage/storage-blob/test/node/pagebloburl.test.ts +++ b/sdk/storage/storage-blob/test/node/pagebloburl.test.ts @@ -1,51 +1,54 @@ import * as assert from "assert"; import { Aborter } from "../../src/Aborter"; -import { BlobURL } from "../../src/BlobURL"; -import { ContainerURL } from "../../src/ContainerURL"; -import { PageBlobURL } from "../../src/PageBlobURL"; +import { BlobClient } from "../../src/BlobClient"; +import { ContainerClient } from "../../src/ContainerClient"; +import { PageBlobClient } from "../../src/PageBlobClient"; import { getBSU, getUniqueName, sleep } from "../utils"; -describe("PageBlobURL", () => { - const serviceURL = getBSU(); +describe("PageBlobClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let pageBlobURL = PageBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let pageBlobClient = PageBlobClient.fromBlobClient(blobClient); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - pageBlobURL = PageBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + pageBlobClient = PageBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("startCopyIncremental", async () => { - await pageBlobURL.create(Aborter.none, 1024, { + await pageBlobClient.create(Aborter.none, 1024, { metadata: { sourcemeta: "val" } }); - await pageBlobURL.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); + await pageBlobClient.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); - let snapshotResult = await pageBlobURL.createSnapshot(Aborter.none); + let snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); assert.ok(snapshotResult.snapshot); - const destPageBlobURL = PageBlobURL.fromContainerURL(containerURL, getUniqueName("page")); + const destPageBlobClient = PageBlobClient.fromContainerClient( + containerClient, + getUniqueName("page") + ); - await containerURL.setAccessPolicy(Aborter.none, "container"); + await containerClient.setAccessPolicy(Aborter.none, "container"); await sleep(5 * 1000); - let copySource = pageBlobURL.withSnapshot(snapshotResult.snapshot!).url; - let copyResponse = await destPageBlobURL.startCopyIncremental(Aborter.none, copySource); + let copySource = pageBlobClient.withSnapshot(snapshotResult.snapshot!).url; + let copyResponse = await destPageBlobClient.startCopyIncremental(Aborter.none, copySource); async function waitForCopy(retries = 0) { if (retries >= 30) { @@ -59,7 +62,7 @@ describe("PageBlobURL", () => { throw new Error("Copy unexcepted aborted."); case "pending": await sleep(3000); - copyResponse = await destPageBlobURL.getProperties(Aborter.none); + copyResponse = await destPageBlobClient.getProperties(Aborter.none); await waitForCopy(++retries); return; case "failed": @@ -71,27 +74,27 @@ describe("PageBlobURL", () => { await waitForCopy(); - let listBlobResponse = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + let listBlobResponse = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["copy", "snapshots"] }); assert.equal(listBlobResponse.segment.blobItems.length, 4); - await pageBlobURL.uploadPages(Aborter.none, "c".repeat(1024), 0, 1024); - snapshotResult = await pageBlobURL.createSnapshot(Aborter.none); + await pageBlobClient.uploadPages(Aborter.none, "c".repeat(1024), 0, 1024); + snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); assert.ok(snapshotResult.snapshot); - copySource = pageBlobURL.withSnapshot(snapshotResult.snapshot!).url; - copyResponse = await destPageBlobURL.startCopyIncremental(Aborter.none, copySource); + copySource = pageBlobClient.withSnapshot(snapshotResult.snapshot!).url; + copyResponse = await destPageBlobClient.startCopyIncremental(Aborter.none, copySource); await waitForCopy(); - listBlobResponse = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + listBlobResponse = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { include: ["copy", "snapshots"] }); assert.equal(listBlobResponse.segment.blobItems.length, 6); - const pageBlobProperties = await destPageBlobURL.getProperties(Aborter.none); + const pageBlobProperties = await destPageBlobClient.getProperties(Aborter.none); assert.equal(pageBlobProperties.metadata!.sourcemeta, "val"); }); }); diff --git a/sdk/storage/storage-blob/test/node/sas.test.ts b/sdk/storage/storage-blob/test/node/sas.test.ts index 2687871d4a64..1acac209cd77 100644 --- a/sdk/storage/storage-blob/test/node/sas.test.ts +++ b/sdk/storage/storage-blob/test/node/sas.test.ts @@ -8,19 +8,19 @@ import { AnonymousCredential, BlobSASPermissions, ContainerSASPermissions, - ContainerURL, + ContainerClient, generateAccountSASQueryParameters, generateBlobSASQueryParameters, - PageBlobURL, - ServiceURL, + PageBlobClient, + ServiceClient, SharedKeyCredential, - StorageURL + StorageClient } from "../../src"; import { SASProtocol } from "../../src/SASQueryParameters"; import { getBSU, getUniqueName } from "../utils"; describe("Shared Access Signature (SAS) generation Node.js only", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); it("generateAccountSASQueryParameters should work", async () => { const now = new Date(); @@ -30,7 +30,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const sas = generateAccountSASQueryParameters( @@ -47,13 +47,13 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ).toString(); - const sasURL = `${serviceURL.url}?${sas}`; - const serviceURLWithSAS = new ServiceURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${serviceClient.url}?${sas}`; + const serviceClientWithSAS = new ServiceClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); - await serviceURLWithSAS.getAccountInfo(Aborter.none); + await serviceClientWithSAS.getAccountInfo(Aborter.none); }); it("generateAccountSASQueryParameters should not work with invalid permission", async () => { @@ -61,7 +61,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const sas = generateAccountSASQueryParameters( @@ -74,15 +74,15 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ).toString(); - const sasURL = `${serviceURL.url}?${sas}`; - const serviceURLWithSAS = new ServiceURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${serviceClient.url}?${sas}`; + const serviceClientWithSAS = new ServiceClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); let error; try { - await serviceURLWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(Aborter.none); } catch (err) { error = err; } @@ -95,7 +95,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const sas = generateAccountSASQueryParameters( @@ -108,15 +108,15 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ).toString(); - const sasURL = `${serviceURL.url}?${sas}`; - const serviceURLWithSAS = new ServiceURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${serviceClient.url}?${sas}`; + const serviceClientWithSAS = new ServiceClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); let error; try { - await serviceURLWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(Aborter.none); } catch (err) { error = err; } @@ -129,7 +129,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const sas = generateAccountSASQueryParameters( @@ -145,15 +145,15 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ).toString(); - const sasURL = `${serviceURL.url}?${sas}`; - const serviceURLWithSAS = new ServiceURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${serviceClient.url}?${sas}`; + const serviceClientWithSAS = new ServiceClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); let error; try { - await serviceURLWithSAS.getProperties(Aborter.none); + await serviceClientWithSAS.getProperties(Aborter.none); } catch (err) { error = err; } @@ -169,12 +169,12 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const containerName = getUniqueName("container"); - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); const containerSAS = generateBlobSASQueryParameters( { @@ -189,14 +189,14 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ); - const sasURL = `${containerURL.url}?${containerSAS}`; - const containerURLwithSAS = new ContainerURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${containerClient.url}?${containerSAS}`; + const containerClientwithSAS = new ContainerClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); - await containerURLwithSAS.listBlobFlatSegment(Aborter.none); - await containerURL.delete(Aborter.none); + await containerClientwithSAS.listBlobFlatSegment(Aborter.none); + await containerClient.delete(Aborter.none); }); it("generateBlobSASQueryParameters should work for blob", async () => { @@ -207,16 +207,16 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const containerName = getUniqueName("container"); - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); const blobName = getUniqueName("blob"); - const blobURL = PageBlobURL.fromContainerURL(containerURL, blobName); - await blobURL.create(Aborter.none, 1024, { + const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); + await blobClient.create(Aborter.none, 1024, { blobHTTPHeaders: { blobContentType: "content-type-original" } @@ -241,20 +241,20 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ); - const sasURL = `${blobURL.url}?${blobSAS}`; - const blobURLwithSAS = new PageBlobURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${blobClient.url}?${blobSAS}`; + const blobClientwithSAS = new PageBlobClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); - const properties = await blobURLwithSAS.getProperties(Aborter.none); + const properties = await blobClientwithSAS.getProperties(Aborter.none); assert.equal(properties.cacheControl, "cache-control-override"); assert.equal(properties.contentDisposition, "content-disposition-override"); assert.equal(properties.contentEncoding, "content-encoding-override"); assert.equal(properties.contentLanguage, "content-language-override"); assert.equal(properties.contentType, "content-type-override"); - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("generateBlobSASQueryParameters should work for blob with special namings", async () => { @@ -265,18 +265,18 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const containerName = getUniqueName("container-with-dash"); - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); const blobName = getUniqueName( "////Upper/blob/empty /another 汉字 ру́сский язы́к ру́сский язы́к عربي/عربى にっぽんご/にほんご . special ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,/'" ); - const blobURL = PageBlobURL.fromContainerURL(containerURL, blobName); - await blobURL.create(Aborter.none, 1024, { + const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); + await blobClient.create(Aborter.none, 1024, { blobHTTPHeaders: { blobContentType: "content-type-original" } @@ -302,20 +302,20 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ); - const sasURL = `${blobURL.url}?${blobSAS}`; - const blobURLwithSAS = new PageBlobURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${blobClient.url}?${blobSAS}`; + const blobClientwithSAS = new PageBlobClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); - const properties = await blobURLwithSAS.getProperties(Aborter.none); + const properties = await blobClientwithSAS.getProperties(Aborter.none); assert.equal(properties.cacheControl, "cache-control-override"); assert.equal(properties.contentDisposition, "content-disposition-override"); assert.equal(properties.contentEncoding, "content-encoding-override"); assert.equal(properties.contentLanguage, "content-language-override"); assert.equal(properties.contentType, "content-type-override"); - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("generateBlobSASQueryParameters should work for blob with access policy", async () => { @@ -326,19 +326,19 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { tmr.setDate(tmr.getDate() + 1); // By default, credential is always the last element of pipeline factories - const factories = serviceURL.pipeline.factories; + const factories = serviceClient.pipeline.factories; const sharedKeyCredential = factories[factories.length - 1]; const containerName = getUniqueName("container"); - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); const blobName = getUniqueName("blob"); - const blobURL = PageBlobURL.fromContainerURL(containerURL, blobName); - await blobURL.create(Aborter.none, 1024); + const blobClient = PageBlobClient.fromContainerClient(containerClient, blobName); + await blobClient.create(Aborter.none, 1024); const id = "unique-id"; - await containerURL.setAccessPolicy(Aborter.none, undefined, [ + await containerClient.setAccessPolicy(Aborter.none, undefined, [ { accessPolicy: { expiry: tmr, @@ -357,13 +357,13 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => { sharedKeyCredential as SharedKeyCredential ); - const sasURL = `${blobURL.url}?${blobSAS}`; - const blobURLwithSAS = new PageBlobURL( - sasURL, - StorageURL.newPipeline(new AnonymousCredential()) + const sasClient = `${blobClient.url}?${blobSAS}`; + const blobClientwithSAS = new PageBlobClient( + sasClient, + StorageClient.newPipeline(new AnonymousCredential()) ); - await blobURLwithSAS.getProperties(Aborter.none); - await containerURL.delete(Aborter.none); + await blobClientwithSAS.getProperties(Aborter.none); + await containerClient.delete(Aborter.none); }); }); diff --git a/sdk/storage/storage-blob/test/pagebloburl.test.ts b/sdk/storage/storage-blob/test/pagebloburl.test.ts index 9be65303de95..aeda23e10a80 100644 --- a/sdk/storage/storage-blob/test/pagebloburl.test.ts +++ b/sdk/storage/storage-blob/test/pagebloburl.test.ts @@ -2,37 +2,37 @@ import * as assert from "assert"; import { bodyToString, getBSU, getUniqueName } from "./utils"; import { Aborter } from "../src/Aborter"; -import { BlobURL } from "../src/BlobURL"; -import { ContainerURL } from "../src/ContainerURL"; -import { PageBlobURL } from "../src/PageBlobURL"; +import { BlobClient } from "../src/BlobClient"; +import { ContainerClient } from "../src/ContainerClient"; +import { PageBlobClient } from "../src/PageBlobClient"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("PageBlobURL", () => { - const serviceURL = getBSU(); +describe("PageBlobClient", () => { + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); let blobName: string = getUniqueName("blob"); - let blobURL = BlobURL.fromContainerURL(containerURL, blobName); - let pageBlobURL = PageBlobURL.fromBlobURL(blobURL); + let blobClient = BlobClient.fromContainerClient(containerClient, blobName); + let pageBlobClient = PageBlobClient.fromBlobClient(blobClient); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); blobName = getUniqueName("blob"); - blobURL = BlobURL.fromContainerURL(containerURL, blobName); - pageBlobURL = PageBlobURL.fromBlobURL(blobURL); + blobClient = BlobClient.fromContainerClient(containerClient, blobName); + pageBlobClient = PageBlobClient.fromBlobClient(blobClient); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("create with default parameters", async () => { - await pageBlobURL.create(Aborter.none, 512); + await pageBlobClient.create(Aborter.none, 512); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); }); @@ -50,12 +50,12 @@ describe("PageBlobURL", () => { key2: "valb" } }; - await pageBlobURL.create(Aborter.none, 512, options); + await pageBlobClient.create(Aborter.none, 512, options); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); - const properties = await blobURL.getProperties(Aborter.none); + const properties = await blobClient.getProperties(Aborter.none); assert.equal(properties.cacheControl, options.blobHTTPHeaders.blobCacheControl); assert.equal(properties.contentDisposition, options.blobHTTPHeaders.blobContentDisposition); assert.equal(properties.contentEncoding, options.blobHTTPHeaders.blobContentEncoding); @@ -66,66 +66,66 @@ describe("PageBlobURL", () => { }); it("uploadPages", async () => { - await pageBlobURL.create(Aborter.none, 1024); + await pageBlobClient.create(Aborter.none, 1024); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.equal(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobURL.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobURL.uploadPages(Aborter.none, "b".repeat(512), 512, 512); + await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); + await pageBlobClient.uploadPages(Aborter.none, "b".repeat(512), 512, 512); - const page1 = await pageBlobURL.download(Aborter.none, 0, 512); - const page2 = await pageBlobURL.download(Aborter.none, 512, 512); + const page1 = await pageBlobClient.download(Aborter.none, 0, 512); + const page2 = await pageBlobClient.download(Aborter.none, 512, 512); assert.equal(await bodyToString(page1, 512), "a".repeat(512)); assert.equal(await bodyToString(page2, 512), "b".repeat(512)); }); it("clearPages", async () => { - await pageBlobURL.create(Aborter.none, 1024); - let result = await blobURL.download(Aborter.none, 0); + await pageBlobClient.create(Aborter.none, 1024); + let result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobURL.uploadPages(Aborter.none, "a".repeat(1024), 0, 1024); - result = await pageBlobURL.download(Aborter.none, 0, 1024); + await pageBlobClient.uploadPages(Aborter.none, "a".repeat(1024), 0, 1024); + result = await pageBlobClient.download(Aborter.none, 0, 1024); assert.deepStrictEqual(await bodyToString(result, 1024), "a".repeat(1024)); - await pageBlobURL.clearPages(Aborter.none, 0, 512); - result = await pageBlobURL.download(Aborter.none, 0, 512); + await pageBlobClient.clearPages(Aborter.none, 0, 512); + result = await pageBlobClient.download(Aborter.none, 0, 512); assert.deepStrictEqual(await bodyToString(result, 512), "\u0000".repeat(512)); }); it("getPageRanges", async () => { - await pageBlobURL.create(Aborter.none, 1024); + await pageBlobClient.create(Aborter.none, 1024); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobURL.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobURL.uploadPages(Aborter.none, "b".repeat(512), 512, 512); + await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); + await pageBlobClient.uploadPages(Aborter.none, "b".repeat(512), 512, 512); - const page1 = await pageBlobURL.getPageRanges(Aborter.none, 0, 512); - const page2 = await pageBlobURL.getPageRanges(Aborter.none, 512, 512); + const page1 = await pageBlobClient.getPageRanges(Aborter.none, 0, 512); + const page2 = await pageBlobClient.getPageRanges(Aborter.none, 512, 512); assert.equal(page1.pageRange![0].end, 511); assert.equal(page2.pageRange![0].end, 1023); }); it("getPageRangesDiff", async () => { - await pageBlobURL.create(Aborter.none, 1024); + await pageBlobClient.create(Aborter.none, 1024); - const result = await blobURL.download(Aborter.none, 0); + const result = await blobClient.download(Aborter.none, 0); assert.deepStrictEqual(await bodyToString(result, 1024), "\u0000".repeat(1024)); - await pageBlobURL.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); + await pageBlobClient.uploadPages(Aborter.none, "b".repeat(1024), 0, 1024); - const snapshotResult = await pageBlobURL.createSnapshot(Aborter.none); + const snapshotResult = await pageBlobClient.createSnapshot(Aborter.none); assert.ok(snapshotResult.snapshot); - await pageBlobURL.uploadPages(Aborter.none, "a".repeat(512), 0, 512); - await pageBlobURL.clearPages(Aborter.none, 512, 512); + await pageBlobClient.uploadPages(Aborter.none, "a".repeat(512), 0, 512); + await pageBlobClient.clearPages(Aborter.none, 512, 512); - const rangesDiff = await pageBlobURL.getPageRangesDiff( + const rangesDiff = await pageBlobClient.getPageRangesDiff( Aborter.none, 0, 1024, @@ -138,19 +138,19 @@ describe("PageBlobURL", () => { }); it("updateSequenceNumber", async () => { - await pageBlobURL.create(Aborter.none, 1024); - let propertiesResponse = await pageBlobURL.getProperties(Aborter.none); + await pageBlobClient.create(Aborter.none, 1024); + let propertiesResponse = await pageBlobClient.getProperties(Aborter.none); - await pageBlobURL.updateSequenceNumber(Aborter.none, "increment"); - propertiesResponse = await pageBlobURL.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber(Aborter.none, "increment"); + propertiesResponse = await pageBlobClient.getProperties(Aborter.none); assert.equal(propertiesResponse.blobSequenceNumber!, 1); - await pageBlobURL.updateSequenceNumber(Aborter.none, "update", 10); - propertiesResponse = await pageBlobURL.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber(Aborter.none, "update", 10); + propertiesResponse = await pageBlobClient.getProperties(Aborter.none); assert.equal(propertiesResponse.blobSequenceNumber!, 10); - await pageBlobURL.updateSequenceNumber(Aborter.none, "max", 100); - propertiesResponse = await pageBlobURL.getProperties(Aborter.none); + await pageBlobClient.updateSequenceNumber(Aborter.none, "max", 100); + propertiesResponse = await pageBlobClient.getProperties(Aborter.none); assert.equal(propertiesResponse.blobSequenceNumber!, 100); }); }); diff --git a/sdk/storage/storage-blob/test/retrypolicy.test.ts b/sdk/storage/storage-blob/test/retrypolicy.test.ts index cb08c6c1252e..9d84c16eec94 100644 --- a/sdk/storage/storage-blob/test/retrypolicy.test.ts +++ b/sdk/storage/storage-blob/test/retrypolicy.test.ts @@ -1,9 +1,9 @@ import { URLBuilder } from "@azure/ms-rest-js"; import * as assert from "assert"; -import { RestError, StorageURL } from "../src"; +import { RestError, StorageClient } from "../src"; import { Aborter } from "../src/Aborter"; -import { ContainerURL } from "../src/ContainerURL"; +import { ContainerClient } from "../src/ContainerClient"; import { Pipeline } from "../src/Pipeline"; import { getBSU, getUniqueName } from "./utils"; import { InjectorPolicyFactory } from "./utils/InjectorPolicyFactory"; @@ -11,18 +11,18 @@ import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); describe("RetryPolicy", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); let containerName: string = getUniqueName("container"); - let containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + let containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); beforeEach(async () => { containerName = getUniqueName("container"); - containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); - await containerURL.create(Aborter.none); + containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); + await containerClient.create(Aborter.none); }); afterEach(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("Retry Policy should work when first request fails with 500", async () => { @@ -33,19 +33,19 @@ describe("RetryPolicy", () => { return new RestError("Server Internal Error", "ServerInternalError", 500); } }); - const factories = containerURL.pipeline.factories.slice(); // clone factories array + const factories = containerClient.pipeline.factories.slice(); // clone factories array factories.push(injector); const pipeline = new Pipeline(factories); - const injectContainerURL = containerURL.withPipeline(pipeline); + const injectContainerClient = containerClient.withPipeline(pipeline); const metadata = { key0: "val0", keya: "vala", keyb: "valb" }; - await injectContainerURL.setMetadata(Aborter.none, metadata); + await injectContainerClient.setMetadata(Aborter.none, metadata); - const result = await containerURL.getProperties(Aborter.none); + const result = await containerClient.getProperties(Aborter.none); assert.deepEqual(result.metadata, metadata); }); @@ -54,13 +54,14 @@ describe("RetryPolicy", () => { return new RestError("Server Internal Error", "ServerInternalError", 500); }); - const credential = containerURL.pipeline.factories[containerURL.pipeline.factories.length - 1]; - const factories = StorageURL.newPipeline(credential, { + const credential = + containerClient.pipeline.factories[containerClient.pipeline.factories.length - 1]; + const factories = StorageClient.newPipeline(credential, { retryOptions: { maxTries: 3 } }).factories; factories.push(injector); const pipeline = new Pipeline(factories); - const injectContainerURL = containerURL.withPipeline(pipeline); + const injectContainerClient = containerClient.withPipeline(pipeline); let hasError = false; try { @@ -69,7 +70,7 @@ describe("RetryPolicy", () => { keya: "vala", keyb: "valb" }; - await injectContainerURL.setMetadata(Aborter.none, metadata); + await injectContainerClient.setMetadata(Aborter.none, metadata); } catch (err) { hasError = true; } @@ -84,7 +85,7 @@ describe("RetryPolicy", () => { } }); - const url = serviceURL.url; + const url = serviceClient.url; const urlParsed = URLBuilder.parse(url); const host = urlParsed.getHost()!; const hostParts = host.split("."); @@ -93,17 +94,18 @@ describe("RetryPolicy", () => { hostParts.unshift(secondaryAccount); const secondaryHost = hostParts.join("."); - const credential = containerURL.pipeline.factories[containerURL.pipeline.factories.length - 1]; - const factories = StorageURL.newPipeline(credential, { + const credential = + containerClient.pipeline.factories[containerClient.pipeline.factories.length - 1]; + const factories = StorageClient.newPipeline(credential, { retryOptions: { maxTries: 2, secondaryHost } }).factories; factories.push(injector); const pipeline = new Pipeline(factories); - const injectContainerURL = containerURL.withPipeline(pipeline); + const injectContainerClient = containerClient.withPipeline(pipeline); let finalRequestURL = ""; try { - const response = await injectContainerURL.getProperties(Aborter.none); + const response = await injectContainerClient.getProperties(Aborter.none); finalRequestURL = response._response.request.url; } catch (err) { finalRequestURL = err.request ? err.request.url : ""; diff --git a/sdk/storage/storage-blob/test/serviceurl.test.ts b/sdk/storage/storage-blob/test/serviceurl.test.ts index 4646ebd71839..51039075c890 100644 --- a/sdk/storage/storage-blob/test/serviceurl.test.ts +++ b/sdk/storage/storage-blob/test/serviceurl.test.ts @@ -1,16 +1,16 @@ import * as assert from "assert"; import { Aborter } from "../src/Aborter"; -import { ContainerURL } from "../src/ContainerURL"; -import { ServiceURL } from "../src/ServiceURL"; +import { ContainerClient } from "../src/ContainerClient"; +import { ServiceClient } from "../src/ServiceClient"; import { getAlternateBSU, getBSU, getUniqueName, wait } from "./utils"; import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -describe("ServiceURL", () => { +describe("ServiceClient", () => { it("ListContainers with default parameters", async () => { - const serviceURL = getBSU(); - const result = await serviceURL.listContainersSegment(Aborter.none); + const serviceClient = getBSU(); + const result = await serviceClient.listContainersSegment(Aborter.none); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); assert.ok(typeof result.version); @@ -28,17 +28,17 @@ describe("ServiceURL", () => { }); it("ListContainers with all parameters configured", async () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); const containerNamePrefix = getUniqueName("container"); const containerName1 = `${containerNamePrefix}x1`; const containerName2 = `${containerNamePrefix}x2`; - const containerURL1 = ContainerURL.fromServiceURL(serviceURL, containerName1); - const containerURL2 = ContainerURL.fromServiceURL(serviceURL, containerName2); - await containerURL1.create(Aborter.none, { metadata: { key: "val" } }); - await containerURL2.create(Aborter.none, { metadata: { key: "val" } }); + const containerClient1 = ContainerClient.fromServiceClient(serviceClient, containerName1); + const containerClient2 = ContainerClient.fromServiceClient(serviceClient, containerName2); + await containerClient1.create(Aborter.none, { metadata: { key: "val" } }); + await containerClient2.create(Aborter.none, { metadata: { key: "val" } }); - const result1 = await serviceURL.listContainersSegment(Aborter.none, undefined, { + const result1 = await serviceClient.listContainersSegment(Aborter.none, undefined, { include: "metadata", maxresults: 1, prefix: containerNamePrefix @@ -55,7 +55,7 @@ describe("ServiceURL", () => { assert.deepEqual(result1.containerItems![0].properties.leaseStatus, "unlocked"); assert.deepEqual(result1.containerItems![0].metadata!.key, "val"); - const result2 = await serviceURL.listContainersSegment(Aborter.none, result1.nextMarker, { + const result2 = await serviceClient.listContainersSegment(Aborter.none, result1.nextMarker, { include: "metadata", maxresults: 1, prefix: containerNamePrefix @@ -72,13 +72,13 @@ describe("ServiceURL", () => { assert.deepEqual(result2.containerItems![0].properties.leaseStatus, "unlocked"); assert.deepEqual(result2.containerItems![0].metadata!.key, "val"); - await containerURL1.delete(Aborter.none); - await containerURL2.delete(Aborter.none); + await containerClient1.delete(Aborter.none); + await containerClient2.delete(Aborter.none); }); it("GetProperties", async () => { - const serviceURL = getBSU(); - const result = await serviceURL.getProperties(Aborter.none); + const serviceClient = getBSU(); + const result = await serviceClient.getProperties(Aborter.none); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); @@ -95,9 +95,9 @@ describe("ServiceURL", () => { }); it("SetProperties", async () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); - const serviceProperties = await serviceURL.getProperties(Aborter.none); + const serviceProperties = await serviceClient.getProperties(Aborter.none); serviceProperties.logging = { deleteProperty: true, @@ -150,10 +150,10 @@ describe("ServiceURL", () => { }; } - await serviceURL.setProperties(Aborter.none, serviceProperties); + await serviceClient.setProperties(Aborter.none, serviceProperties); await wait(5 * 1000); - const result = await serviceURL.getProperties(Aborter.none); + const result = await serviceClient.getProperties(Aborter.none); assert.ok(typeof result.requestId); assert.ok(result.requestId!.length > 0); assert.ok(typeof result.version); @@ -162,15 +162,15 @@ describe("ServiceURL", () => { }); it("getStatistics", (done) => { - let serviceURL: ServiceURL | undefined; + let serviceClient: ServiceClient | undefined; try { - serviceURL = getAlternateBSU(); + serviceClient = getAlternateBSU(); } catch (err) { done(); return; } - serviceURL! + serviceClient! .getStatistics(Aborter.none) .then((result) => { assert.ok(result.geoReplication!.lastSyncTime); @@ -180,9 +180,9 @@ describe("ServiceURL", () => { }); it("getAccountInfo", async () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); - const accountInfo = await serviceURL.getAccountInfo(Aborter.none); + const accountInfo = await serviceClient.getAccountInfo(Aborter.none); assert.ok(accountInfo.accountKind); assert.ok(accountInfo.skuName); }); diff --git a/sdk/storage/storage-blob/test/specialnaming.test.ts b/sdk/storage/storage-blob/test/specialnaming.test.ts index 81fa50114351..6a94d17a3b5c 100644 --- a/sdk/storage/storage-blob/test/specialnaming.test.ts +++ b/sdk/storage/storage-blob/test/specialnaming.test.ts @@ -1,6 +1,6 @@ import { Aborter } from "../src/Aborter"; -import { BlockBlobURL } from "../src/BlockBlobURL"; -import { ContainerURL } from "../src/ContainerURL"; +import { BlockBlobClient } from "../src/BlockBlobClient"; +import { ContainerClient } from "../src/ContainerClient"; import { getBSU, getUniqueName } from "./utils/index"; import * as assert from "assert"; import { appendToURLPath } from "../src/utils/utils.common"; @@ -8,24 +8,24 @@ import * as dotenv from "dotenv"; dotenv.config({ path: "../.env" }); describe("Special Naming Tests", () => { - const serviceURL = getBSU(); + const serviceClient = getBSU(); const containerName: string = getUniqueName("1container-with-dash"); - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName); + const containerClient = ContainerClient.fromServiceClient(serviceClient, containerName); before(async () => { - await containerURL.create(Aborter.none); + await containerClient.create(Aborter.none); }); after(async () => { - await containerURL.delete(Aborter.none); + await containerClient.delete(Aborter.none); }); it("Should work with special container and blob names with spaces", async () => { const blobName: string = getUniqueName("blob empty"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -33,13 +33,13 @@ describe("Special Naming Tests", () => { it("Should work with special container and blob names with spaces in URL string", async () => { const blobName: string = getUniqueName("blob empty"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -47,11 +47,11 @@ describe("Special Naming Tests", () => { it("Should work with special container and blob names with /", async () => { const blobName: string = getUniqueName("////blob/empty /another"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -59,14 +59,14 @@ describe("Special Naming Tests", () => { it("Should work with special container and blob names with / in URL string", async () => { const blobName: string = getUniqueName("////blob/empty /another"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -74,11 +74,11 @@ describe("Special Naming Tests", () => { it("Should work with special container and blob names uppercase", async () => { const blobName: string = getUniqueName("////Upper/blob/empty /another"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -86,14 +86,14 @@ describe("Special Naming Tests", () => { it("Should work with special container and blob names uppercase in URL string", async () => { const blobName: string = getUniqueName("////Upper/blob/empty /another"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -101,11 +101,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob names Chinese characters", async () => { const blobName: string = getUniqueName("////Upper/blob/empty /another 汉字"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -113,14 +113,14 @@ describe("Special Naming Tests", () => { it("Should work with special blob names Chinese characters in URL string", async () => { const blobName: string = getUniqueName("////Upper/blob/empty /another 汉字"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -130,11 +130,11 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName( "汉字. special ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,/'" ); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { // NOTICE: Azure Storage Server will replace "\" with "/" in the blob names prefix: blobName.replace(/\\/g, "/") }); @@ -145,17 +145,17 @@ describe("Special Naming Tests", () => { const blobName: string = getUniqueName( "汉字. special ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,/'" ); - const blockBlobURL = new BlockBlobURL( + const blockBlobClient = new BlockBlobClient( // There are 2 special cases for a URL string: - // Escape "%" when creating XXXURL object with URL strings + // Escape "%" when creating XxxClient object with URL strings // Escape "?" otherwise string after "?" will be treated as URL parameters - appendToURLPath(containerURL.url, blobName.replace(/%/g, "%25").replace(/\?/g, "%3F")), - containerURL.pipeline + appendToURLPath(containerClient.url, blobName.replace(/%/g, "%25").replace(/\?/g, "%3F")), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { // NOTICE: Azure Storage Server will replace "\" with "/" in the blob names prefix: blobName.replace(/\\/g, "/") }); @@ -165,11 +165,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Russian URI encoded", async () => { const blobName: string = getUniqueName("ру́сский язы́к"); const blobNameEncoded: string = encodeURIComponent(blobName); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobNameEncoded); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -177,11 +177,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Russian", async () => { const blobName: string = getUniqueName("ру́сский язы́к"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -189,14 +189,14 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Russian in URL string", async () => { const blobName: string = getUniqueName("ру́сский язы́к"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -205,11 +205,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Arabic URI encoded", async () => { const blobName: string = getUniqueName("عربي/عربى"); const blobNameEncoded: string = encodeURIComponent(blobName); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobNameEncoded); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -217,11 +217,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Arabic", async () => { const blobName: string = getUniqueName("عربي/عربى"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -229,14 +229,14 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Arabic in URL string", async () => { const blobName: string = getUniqueName("عربي/عربى"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -245,11 +245,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Japanese URI encoded", async () => { const blobName: string = getUniqueName("にっぽんご/にほんご"); const blobNameEncoded: string = encodeURIComponent(blobName); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobNameEncoded); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobNameEncoded); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobNameEncoded }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -257,11 +257,11 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Japanese", async () => { const blobName: string = getUniqueName("にっぽんご/にほんご"); - const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName); + const blockBlobClient = BlockBlobClient.fromContainerClient(containerClient, blobName); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); @@ -269,14 +269,14 @@ describe("Special Naming Tests", () => { it("Should work with special blob name Japanese in URL string", async () => { const blobName: string = getUniqueName("にっぽんご/にほんご"); - const blockBlobURL = new BlockBlobURL( - appendToURLPath(containerURL.url, blobName), - containerURL.pipeline + const blockBlobClient = new BlockBlobClient( + appendToURLPath(containerClient.url, blobName), + containerClient.pipeline ); - await blockBlobURL.upload(Aborter.none, "A", 1); - await blockBlobURL.getProperties(Aborter.none); - const response = await containerURL.listBlobFlatSegment(Aborter.none, undefined, { + await blockBlobClient.upload(Aborter.none, "A", 1); + await blockBlobClient.getProperties(Aborter.none); + const response = await containerClient.listBlobFlatSegment(Aborter.none, undefined, { prefix: blobName }); assert.notDeepEqual(response.segment.blobItems.length, 0); diff --git a/sdk/storage/storage-blob/test/utils/index.browser.ts b/sdk/storage/storage-blob/test/utils/index.browser.ts index 295c36993a0c..d4cdb18020bb 100644 --- a/sdk/storage/storage-blob/test/utils/index.browser.ts +++ b/sdk/storage/storage-blob/test/utils/index.browser.ts @@ -1,10 +1,10 @@ import { AnonymousCredential } from "../../src/credentials/AnonymousCredential"; -import { ServiceURL } from "../../src/ServiceURL"; -import { StorageURL } from "../../src/StorageURL"; +import { ServiceClient } from "../../src/ServiceClient"; +import { StorageClient } from "../../src/StorageClient"; export * from "./testutils.common"; -export function getGenericBSU(accountType: string, accountNameSuffix: string = ""): ServiceURL { +export function getGenericBSU(accountType: string, accountNameSuffix: string = ""): ServiceClient { const accountNameEnvVar = `${accountType}ACCOUNT_NAME`; const accountSASEnvVar = `${accountType}ACCOUNT_SAS`; @@ -24,19 +24,19 @@ export function getGenericBSU(accountType: string, accountNameSuffix: string = " } const credentials = new AnonymousCredential(); - const pipeline = StorageURL.newPipeline(credentials, { + const pipeline = StorageClient.newPipeline(credentials, { // Enable logger when debugging // logger: new ConsoleHttpPipelineLogger(HttpPipelineLogLevel.INFO) }); const blobPrimaryURL = `https://${accountName}${accountNameSuffix}.blob.core.windows.net${accountSAS}`; - return new ServiceURL(blobPrimaryURL, pipeline); + return new ServiceClient(blobPrimaryURL, pipeline); } -export function getBSU(): ServiceURL { +export function getBSU(): ServiceClient { return getGenericBSU(""); } -export function getAlternateBSU(): ServiceURL { +export function getAlternateBSU(): ServiceClient { return getGenericBSU("SECONDARY_", "-secondary"); } diff --git a/sdk/storage/storage-blob/test/utils/index.ts b/sdk/storage/storage-blob/test/utils/index.ts index 69ed28382461..9620a50853b8 100644 --- a/sdk/storage/storage-blob/test/utils/index.ts +++ b/sdk/storage/storage-blob/test/utils/index.ts @@ -3,13 +3,13 @@ import * as fs from "fs"; import * as path from "path"; import { SharedKeyCredential } from "../../src/credentials/SharedKeyCredential"; -import { ServiceURL } from "../../src/ServiceURL"; -import { StorageURL } from "../../src/StorageURL"; +import { ServiceClient } from "../../src/ServiceClient"; +import { StorageClient } from "../../src/StorageClient"; import { getUniqueName } from "./testutils.common"; export * from "./testutils.common"; -export function getGenericBSU(accountType: string, accountNameSuffix: string = ""): ServiceURL { +export function getGenericBSU(accountType: string, accountNameSuffix: string = ""): ServiceClient { const accountNameEnvVar = `${accountType}ACCOUNT_NAME`; const accountKeyEnvVar = `${accountType}ACCOUNT_KEY`; @@ -26,19 +26,19 @@ export function getGenericBSU(accountType: string, accountNameSuffix: string = " } const credentials = new SharedKeyCredential(accountName, accountKey); - const pipeline = StorageURL.newPipeline(credentials, { + const pipeline = StorageClient.newPipeline(credentials, { // Enable logger when debugging // logger: new ConsoleHttpPipelineLogger(HttpPipelineLogLevel.INFO) }); const blobPrimaryURL = `https://${accountName}${accountNameSuffix}.blob.core.windows.net/`; - return new ServiceURL(blobPrimaryURL, pipeline); + return new ServiceClient(blobPrimaryURL, pipeline); } -export function getBSU(): ServiceURL { +export function getBSU(): ServiceClient { return getGenericBSU(""); } -export function getAlternateBSU(): ServiceURL { +export function getAlternateBSU(): ServiceClient { return getGenericBSU("SECONDARY_", "-secondary"); } From f3b3f342c63547baddcefbb06d158627ea4d44f8 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Tue, 14 May 2019 15:13:59 -0700 Subject: [PATCH 2/2] Rename test files after the client rename --- .../test/{appendbloburl.test.ts => appendblobclient.test.ts} | 0 .../storage-blob/test/{bloburl.test.ts => blobclient.test.ts} | 0 .../test/{serviceurl.test.ts => blobserviceclient.test.ts} | 0 .../test/{blockbloburl.test.ts => blockblobclient.test.ts} | 0 .../test/{containerurl.test.ts => containerclient.test.ts} | 0 .../test/node/{blockbloburl.test.ts => blockblobclient.test.ts} | 0 .../test/node/{containerurl.test.ts => containerclient.test.ts} | 0 .../test/node/{pagebloburl.test.ts => pageblobclient.test.ts} | 0 .../test/{pagebloburl.test.ts => pageblobclient.test.ts} | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename sdk/storage/storage-blob/test/{appendbloburl.test.ts => appendblobclient.test.ts} (100%) rename sdk/storage/storage-blob/test/{bloburl.test.ts => blobclient.test.ts} (100%) rename sdk/storage/storage-blob/test/{serviceurl.test.ts => blobserviceclient.test.ts} (100%) rename sdk/storage/storage-blob/test/{blockbloburl.test.ts => blockblobclient.test.ts} (100%) rename sdk/storage/storage-blob/test/{containerurl.test.ts => containerclient.test.ts} (100%) rename sdk/storage/storage-blob/test/node/{blockbloburl.test.ts => blockblobclient.test.ts} (100%) rename sdk/storage/storage-blob/test/node/{containerurl.test.ts => containerclient.test.ts} (100%) rename sdk/storage/storage-blob/test/node/{pagebloburl.test.ts => pageblobclient.test.ts} (100%) rename sdk/storage/storage-blob/test/{pagebloburl.test.ts => pageblobclient.test.ts} (100%) diff --git a/sdk/storage/storage-blob/test/appendbloburl.test.ts b/sdk/storage/storage-blob/test/appendblobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/appendbloburl.test.ts rename to sdk/storage/storage-blob/test/appendblobclient.test.ts diff --git a/sdk/storage/storage-blob/test/bloburl.test.ts b/sdk/storage/storage-blob/test/blobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/bloburl.test.ts rename to sdk/storage/storage-blob/test/blobclient.test.ts diff --git a/sdk/storage/storage-blob/test/serviceurl.test.ts b/sdk/storage/storage-blob/test/blobserviceclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/serviceurl.test.ts rename to sdk/storage/storage-blob/test/blobserviceclient.test.ts diff --git a/sdk/storage/storage-blob/test/blockbloburl.test.ts b/sdk/storage/storage-blob/test/blockblobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/blockbloburl.test.ts rename to sdk/storage/storage-blob/test/blockblobclient.test.ts diff --git a/sdk/storage/storage-blob/test/containerurl.test.ts b/sdk/storage/storage-blob/test/containerclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/containerurl.test.ts rename to sdk/storage/storage-blob/test/containerclient.test.ts diff --git a/sdk/storage/storage-blob/test/node/blockbloburl.test.ts b/sdk/storage/storage-blob/test/node/blockblobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/node/blockbloburl.test.ts rename to sdk/storage/storage-blob/test/node/blockblobclient.test.ts diff --git a/sdk/storage/storage-blob/test/node/containerurl.test.ts b/sdk/storage/storage-blob/test/node/containerclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/node/containerurl.test.ts rename to sdk/storage/storage-blob/test/node/containerclient.test.ts diff --git a/sdk/storage/storage-blob/test/node/pagebloburl.test.ts b/sdk/storage/storage-blob/test/node/pageblobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/node/pagebloburl.test.ts rename to sdk/storage/storage-blob/test/node/pageblobclient.test.ts diff --git a/sdk/storage/storage-blob/test/pagebloburl.test.ts b/sdk/storage/storage-blob/test/pageblobclient.test.ts similarity index 100% rename from sdk/storage/storage-blob/test/pagebloburl.test.ts rename to sdk/storage/storage-blob/test/pageblobclient.test.ts