diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 954c8058af96..2b6778ff23a5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,7 +13,7 @@ /sdk/core/ @alzimmermsft @jianghaolu @srnagar @hemanttanwar /sdk/cosmos/ @moderakh @christopheranderson @kushagraThapar /sdk/eventhubs/ @conniey @srnagar @mssfang -/sdk/identity/ @jianghaolu @g2vinay +/sdk/identity/ @jianghaolu @g2vinay @hemanttanwar /sdk/keyvault/ @g2vinay @samvaity /sdk/servicebus/ @yvgopal @nemakam /sdk/tracing/ @samvaity @alzimmermsft diff --git a/containerregistry/resource-manager/v2016_06_27_preview/pom.xml b/containerregistry/resource-manager/v2016_06_27_preview/pom.xml index 64400aeff25d..6bc1f83e6ce1 100644 --- a/containerregistry/resource-manager/v2016_06_27_preview/pom.xml +++ b/containerregistry/resource-manager/v2016_06_27_preview/pom.xml @@ -11,8 +11,8 @@ com.microsoft.azure azure-arm-parent - 1.1.0 - ../../../pom.management.xml + 0.0.3-beta + ../../../pom.xml azure-mgmt-containerregistry 1.0.0-beta diff --git a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java index c2e2caedfee1..8d15a0f13656 100644 --- a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java +++ b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java @@ -4,10 +4,6 @@ package com.azure.security.keyvault.keys; import com.azure.core.credentials.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.VoidResponse; import com.azure.core.util.Context; diff --git a/storage/client/blob/CHANGELOG.md b/storage/client/blob/CHANGELOG.md index 32e9b8a3e4a4..27a9660550d7 100644 --- a/storage/client/blob/CHANGELOG.md +++ b/storage/client/blob/CHANGELOG.md @@ -7,7 +7,7 @@ https://aka.ms/azure-sdk-preview1-java. **Breaking changes: New API design** - Operations are now scoped to a particular client: - - `StorageClient`: StorageURL's functionality was migrated to StorageClient. This client handles account-level operations. This includes managing service properties and listing the containers within an account. + - `BlobServiceClient`: StorageURL's functionality was migrated to BlobServiceClient. This client handles account-level operations. This includes managing service properties and listing the containers within an account. - `ContainerClient`: ContainerURL's functionality was migrated to ContainerClient. The client handles operations for a particular container. This includes creating or deleting that container, as well as listing the blobs within that container. - `BlobClient`: BlobURL's functionality was migrated to BlobClient, TransferManager download functionality was migrated to BlobClient and TransferManager upload functionality was migrated to BlockBlobClient. The client handles most operations, excluding upload, for an individual blob, including downloading data and working with blob properties. There are subclients (BlockBlobClient, PageBlobClient, AppendBlobClient) available for their respective blob types on the service. diff --git a/storage/client/blob/README.md b/storage/client/blob/README.md index 5a90220c5ed7..a819bc1e98ba 100644 --- a/storage/client/blob/README.md +++ b/storage/client/blob/README.md @@ -97,9 +97,9 @@ Blob storage is designed for: The following sections provide several code snippets covering some of the most common Azure Storage Blob tasks, including: -- [Create storage client](#create-storage-client) -- [Create container client](#create-container-client) -- [Create blob client](#create-blob-client) +- [Create BlobServiceClient](#create-blobserviceclient) +- [Create ContainerClient](#create-containerclient) +- [Create BlobClient](#create-blobclient) - [Create a container](#create-a-container) - [Upload a blob from InputStream](#uploading-a-blob-from-a-stream) - [Upload a blob from File](#uploading-a-blob-from-file) @@ -108,70 +108,70 @@ The following sections provide several code snippets covering some of the most c - [Enumerating blobs](#enumerating-blobs) - [Authenticate with Azure.Identity](#authenticate-with-azureidentity) -### Create storage client +### Create BlobServiceClient -Create a storage client using the [`sasToken`](#get-credentials) generated above. +Create a BlobServiceClient using the [`sasToken`](#get-credentials) generated above. ```java -StorageClient storageClient = StorageClient.builder() +BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() .endpoint("") .credential("") - .build(); + .buildClient(); ``` -### Create container client +### Create ContainerClient -Create a container client if storage client exists. +Create a ContainerClient if a BlobServiceClient exists. ```java -ContainerClient containerClient = storageClient.getContainerClient("mycontainer"); +ContainerClient containerClient = blobServiceClient.getContainerClient("mycontainer"); ``` or -Create the container client from the builder [`sasToken`](#get-credentials) generated above. +Create the ContainerClient from the builder [`sasToken`](#get-credentials) generated above. ```java -ContainerClient containerClient = ContainerClient.builder() +ContainerClient containerClient = new ContainerClientBuilder() .endpoint("") .credential("") .containerName("mycontainer") - .build(); + .buildClient(); ``` -### Create blob client +### Create BlobClient -Create a blob client if container client exists. +Create a BlobClient if container client exists. ```java BlobClient blobClient = containerClient.getBlobClient("myblob"); ``` or -Create the blob client from the builder [`sasToken`](#get-credentials) generated above. +Create the BlobClient from the builder [`sasToken`](#get-credentials) generated above. ```java -BlobClient blobClient = BlobClient.builder() +BlobClient blobClient = new BlobClientBuilder() .endpoint("") .credential("") .containerName("mycontainer") .blobName("myblob") - .build(); + .buildBlobClient(); ``` ### Create a container -Create a container from storage client. +Create a container from a BlobServiceClient. ```java -storageClient.createContainer("mycontainer"); +blobServiceClient.createContainer("mycontainer"); ``` or -Create a container using container client. +Create a container using ContainerClient. ```java containerClient.create(); ``` ### Uploading a blob from a stream -Upload data stream to a blob using blockBlobClient generated from containerClient. +Upload data stream to a blob using BlockBlobClient generated from a ContainerClient. ```java BlockBlobClient blockBlobClient = containerClient.getBlockBlobClient("myblockblob"); @@ -183,7 +183,7 @@ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBy ### Uploading a blob from `File` -Upload a file to a blob using blockBlobClient generated from containerClient. +Upload a file to a blob using BlockBlobClient generated from ContainerClient. ```java BlockBlobClient blockBlobClient = containerClient.getBlockBlobClient("myblockblob"); @@ -192,7 +192,7 @@ blobClient.uploadFromFile("local-file.jpg"); ### Downloading a blob to output stream -Download blob to output stream using blobClient. +Download blob to output stream using BlobClient. ```java try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream("downloaded-file.jpg")) { @@ -202,14 +202,14 @@ try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream("downloaded-f ### Downloading a blob to local path -Download blob to local file using blobClient. +Download blob to local file using BlobClient. ```java blobClient.downloadToFile("downloaded-file.jpg"); ``` ### Enumerating blobs -Enumerating all blobs using `ContainerClient` +Enumerating all blobs using ContainerClient ```java containerClient.listBlobsFlat() .forEach( @@ -222,7 +222,7 @@ containerClient.listBlobsFlat() The [Azure Identity library][identity] provides Azure Active Directory support for authenticating with Azure Storage. ```java -StorageClient storageClient = StorageClient.storageClientBuilder() +BlobServiceClient storageClient = BlobServiceClient.storageClientBuilder() .endpoint(endpoint) .credential(new DefaultAzureCredential()) .buildClient(); diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/AnonymousCredentialPolicy.java b/storage/client/blob/src/main/java/com/azure/storage/blob/AnonymousCredentialPolicy.java index d54b264702f6..d5b1b30df030 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/AnonymousCredentialPolicy.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/AnonymousCredentialPolicy.java @@ -13,7 +13,7 @@ * Anonymous credentials are to be used with with HTTP(S) requests that read blobs from public containers or requests * that use a Shared Access Signature (SAS). This is because Anonymous credentials will not set an Authorization header. * Pass an instance of this class as the credentials parameter when creating a new pipeline (typically with - * {@link StorageClient}). + * {@link BlobServiceClient}). */ public final class AnonymousCredentialPolicy implements HttpPipelinePolicy { diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java index 7275f0fb326f..af64a840c8cc 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobAsyncClient.java @@ -32,7 +32,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient}, - * and operations on the service are available on {@link StorageAsyncClient}. + * and operations on the service are available on {@link BlobServiceAsyncClient}. * *

* Please refer diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java index 246fe645af17..65468a2e42b5 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/AppendBlobClient.java @@ -31,7 +31,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient}, - * and operations on the service are available on {@link StorageClient}. + * and operations on the service are available on {@link BlobServiceClient}. * *

* Please refer to the Azure Docs diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java index 1e5f741d3b8a..ad598f8a8983 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java @@ -59,7 +59,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient}, - * and operations on the service are available on {@link StorageAsyncClient}. + * and operations on the service are available on {@link BlobServiceAsyncClient}. * *

* Please refer to the Azure @@ -71,7 +71,6 @@ * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. */ -@SuppressWarnings({"unused", "WeakerAccess"}) public class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; @@ -127,7 +126,7 @@ public PageBlobAsyncClient asPageBlobAsyncClient() { /** * Initializes a {@link ContainerAsyncClient} object pointing to the container this blob is in. This method does not - * create a container. It simply constructs the URL to the container and offers access to methods relevant to + * create a container. It simply constructs the client to the container and offers access to methods relevant to * containers. * * @return A {@link ContainerAsyncClient} object pointing to the container containing the blob @@ -158,7 +157,11 @@ public URL getBlobUrl() { } /** - * Gets if the blob this client represents exists in the cloud. + * Determines if the blob this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.exists} * * @return true if the blob exists, false if it doesn't */ @@ -172,8 +175,14 @@ public Mono> exists() { } /** - * Copies the data at the source URL to a blob. For more information, see the - * Azure Docs + * Copies the data at the source URL to a blob. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL} + * + *

For more information, see the + * Azure Docs

* * @param sourceURL The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @return A reactive response containing the copy ID for the long running operation. @@ -183,8 +192,14 @@ public Mono> startCopyFromURL(URL sourceURL) { } /** - * Copies the data at the source URL to a blob. For more information, see the - * Azure Docs + * Copies the data at the source URL to a blob. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

* * @param sourceURL The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @param metadata {@link Metadata} @@ -217,6 +232,13 @@ public Mono> startCopyFromURL(URL sourceURL, Metadata metadata, /** * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String} + * + *

For more information, see the + * Azure Docs

+ * * @param copyId The id of the copy operation to abort. Returned as the {@code copyId} field on the {@link * BlobStartCopyFromURLHeaders} object. * @return A reactive response signalling completion. @@ -228,6 +250,13 @@ public Mono abortCopyFromURL(String copyId) { /** * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String-LeaseAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param copyId The id of the copy operation to abort. Returned as the {@code copyId} field on the {@link * BlobStartCopyFromURLHeaders} object. * @param leaseAccessConditions By setting lease access conditions, requests will fail if the provided lease does @@ -243,6 +272,13 @@ public Mono abortCopyFromURL(String copyId, LeaseAccessConditions /** * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL} + * + *

For more information, see the + * Azure Docs

+ * * @param copySource The source URL to copy from. * @return A reactive response containing the copy ID for the long running operation. */ @@ -253,6 +289,13 @@ public Mono> copyFromURL(URL copySource) { /** * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @param metadata {@link Metadata} * @param sourceModifiedAccessConditions {@link ModifiedAccessConditions} against the source. Standard HTTP Access @@ -285,23 +328,37 @@ public Mono> copyFromURL(URL copySource, Metadata metadata, Mod * Reads the entire blob. Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or * {@link AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.download} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response containing the blob data. */ public Mono>> download() { - return this.download(null, null, false, null); + return this.download(null, null, null, false); } /** * Reads a range of bytes from a blob. Uploading data must be done from the {@link BlockBlobClient}, {@link * PageBlobClient}, or {@link AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.download#BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean} + * + *

For more information, see the + * Azure Docs

+ * * @param range {@link BlobRange} + * @param options {@link ReliableDownloadOptions} * @param accessConditions {@link BlobAccessConditions} * @param rangeGetContentMD5 Whether the contentMD5 for the specified blob range should be returned. - * @param options {@link ReliableDownloadOptions} * @return A reactive response containing the blob data. */ - public Mono>> download(BlobRange range, BlobAccessConditions accessConditions, boolean rangeGetContentMD5, ReliableDownloadOptions options) { + public Mono>> download(BlobRange range, ReliableDownloadOptions options, BlobAccessConditions accessConditions, boolean rangeGetContentMD5) { return this.download(range, accessConditions, rangeGetContentMD5) .map(response -> new SimpleResponse<>( response.rawResponse(), @@ -359,11 +416,18 @@ Mono download(BlobRange range, BlobAccessConditions acces * This method makes an extra HTTP call to get the length of the blob in the beginning. To avoid this extra call, * use the other overload providing the {@link BlobRange} parameter. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.downloadToFile#String} + * + *

For more information, see the + * Azure Docs

+ * * @param filePath A non-null {@link OutputStream} instance where the downloaded data will be written. * @return An empty response */ public Mono downloadToFile(String filePath) { - return this.downloadToFile(filePath, null, BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE, null, false, null); + return this.downloadToFile(filePath, null, BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE, null, null, false); } /** @@ -374,18 +438,25 @@ public Mono downloadToFile(String filePath) { * This method makes an extra HTTP call to get the length of the blob in the beginning. To avoid this extra call, * provide the {@link BlobRange} parameter. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean} + * + *

For more information, see the + * Azure Docs

+ * * @param filePath A non-null {@link OutputStream} instance where the downloaded data will be written. * @param range {@link BlobRange} * @param blockSize the size of a chunk to download at a time, in bytes + * @param options {@link ReliableDownloadOptions} * @param accessConditions {@link BlobAccessConditions} * @param rangeGetContentMD5 Whether the contentMD5 for the specified blob range should be returned. - * @param options {@link ReliableDownloadOptions} * @return An empty response * @throws IllegalArgumentException If {@code blockSize} is less than 0 or greater than 100MB. * @throws UncheckedIOException If an I/O error occurs. */ - public Mono downloadToFile(String filePath, BlobRange range, Integer blockSize, BlobAccessConditions accessConditions, - boolean rangeGetContentMD5, ReliableDownloadOptions options) { + public Mono downloadToFile(String filePath, BlobRange range, Integer blockSize, ReliableDownloadOptions options, + BlobAccessConditions accessConditions, boolean rangeGetContentMD5) { if (blockSize < 0 || blockSize > BLOB_MAX_DOWNLOAD_BLOCK_SIZE) { throw new IllegalArgumentException("Block size should not exceed 100MB"); } @@ -440,6 +511,13 @@ private List sliceBlobRange(BlobRange blobRange, Integer blockSize) { /** * Deletes the specified blob or snapshot. Note that deleting a blob also deletes all its snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.delete} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response signalling completion. */ public Mono delete() { @@ -449,6 +527,13 @@ public Mono delete() { /** * Deletes the specified blob or snapshot. Note that deleting a blob also deletes all its snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being * deleted, you must pass null. @@ -468,6 +553,13 @@ public Mono delete(DeleteSnapshotsOptionType deleteBlobSnapshotOpt /** * Returns the blob's metadata and properties. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.getProperties} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response containing the blob properties and metadata. */ public Mono> getProperties() { @@ -477,6 +569,13 @@ public Mono> getProperties() { /** * Returns the blob's metadata and properties. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.getProperties#BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param accessConditions {@link BlobAccessConditions} * @return A reactive response containing the blob properties and metadata. */ @@ -492,9 +591,14 @@ public Mono> getProperties(BlobAccessConditions accessC /** * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. For more information, - * see the - * Azure Docs. + * order to preserve existing values, they must be passed alongside the header being changed. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders} + * + *

For more information, see the + * Azure Docs

* * @param headers {@link BlobHTTPHeaders} * @return A reactive response signalling completion. @@ -505,9 +609,14 @@ public Mono setHTTPHeaders(BlobHTTPHeaders headers) { /** * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. For more information, - * see the - * Azure Docs. + * order to preserve existing values, they must be passed alongside the header being changed. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

* * @param headers {@link BlobHTTPHeaders} * @param accessConditions {@link BlobAccessConditions} @@ -524,8 +633,14 @@ public Mono setHTTPHeaders(BlobHTTPHeaders headers, BlobAccessCond /** * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. For more information, see the - * Azure Docs. + * must be preserved, they must be downloaded and included in the call to this method. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata} + * + *

For more information, see the + * Azure Docs

* * @param metadata {@link Metadata} * @return A reactive response signalling completion. @@ -536,8 +651,14 @@ public Mono setMetadata(Metadata metadata) { /** * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. For more information, see the - * Azure Docs. + * must be preserved, they must be downloaded and included in the call to this method. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

* * @param metadata {@link Metadata} * @param accessConditions {@link BlobAccessConditions} @@ -557,6 +678,13 @@ public Mono setMetadata(Metadata metadata, BlobAccessConditions ac /** * Creates a read-only snapshot of a blob. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.createSnapshot} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response containing the ID of the new snapshot. */ public Mono> createSnapshot() { @@ -566,6 +694,13 @@ public Mono> createSnapshot() { /** * Creates a read-only snapshot of a blob. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.createSnapshot#Metadata-BlobAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param metadata {@link Metadata} * @param accessConditions {@link BlobAccessConditions} * @return A reactive response containing the ID of the new snapshot. @@ -587,6 +722,13 @@ public Mono> createSnapshot(Metadata metadata, BlobAccessCondit * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's * etag. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier} + * + *

For more information, see the + * Azure Docs

+ * * @param tier The new tier for the blob. * @return A reactive response signalling completion. */ @@ -600,6 +742,13 @@ public Mono setTier(AccessTier tier) { * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's * etag. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier-LeaseAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param tier The new tier for the blob. * @param leaseAccessConditions By setting lease access conditions, requests will fail if the provided lease does * not match the active lease on the blob. @@ -616,6 +765,13 @@ public Mono setTier(AccessTier tier, LeaseAccessConditions leaseAc /** * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.undelete} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response signalling completion. */ public Mono undelete() { @@ -628,6 +784,13 @@ public Mono undelete() { * Acquires a lease on the blob for write and delete operations. The lease duration must be between 15 to 60 * seconds, or infinite (-1). * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int} + * + *

For more information, see the + * Azure Docs

+ * * @param proposedId A {@code String} in any valid GUID format. May be null. * @param duration The duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A * non-infinite lease can be between 15 and 60 seconds. @@ -641,7 +804,14 @@ public Mono> acquireLease(String proposedId, int duration) { * Acquires a lease on the blob for write and delete operations. The lease duration must be between 15 to 60 * seconds, or infinite (-1). * - * @param proposedID A {@code String} in any valid GUID format. May be null. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int-ModifiedAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * + * @param proposedId A {@code String} in any valid GUID format. May be null. * @param duration The duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A * non-infinite lease can be between 15 and 60 seconds. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and @@ -650,7 +820,7 @@ public Mono> acquireLease(String proposedId, int duration) { * @return A reactive response containing the lease ID. * @throws IllegalArgumentException If {@code duration} is outside the bounds of 15 to 60 or isn't -1. */ - public Mono> acquireLease(String proposedID, int duration, ModifiedAccessConditions modifiedAccessConditions) { + public Mono> acquireLease(String proposedId, int duration, ModifiedAccessConditions modifiedAccessConditions) { if (!(duration == -1 || (duration >= 15 && duration <= 60))) { // Throwing is preferred to Mono.error because this will error out immediately instead of waiting until // subscription. @@ -658,7 +828,7 @@ public Mono> acquireLease(String proposedID, int duration, Modi } return postProcessResponse(this.azureBlobStorage.blobs().acquireLeaseWithRestResponseAsync( - null, null, null, duration, proposedID, null, + null, null, null, duration, proposedId, null, modifiedAccessConditions, Context.NONE)) .map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().leaseId())); } @@ -666,50 +836,78 @@ public Mono> acquireLease(String proposedID, int duration, Modi /** * Renews the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.renewLease#String} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @return A reactive response containing the renewed lease ID. */ - public Mono> renewLease(String leaseID) { - return this.renewLease(leaseID, null); + public Mono> renewLease(String leaseId) { + return this.renewLease(leaseId, null); } /** * Renews the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.renewLease#String-ModifiedAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @return A reactive response containing the renewed lease ID. */ - public Mono> renewLease(String leaseID, ModifiedAccessConditions modifiedAccessConditions) { + public Mono> renewLease(String leaseId, ModifiedAccessConditions modifiedAccessConditions) { return postProcessResponse(this.azureBlobStorage.blobs().renewLeaseWithRestResponseAsync(null, - null, leaseID, null, null, modifiedAccessConditions, Context.NONE)) + null, leaseId, null, null, modifiedAccessConditions, Context.NONE)) .map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().leaseId())); } /** * Releases the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.releaseLease#String} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @return A reactive response signalling completion. */ - public Mono releaseLease(String leaseID) { - return this.releaseLease(leaseID, null); + public Mono releaseLease(String leaseId) { + return this.releaseLease(leaseId, null); } /** * Releases the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.releaseLease#String-ModifiedAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @return A reactive response signalling completion. */ - public Mono releaseLease(String leaseID, ModifiedAccessConditions modifiedAccessConditions) { + public Mono releaseLease(String leaseId, ModifiedAccessConditions modifiedAccessConditions) { return postProcessResponse(this.azureBlobStorage.blobs().releaseLeaseWithRestResponseAsync(null, - null, leaseID, null, null, modifiedAccessConditions, Context.NONE)) + null, leaseId, null, null, modifiedAccessConditions, Context.NONE)) .map(VoidResponse::new); } @@ -717,6 +915,13 @@ public Mono releaseLease(String leaseID, ModifiedAccessConditions * BreakLease breaks the blob's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1) constant * to break a fixed-duration lease when it expires or an infinite lease immediately. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.breakLease} + * + *

For more information, see the + * Azure Docs

+ * * @return A reactive response containing the remaining time in the broken lease in seconds. */ public Mono> breakLease() { @@ -727,6 +932,13 @@ public Mono> breakLease() { * BreakLease breaks the blob's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1) constant * to break a fixed-duration lease when it expires or an infinite lease immediately. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.breakLease#Integer-ModifiedAccessConditions} + * + *

For more information, see the + * Azure Docs

+ * * @param breakPeriodInSeconds An optional {@code Integer} representing the proposed duration of seconds that the * lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease @@ -746,38 +958,56 @@ public Mono> breakLease(Integer breakPeriodInSeconds, Modified /** * ChangeLease changes the blob's lease ID. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.changeLease#String-String} + * + *

For more information, see the + * Azure Docs

+ * * @param leaseId The leaseId of the active lease on the blob. - * @param proposedID A {@code String} in any valid GUID format. + * @param proposedId A {@code String} in any valid GUID format. * @return A reactive response containing the new lease ID. */ - public Mono> changeLease(String leaseId, String proposedID) { - return this.changeLease(leaseId, proposedID, null); + public Mono> changeLease(String leaseId, String proposedId) { + return this.changeLease(leaseId, proposedId, null); } /** - * ChangeLease changes the blob's lease ID. For more information, see the Azure - * Docs. + * ChangeLease changes the blob's lease ID. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.changeLease#String-String-ModifiedAccessConditions} + * + *

For more information, see the + * Azure Docs

* * @param leaseId The leaseId of the active lease on the blob. - * @param proposedID A {@code String} in any valid GUID format. + * @param proposedId A {@code String} in any valid GUID format. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @return A reactive response containing the new lease ID. */ - public Mono> changeLease(String leaseId, String proposedID, ModifiedAccessConditions modifiedAccessConditions) { + public Mono> changeLease(String leaseId, String proposedId, ModifiedAccessConditions modifiedAccessConditions) { return postProcessResponse(this.azureBlobStorage.blobs().changeLeaseWithRestResponseAsync(null, - null, leaseId, proposedID, null, null, modifiedAccessConditions, Context.NONE)) + null, leaseId, proposedId, null, null, modifiedAccessConditions, Context.NONE)) .map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().leaseId())); } /** - * Returns the sku name and account kind for the account. For more information, please see the Azure Docs. + * Returns the sku name and account kind for the account. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobAsyncClient.getAccountInfo} + * + *

For more information, see the + * Azure Docs

* * @return a reactor response containing the sku name and account kind. */ - // TODO (unknown): determine this return type public Mono> getAccountInfo() { return postProcessResponse( this.azureBlobStorage.blobs().getAccountInfoWithRestResponseAsync(null, null, Context.NONE)) diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobClient.java index e2c6eab47a76..c88bac43c0da 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobClient.java @@ -39,13 +39,12 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient}, and - * operations on the service are available on {@link StorageClient}. + * operations on the service are available on {@link BlobServiceClient}. * *

* Please refer to the Azure * Docs for more information. */ -@SuppressWarnings({"unused", "WeakerAccess"}) public class BlobClient { private final BlobAsyncClient blobAsyncClient; @@ -136,6 +135,10 @@ public final BlobInputStream openInputStream(BlobRange range, BlobAccessConditio /** * Gets if the container this client represents exists in the cloud. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.exists} + * * @return true if the container exists, false if it doesn't */ public Response exists() { @@ -145,6 +148,10 @@ public Response exists() { /** * Gets if the container this client represents exists in the cloud. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.exists#Duration} + * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return true if the container exists, false if it doesn't */ @@ -155,8 +162,14 @@ public Response exists(Duration timeout) { } /** - * Copies the data at the source URL to a blob. For more information, see the - * Azure Docs + * Copies the data at the source URL to a blob. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.startCopyFromURL#URL} + * + *

For more information, see the + * Azure Docs

* * @param sourceURL The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @return The copy ID for the long running operation. @@ -166,8 +179,14 @@ public Response startCopyFromURL(URL sourceURL) { } /** - * Copies the data at the source URL to a blob. For more information, see the - * Azure Docs + * Copies the data at the source URL to a blob. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

* * @param sourceURL The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @param metadata {@link Metadata} @@ -179,9 +198,8 @@ public Response startCopyFromURL(URL sourceURL) { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The copy ID for the long running operation. */ - public Response startCopyFromURL(URL sourceURL, Metadata metadata, - ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, - Duration timeout) { + public Response startCopyFromURL(URL sourceURL, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, + BlobAccessConditions destAccessConditions, Duration timeout) { Mono> response = blobAsyncClient .startCopyFromURL(sourceURL, metadata, sourceModifiedAccessConditions, destAccessConditions); @@ -191,6 +209,13 @@ public Response startCopyFromURL(URL sourceURL, Metadata metadata, /** * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.abortCopyFromURL#String} + * + *

For more information, see the + * Azure Docs

+ * * @param copyId The id of the copy operation to abort. Returned as the {@code copyId} field on the {@link * BlobStartCopyFromURLHeaders} object. * @return A response containing status code and HTTP headers. @@ -202,6 +227,13 @@ public VoidResponse abortCopyFromURL(String copyId) { /** * Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.abortCopyFromURL#String-LeaseAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param copyId The id of the copy operation to abort. Returned as the {@code copyId} field on the {@link * BlobStartCopyFromURLHeaders} object. * @param leaseAccessConditions By setting lease access conditions, requests will fail if the provided lease does @@ -219,6 +251,13 @@ public VoidResponse abortCopyFromURL(String copyId, LeaseAccessConditions leaseA /** * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.copyFromURL#URL} + * + *

For more information, see the + * Azure Docs

+ * * @param copySource The source URL to copy from. * @return The copy ID for the long running operation. */ @@ -229,6 +268,13 @@ public Response copyFromURL(URL copySource) { /** * Copies the data at the source URL to a blob and waits for the copy to complete before returning a response. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param copySource The source URL to copy from. URLs outside of Azure may only be copied to block blobs. * @param metadata {@link Metadata} * @param sourceModifiedAccessConditions {@link ModifiedAccessConditions} against the source. Standard HTTP Access @@ -239,9 +285,8 @@ public Response copyFromURL(URL copySource) { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The copy ID for the long running operation. */ - public Response copyFromURL(URL copySource, Metadata metadata, - ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, - Duration timeout) { + public Response copyFromURL(URL copySource, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, + BlobAccessConditions destAccessConditions, Duration timeout) { Mono> response = blobAsyncClient .copyFromURL(copySource, metadata, sourceModifiedAccessConditions, destAccessConditions); @@ -252,6 +297,13 @@ public Response copyFromURL(URL copySource, Metadata metadata, * Downloads the entire blob into an output stream. Uploading data must be done from the {@link BlockBlobClient}, * {@link PageBlobClient}, or {@link AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.download#OutputStream} + * + *

For more information, see the + * Azure Docs

+ * * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. * @return A response containing status code and HTTP headers. * @throws UncheckedIOException If an I/O error occurs. @@ -264,19 +316,26 @@ public VoidResponse download(OutputStream stream) { * Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the {@link * BlockBlobClient}, {@link PageBlobClient}, or {@link AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.download#OutputStream-BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param stream A non-null {@link OutputStream} instance where the downloaded data will be written. - * @param options {@link ReliableDownloadOptions} * @param range {@link BlobRange} + * @param options {@link ReliableDownloadOptions} * @param accessConditions {@link BlobAccessConditions} * @param rangeGetContentMD5 Whether the contentMD5 for the specified blob range should be returned. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return A response containing status code and HTTP headers. * @throws UncheckedIOException If an I/O error occurs. */ - public VoidResponse download(OutputStream stream, ReliableDownloadOptions options, BlobRange range, + public VoidResponse download(OutputStream stream, BlobRange range, ReliableDownloadOptions options, BlobAccessConditions accessConditions, boolean rangeGetContentMD5, Duration timeout) { Mono download = blobAsyncClient - .download(range, accessConditions, rangeGetContentMD5, options) + .download(range, options, accessConditions, rangeGetContentMD5) .flatMapMany(res -> res.value() .doOnNext(bf -> { try { @@ -296,10 +355,17 @@ public VoidResponse download(OutputStream stream, ReliableDownloadOptions option * Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or {@link * AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.downloadToFile#String} + * + *

For more information, see the + * Azure Docs

+ * * @param filePath A non-null {@link OutputStream} instance where the downloaded data will be written. - * @throws IOException If an I/O error occurs + * @throws UncheckedIOException If an I/O error occurs */ - public void downloadToFile(String filePath) throws IOException { + public void downloadToFile(String filePath) { blobAsyncClient.downloadToFile(filePath); } @@ -308,29 +374,39 @@ public void downloadToFile(String filePath) throws IOException { * Uploading data must be done from the {@link BlockBlobClient}, {@link PageBlobClient}, or {@link * AppendBlobClient}. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param filePath A non-null {@link OutputStream} instance where the downloaded data will be written. - * @param options {@link ReliableDownloadOptions} * @param range {@link BlobRange} * @param blockSize the size of a chunk to download at a time, in bytes + * @param options {@link ReliableDownloadOptions} * @param accessConditions {@link BlobAccessConditions} * @param rangeGetContentMD5 Whether the contentMD5 for the specified blob range should be returned. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. - * @throws IOException If an I/O error occurs + * @throws UncheckedIOException If an I/O error occurs */ - public void downloadToFile(String filePath, ReliableDownloadOptions options, BlobRange range, Integer blockSize, - BlobAccessConditions accessConditions, boolean rangeGetContentMD5, Duration timeout) throws IOException { - Mono download = blobAsyncClient.downloadToFile(filePath, range, blockSize, accessConditions, rangeGetContentMD5, options); + public void downloadToFile(String filePath, BlobRange range, Integer blockSize, ReliableDownloadOptions options, + BlobAccessConditions accessConditions, boolean rangeGetContentMD5, Duration timeout) { + Mono download = blobAsyncClient.downloadToFile(filePath, range, blockSize, options, accessConditions, rangeGetContentMD5); - try { - Utility.blockWithOptionalTimeout(download, timeout); - } catch (UncheckedIOException e) { - throw e.getCause(); - } + Utility.blockWithOptionalTimeout(download, timeout); } /** * Deletes the specified blob or snapshot. Note that deleting a blob also deletes all its snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.delete} + * + *

For more information, see the + * Azure Docs

+ * * @return A response containing status code and HTTP headers. */ public VoidResponse delete() { @@ -340,6 +416,13 @@ public VoidResponse delete() { /** * Deletes the specified blob or snapshot. Note that deleting a blob also deletes all its snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param deleteBlobSnapshotOptions Specifies the behavior for deleting the snapshots on this blob. {@code Include} * will delete the base blob and all snapshots. {@code Only} will delete only the snapshots. If a snapshot is being * deleted, you must pass null. @@ -358,6 +441,13 @@ public VoidResponse delete(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, /** * Returns the blob's metadata and properties. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.getProperties} + * + *

For more information, see the + * Azure Docs

+ * * @return The blob properties and metadata. */ public Response getProperties() { @@ -367,6 +457,13 @@ public Response getProperties() { /** * Returns the blob's metadata and properties. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.getProperties#BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param accessConditions {@link BlobAccessConditions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The blob properties and metadata. @@ -380,9 +477,14 @@ public Response getProperties(BlobAccessConditions accessConditi /** * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. For more information, - * see the - * Azure Docs. + * order to preserve existing values, they must be passed alongside the header being changed. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders} + * + *

For more information, see the + * Azure Docs

* * @param headers {@link BlobHTTPHeaders} * @return A response containing status code and HTTP headers. @@ -393,9 +495,14 @@ public VoidResponse setHTTPHeaders(BlobHTTPHeaders headers) { /** * Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In - * order to preserve existing values, they must be passed alongside the header being changed. For more information, - * see the - * Azure Docs. + * order to preserve existing values, they must be passed alongside the header being changed. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

* * @param headers {@link BlobHTTPHeaders} * @param accessConditions {@link BlobAccessConditions} @@ -412,8 +519,14 @@ public VoidResponse setHTTPHeaders(BlobHTTPHeaders headers, BlobAccessConditions /** * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. For more information, see the - * Azure Docs. + * must be preserved, they must be downloaded and included in the call to this method. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setMetadata#Metadata} + * + *

For more information, see the + * Azure Docs

* * @param metadata {@link Metadata} * @return A response containing status code and HTTP headers. @@ -424,8 +537,14 @@ public VoidResponse setMetadata(Metadata metadata) { /** * Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values - * must be preserved, they must be downloaded and included in the call to this method. For more information, see the - * Azure Docs. + * must be preserved, they must be downloaded and included in the call to this method. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setMetadata#Metadata-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

* * @param metadata {@link Metadata} * @param accessConditions {@link BlobAccessConditions} @@ -442,6 +561,13 @@ public VoidResponse setMetadata(Metadata metadata, BlobAccessConditions accessCo /** * Creates a read-only snapshot of a blob. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.createSnapshot} + * + *

For more information, see the + * Azure Docs

+ * * @return The ID of the new snapshot. */ public Response createSnapshot() { @@ -451,6 +577,13 @@ public Response createSnapshot() { /** * Creates a read-only snapshot of a blob. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.createSnapshot#Metadata-BlobAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param metadata {@link Metadata} * @param accessConditions {@link BlobAccessConditions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -469,6 +602,13 @@ public Response createSnapshot(Metadata metadata, BlobAccessConditions a * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's * etag. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setTier#AccessTier} + * + *

For more information, see the + * Azure Docs

+ * * @param tier The new tier for the blob. * @return A response containing status code and HTTP headers. */ @@ -482,6 +622,13 @@ public VoidResponse setTier(AccessTier tier) { * the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's * etag. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.setTier#AccessTier-LeaseAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param tier The new tier for the blob. * @param leaseAccessConditions By setting lease access conditions, requests will fail if the provided lease does * not match the active lease on the blob. @@ -498,6 +645,13 @@ public VoidResponse setTier(AccessTier tier, LeaseAccessConditions leaseAccessCo /** * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.undelete} + * + *

For more information, see the + * Azure Docs

+ * * @return A response containing status code and HTTP headers. */ public VoidResponse undelete() { @@ -507,6 +661,13 @@ public VoidResponse undelete() { /** * Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.undelete#Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return A response containing status code and HTTP headers. */ @@ -521,6 +682,13 @@ public VoidResponse undelete(Duration timeout) { * Acquires a lease on the blob for write and delete operations. The lease duration must be between 15 to 60 * seconds, or infinite (-1). * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.acquireLease#String-int} + * + *

For more information, see the + * Azure Docs

+ * * @param proposedId A {@code String} in any valid GUID format. May be null. * @param duration The duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A * non-infinite lease can be between 15 and 60 seconds. @@ -534,7 +702,14 @@ public Response acquireLease(String proposedId, int duration) { * Acquires a lease on the blob for write and delete operations. The lease duration must be between 15 to 60 * seconds, or infinite (-1). * - * @param proposedID A {@code String} in any valid GUID format. May be null. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.acquireLease#String-int-ModifiedAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * + * @param proposedId A {@code String} in any valid GUID format. May be null. * @param duration The duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A * non-infinite lease can be between 15 and 60 seconds. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and @@ -543,10 +718,10 @@ public Response acquireLease(String proposedId, int duration) { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The lease ID. */ - public Response acquireLease(String proposedID, int duration, + public Response acquireLease(String proposedId, int duration, ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { Mono> response = blobAsyncClient - .acquireLease(proposedID, duration, modifiedAccessConditions); + .acquireLease(proposedId, duration, modifiedAccessConditions); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -554,27 +729,40 @@ public Response acquireLease(String proposedID, int duration, /** * Renews the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.renewLease#String} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @return The renewed lease ID. */ - public Response renewLease(String leaseID) { - return this.renewLease(leaseID, null, null); + public Response renewLease(String leaseId) { + return this.renewLease(leaseId, null, null); } /** * Renews the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.renewLease#String-ModifiedAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The renewed lease ID. */ - public Response renewLease(String leaseID, ModifiedAccessConditions modifiedAccessConditions, - Duration timeout) { + public Response renewLease(String leaseId, ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { Mono> response = blobAsyncClient - .renewLease(leaseID, modifiedAccessConditions); + .renewLease(leaseId, modifiedAccessConditions); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -582,27 +770,39 @@ public Response renewLease(String leaseID, ModifiedAccessConditions modi /** * Releases the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.releaseLease#String} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @return A response containing status code and HTTP headers. */ - public VoidResponse releaseLease(String leaseID) { - return this.releaseLease(leaseID, null, null); + public VoidResponse releaseLease(String leaseId) { + return this.releaseLease(leaseId, null, null); } /** * Releases the blob's previously-acquired lease. * - * @param leaseID The leaseId of the active lease on the blob. + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.releaseLease#String-ModifiedAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * + * @param leaseId The leaseId of the active lease on the blob. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return A response containing status code and HTTP headers. */ - public VoidResponse releaseLease(String leaseID, - ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { - Mono response = blobAsyncClient - .releaseLease(leaseID, modifiedAccessConditions); + public VoidResponse releaseLease(String leaseId, ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { + Mono response = blobAsyncClient.releaseLease(leaseId, modifiedAccessConditions); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -611,6 +811,13 @@ public VoidResponse releaseLease(String leaseID, * BreakLease breaks the blob's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1) constant * to break a fixed-duration lease when it expires or an infinite lease immediately. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.breakLease} + * + *

For more information, see the + * Azure Docs

+ * * @return The remaining time in the broken lease in seconds. */ public Response breakLease() { @@ -621,6 +828,13 @@ public Response breakLease() { * BreakLease breaks the blob's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1) constant * to break a fixed-duration lease when it expires or an infinite lease immediately. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.breakLease#Integer-ModifiedAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

+ * * @param breakPeriodInSeconds An optional {@code Integer} representing the proposed duration of seconds that the * lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is * shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease @@ -632,8 +846,7 @@ public Response breakLease() { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The remaining time in the broken lease in seconds. */ - public Response breakLease(Integer breakPeriodInSeconds, - ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { + public Response breakLease(Integer breakPeriodInSeconds, ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { Mono> response = blobAsyncClient .breakLease(breakPeriodInSeconds, modifiedAccessConditions); @@ -643,37 +856,54 @@ public Response breakLease(Integer breakPeriodInSeconds, /** * ChangeLease changes the blob's lease ID. * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.changeLease#String-String} + * + *

For more information, see the + * Azure Docs

+ * * @param leaseId The leaseId of the active lease on the blob. - * @param proposedID A {@code String} in any valid GUID format. + * @param proposedId A {@code String} in any valid GUID format. * @return The new lease ID. */ - public Response changeLease(String leaseId, String proposedID) { - return this.changeLease(leaseId, proposedID, null, null); + public Response changeLease(String leaseId, String proposedId) { + return this.changeLease(leaseId, proposedId, null, null); } /** - * ChangeLease changes the blob's lease ID. For more information, see the Azure - * Docs. + * ChangeLease changes the blob's lease ID. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.changeLease#String-String-ModifiedAccessConditions-Duration} + * + *

For more information, see the + * Azure Docs

* * @param leaseId The leaseId of the active lease on the blob. - * @param proposedID A {@code String} in any valid GUID format. + * @param proposedId A {@code String} in any valid GUID format. * @param modifiedAccessConditions Standard HTTP Access conditions related to the modification of data. ETag and * LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given * request. The request will fail if the specified condition is not satisfied. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The new lease ID. */ - public Response changeLease(String leaseId, String proposedID, - ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { - Mono> response = blobAsyncClient - .changeLease(leaseId, proposedID, modifiedAccessConditions); + public Response changeLease(String leaseId, String proposedId, ModifiedAccessConditions modifiedAccessConditions, Duration timeout) { + Mono> response = blobAsyncClient.changeLease(leaseId, proposedId, modifiedAccessConditions); return Utility.blockWithOptionalTimeout(response, timeout); } /** - * Returns the sku name and account kind for the account. For more information, please see the Azure Docs. + * Returns the sku name and account kind for the account. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.getAccountInfo} + * + *

For more information, see the + * Azure Docs

* * @return The sku name and account kind. */ @@ -682,8 +912,14 @@ public Response getAccountInfo() { } /** - * Returns the sku name and account kind for the account. For more information, please see the Azure Docs. + * Returns the sku name and account kind for the account. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.blob.BlobClient.getAccountInfo#Duration} + * + *

For more information, see the + * Azure Docs

* * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @return The sku name and account kind. diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java similarity index 98% rename from storage/client/blob/src/main/java/com/azure/storage/blob/StorageAsyncClient.java rename to storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java index e84d23ee1dbe..4738c234387b 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java @@ -32,7 +32,7 @@ import static com.azure.storage.blob.Utility.postProcessResponse; /** - * Client to a storage account. It may only be instantiated through a {@link StorageClientBuilder}. This class does not + * Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does not * hold any state about a particular storage account but is instead a convenient way of sending off appropriate requests * to the resource on the service. It may also be used to construct URLs to blobs and containers. * @@ -50,15 +50,15 @@ * operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these * responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}. */ -public final class StorageAsyncClient { +public final class BlobServiceAsyncClient { private final AzureBlobStorageImpl azureBlobStorage; /** - * Package-private constructor for use by {@link StorageClientBuilder}. + * Package-private constructor for use by {@link BlobServiceClientBuilder}. * * @param azureBlobStorageBuilder the API client builder for blob storage API */ - StorageAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder) { + BlobServiceAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder) { this.azureBlobStorage = azureBlobStorageBuilder.build(); } diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java similarity index 89% rename from storage/client/blob/src/main/java/com/azure/storage/blob/StorageClient.java rename to storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java index 5749b1b3fe7d..782e766330ab 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java @@ -24,7 +24,7 @@ import java.time.OffsetDateTime; /** - * Client to a storage account. It may only be instantiated through a {@link StorageClientBuilder}. This class does not + * Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does not * hold any state about a particular storage account but is instead a convenient way of sending off appropriate requests * to the resource on the service. It may also be used to construct URLs to blobs and containers. * @@ -36,16 +36,16 @@ * Please see here for more * information on containers. */ -public final class StorageClient { - private final StorageAsyncClient storageAsyncClient; +public final class BlobServiceClient { + private final BlobServiceAsyncClient blobServiceAsyncClient; /** - * Package-private constructor for use by {@link StorageClientBuilder}. + * Package-private constructor for use by {@link BlobServiceClientBuilder}. * - * @param storageAsyncClient the async storage account client + * @param blobServiceAsyncClient the async storage account client */ - StorageClient(StorageAsyncClient storageAsyncClient) { - this.storageAsyncClient = storageAsyncClient; + BlobServiceClient(BlobServiceAsyncClient blobServiceAsyncClient) { + this.blobServiceAsyncClient = blobServiceAsyncClient; } /** @@ -56,7 +56,7 @@ public final class StorageClient { * @return A {@link ContainerClient} object pointing to the specified container */ public ContainerClient getContainerClient(String containerName) { - return new ContainerClient(storageAsyncClient.getContainerAsyncClient(containerName)); + return new ContainerClient(blobServiceAsyncClient.getContainerAsyncClient(containerName)); } /** @@ -96,7 +96,7 @@ public Response createContainer(String containerName, Metadata * @return A response containing status code and HTTP headers */ public VoidResponse deleteContainer(String containerName) { - return storageAsyncClient.deleteContainer(containerName).block(); + return blobServiceAsyncClient.deleteContainer(containerName).block(); } /** @@ -105,7 +105,7 @@ public VoidResponse deleteContainer(String containerName) { * @return the URL. */ public URL getAccountUrl() { - return storageAsyncClient.getAccountUrl(); + return blobServiceAsyncClient.getAccountUrl(); } /** @@ -129,7 +129,7 @@ public Iterable listContainers() { * @return The list of containers. */ public Iterable listContainers(ListContainersOptions options, Duration timeout) { - Flux response = storageAsyncClient.listContainers(options); + Flux response = blobServiceAsyncClient.listContainers(options); return timeout == null ? response.toIterable() : response.timeout(timeout).toIterable(); } @@ -153,7 +153,7 @@ public Response getProperties() { */ public Response getProperties(Duration timeout) { - Mono> response = storageAsyncClient.getProperties(); + Mono> response = blobServiceAsyncClient.getProperties(); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -182,7 +182,7 @@ public VoidResponse setProperties(StorageServiceProperties properties) { * @return The storage account properties. */ public VoidResponse setProperties(StorageServiceProperties properties, Duration timeout) { - Mono response = storageAsyncClient.setProperties(properties); + Mono response = blobServiceAsyncClient.setProperties(properties); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -210,7 +210,7 @@ public Response getUserDelegationKey(OffsetDateTime start, Of */ public Response getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry, Duration timeout) { - Mono> response = storageAsyncClient.getUserDelegationKey(start, expiry); + Mono> response = blobServiceAsyncClient.getUserDelegationKey(start, expiry); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -237,7 +237,7 @@ public Response getStatistics() { * @return The storage account statistics. */ public Response getStatistics(Duration timeout) { - Mono> response = storageAsyncClient.getStatistics(); + Mono> response = blobServiceAsyncClient.getStatistics(); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -260,7 +260,7 @@ public Response getAccountInfo() { * @return The storage account info. */ public Response getAccountInfo(Duration timeout) { - Mono> response = storageAsyncClient.getAccountInfo(); + Mono> response = blobServiceAsyncClient.getAccountInfo(); return Utility.blockWithOptionalTimeout(response, timeout); } @@ -276,7 +276,7 @@ public Response getAccountInfo(Duration timeout) { */ public String generateAccountSAS(AccountSASService accountSASService, AccountSASResourceType accountSASResourceType, AccountSASPermission accountSASPermission, OffsetDateTime expiryTime) { - return this.storageAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime); + return this.blobServiceAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime); } /** @@ -295,6 +295,6 @@ public String generateAccountSAS(AccountSASService accountSASService, AccountSAS public String generateAccountSAS(AccountSASService accountSASService, AccountSASResourceType accountSASResourceType, AccountSASPermission accountSASPermission, OffsetDateTime expiryTime, OffsetDateTime startTime, String version, IPRange ipRange, SASProtocol sasProtocol) { - return this.storageAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime, startTime, version, ipRange, sasProtocol); + return this.blobServiceAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime, startTime, version, ipRange, sasProtocol); } } diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageClientBuilder.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java similarity index 79% rename from storage/client/blob/src/main/java/com/azure/storage/blob/StorageClientBuilder.java rename to storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java index a73249dec8f7..114924273c6c 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/StorageClientBuilder.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java @@ -35,8 +35,8 @@ import java.util.Objects; /** - * Fluent StorageClientBuilder for instantiating a {@link StorageClient} or {@link StorageAsyncClient} - * using {@link StorageClientBuilder#buildClient()} or {@link StorageClientBuilder#buildAsyncClient()} respectively. + * Fluent BlobServiceClientBuilder for instantiating a {@link BlobServiceClient} or {@link BlobServiceAsyncClient} + * using {@link BlobServiceClientBuilder#buildClient()} or {@link BlobServiceClientBuilder#buildAsyncClient()} respectively. * *

* The following information must be provided on this builder: @@ -48,9 +48,9 @@ * *

* Once all the configurations are set on this builder, call {@code .buildClient()} to create a - * {@link StorageClient} or {@code .buildAsyncClient()} to create a {@link StorageAsyncClient}. + * {@link BlobServiceClient} or {@code .buildAsyncClient()} to create a {@link BlobServiceAsyncClient}. */ -public final class StorageClientBuilder { +public final class BlobServiceClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; @@ -68,10 +68,10 @@ public final class StorageClientBuilder { private Configuration configuration; /** - * Creates a builder instance that is able to configure and construct {@link StorageClient StorageClients} - * and {@link StorageAsyncClient StorageAsyncClients}. + * Creates a builder instance that is able to configure and construct {@link BlobServiceClient BlobServiceClients} + * and {@link BlobServiceAsyncClient BlobServiceAsyncClients}. */ - public StorageClientBuilder() { + public BlobServiceClientBuilder() { retryOptions = new RequestRetryOptions(); logLevel = HttpLogDetailLevel.NONE; policies = new ArrayList<>(); @@ -116,32 +116,32 @@ private AzureBlobStorageBuilder buildImpl() { } /** - * Creates a {@link StorageClient} based on options set in the Builder. + * Creates a {@link BlobServiceClient} based on options set in the Builder. * - * @return a {@link StorageClient} created from the configurations in this builder. + * @return a {@link BlobServiceClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint} is {@code null}. */ - public StorageClient buildClient() { - return new StorageClient(buildAsyncClient()); + public BlobServiceClient buildClient() { + return new BlobServiceClient(buildAsyncClient()); } /** - * Creates a {@link StorageAsyncClient} based on options set in the Builder. + * Creates a {@link BlobServiceAsyncClient} based on options set in the Builder. * - * @return a {@link StorageAsyncClient} created from the configurations in this builder. + * @return a {@link BlobServiceAsyncClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint} is {@code null}. */ - public StorageAsyncClient buildAsyncClient() { - return new StorageAsyncClient(buildImpl()); + public BlobServiceAsyncClient buildAsyncClient() { + return new BlobServiceAsyncClient(buildImpl()); } /** * Sets the blob service endpoint, additionally parses it for information (SAS token, queue name) * @param endpoint URL of the service - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws IllegalArgumentException If {@code endpoint} is {@code null} or is a malformed URL. */ - public StorageClientBuilder endpoint(String endpoint) { + public BlobServiceClientBuilder endpoint(String endpoint) { try { URL url = new URL(endpoint); this.endpoint = url.getProtocol() + "://" + url.getAuthority(); @@ -168,7 +168,7 @@ String endpoint() { * @return the updated ContainerClientBuilder object * @throws NullPointerException If {@code credential} is {@code null}. */ - public StorageClientBuilder credential(SharedKeyCredential credential) { + public BlobServiceClientBuilder credential(SharedKeyCredential credential) { this.sharedKeyCredential = Objects.requireNonNull(credential); this.tokenCredential = null; this.sasTokenCredential = null; @@ -178,10 +178,10 @@ public StorageClientBuilder credential(SharedKeyCredential credential) { /** * Sets the credential used to authorize requests sent to the service * @param credential authorization credential - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws NullPointerException If {@code credential} is {@code null}. */ - public StorageClientBuilder credential(TokenCredential credential) { + public BlobServiceClientBuilder credential(TokenCredential credential) { this.tokenCredential = Objects.requireNonNull(credential); this.sharedKeyCredential = null; this.sasTokenCredential = null; @@ -191,10 +191,10 @@ public StorageClientBuilder credential(TokenCredential credential) { /** * Sets the credential used to authorize requests sent to the service * @param credential authorization credential - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws NullPointerException If {@code credential} is {@code null}. */ - public StorageClientBuilder credential(SASTokenCredential credential) { + public BlobServiceClientBuilder credential(SASTokenCredential credential) { this.sasTokenCredential = Objects.requireNonNull(credential); this.sharedKeyCredential = null; this.tokenCredential = null; @@ -203,9 +203,9 @@ public StorageClientBuilder credential(SASTokenCredential credential) { /** * Clears the credential used to authorize requests sent to the service - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object */ - public StorageClientBuilder anonymousCredential() { + public BlobServiceClientBuilder anonymousCredential() { this.sharedKeyCredential = null; this.tokenCredential = null; this.sasTokenCredential = null; @@ -215,10 +215,10 @@ public StorageClientBuilder anonymousCredential() { /** * Sets the connection string for the service, parses it for authentication information (account name, account key) * @param connectionString connection string from access keys section - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws IllegalArgumentException If {@code connectionString} doesn't contain AccountName or AccountKey. */ - public StorageClientBuilder connectionString(String connectionString) { + public BlobServiceClientBuilder connectionString(String connectionString) { Objects.requireNonNull(connectionString); Map connectionKVPs = new HashMap<>(); @@ -248,10 +248,10 @@ public StorageClientBuilder connectionString(String connectionString) { /** * Sets the http client used to send service requests * @param httpClient http client to send requests - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws NullPointerException If {@code httpClient} is {@code null}. */ - public StorageClientBuilder httpClient(HttpClient httpClient) { + public BlobServiceClientBuilder httpClient(HttpClient httpClient) { this.httpClient = Objects.requireNonNull(httpClient); return this; } @@ -259,10 +259,10 @@ public StorageClientBuilder httpClient(HttpClient httpClient) { /** * Adds a pipeline policy to apply on each request sent * @param pipelinePolicy a pipeline policy - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws NullPointerException If {@code pipelinePolicy} is {@code null}. */ - public StorageClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { + public BlobServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { this.policies.add(Objects.requireNonNull(pipelinePolicy)); return this; } @@ -270,9 +270,9 @@ public StorageClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) { /** * Sets the logging level for service requests * @param logLevel logging level - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object */ - public StorageClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel) { + public BlobServiceClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel) { this.logLevel = logLevel; return this; } @@ -281,9 +281,9 @@ public StorageClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel) { * Sets the configuration object used to retrieve environment configuration values used to buildClient the client with * when they are not set in the appendBlobClientBuilder, defaults to Configuration.NONE * @param configuration configuration store - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object */ - public StorageClientBuilder configuration(Configuration configuration) { + public BlobServiceClientBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; } @@ -291,10 +291,10 @@ public StorageClientBuilder configuration(Configuration configuration) { /** * Sets the request retry options for all the requests made through the client. * @param retryOptions the options to configure retry behaviors - * @return the updated StorageClientBuilder object + * @return the updated BlobServiceClientBuilder object * @throws NullPointerException If {@code retryOptions} is {@code null}. */ - public StorageClientBuilder retryOptions(RequestRetryOptions retryOptions) { + public BlobServiceClientBuilder retryOptions(RequestRetryOptions retryOptions) { this.retryOptions = Objects.requireNonNull(retryOptions); return this; } diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobURLParts.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobURLParts.java index 1200e960f750..5c629e719ca3 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/BlobURLParts.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlobURLParts.java @@ -76,14 +76,14 @@ public BlobURLParts host(String host) { } /** - * The container name or {@code null} if a {@link StorageAsyncClient} was parsed. + * The container name or {@code null} if a {@link BlobServiceAsyncClient} was parsed. */ public String containerName() { return containerName; } /** - * The container name or {@code null} if a {@link StorageAsyncClient} was parsed. + * The container name or {@code null} if a {@link BlobServiceAsyncClient} was parsed. */ public BlobURLParts containerName(String containerName) { this.containerName = containerName; @@ -91,14 +91,14 @@ public BlobURLParts containerName(String containerName) { } /** - * The blob name or {@code null} if a {@link StorageAsyncClient} or {@link ContainerAsyncClient} was parsed. + * The blob name or {@code null} if a {@link BlobServiceAsyncClient} or {@link ContainerAsyncClient} was parsed. */ public String blobName() { return blobName; } /** - * The blob name or {@code null} if a {@link StorageAsyncClient} or {@link ContainerAsyncClient} was parsed. + * The blob name or {@code null} if a {@link BlobServiceAsyncClient} or {@link ContainerAsyncClient} was parsed. */ public BlobURLParts blobName(String blobName) { this.blobName = blobName; diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java index cdb0a06fa68e..ffb2eddc60b8 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobAsyncClient.java @@ -50,7 +50,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient}, - * and operations on the service are available on {@link StorageAsyncClient}. + * and operations on the service are available on {@link BlobServiceAsyncClient}. * *

* Please refer diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java index 6af92555c2b0..69bad81c7ff2 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/BlockBlobClient.java @@ -36,7 +36,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient}, - * and operations on the service are available on {@link StorageClient}. + * and operations on the service are available on {@link BlobServiceClient}. * *

* Please refer to the Azure Docs diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java index f9cf29c3e79f..67bd29d4d381 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerAsyncClient.java @@ -41,13 +41,13 @@ /** * Client to a container. It may only be instantiated through a {@link ContainerClientBuilder} or via the method {@link - * StorageAsyncClient#getContainerAsyncClient(String)}. This class does not hold any state about a particular blob but + * BlobServiceAsyncClient#getContainerAsyncClient(String)}. This class does not hold any state about a particular blob but * is instead a convenient way of sending off appropriate requests to the resource on the service. It may also be used * to construct URLs to blobs. * *

* This client contains operations on a container. Operations on a blob are available on {@link BlobAsyncClient} through - * {@link #getBlobAsyncClient(String)}, and operations on the service are available on {@link StorageAsyncClient}. + * {@link #getBlobAsyncClient(String)}, and operations on the service are available on {@link BlobServiceAsyncClient}. * *

* Please refer to the Azure @@ -206,12 +206,12 @@ public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) { } /** - * Initializes a {@link StorageAsyncClient} object pointing to the storage account this container is in. + * Initializes a {@link BlobServiceAsyncClient} object pointing to the storage account this container is in. * - * @return A {@link StorageAsyncClient} object pointing to the specified storage account + * @return A {@link BlobServiceAsyncClient} object pointing to the specified storage account */ - public StorageAsyncClient getStorageAsyncClient() { - return new StorageAsyncClient(new AzureBlobStorageBuilder() + public BlobServiceAsyncClient getBlobServiceAsyncClient() { + return new BlobServiceAsyncClient(new AzureBlobStorageBuilder() .url(Utility.stripLastPathSegment(getContainerUrl()).toString()) .pipeline(azureBlobStorage.getHttpPipeline())); } diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerClient.java index 12d5844a696f..c66b9d8c2373 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/ContainerClient.java @@ -26,13 +26,13 @@ /** * Client to a container. It may only be instantiated through a {@link ContainerClientBuilder} or via the method {@link - * StorageClient#getContainerClient(String)}. This class does not hold any state about a particular container but is + * BlobServiceClient#getContainerClient(String)}. This class does not hold any state about a particular container but is * instead a convenient way of sending off appropriate requests to the resource on the service. It may also be used to * construct URLs to blobs. * *

* This client contains operations on a container. Operations on a blob are available on {@link BlobClient} through - * {@link #getBlobClient(String)}, and operations on the service are available on {@link StorageClient}. + * {@link #getBlobClient(String)}, and operations on the service are available on {@link BlobServiceClient}. * *

* Please refer to the Azure @@ -171,12 +171,12 @@ public BlobClient getBlobClient(String blobName, String snapshot) { } /** - * Initializes a {@link StorageClient} object pointing to the storage account this container is in. + * Initializes a {@link BlobServiceClient} object pointing to the storage account this container is in. * - * @return A {@link StorageClient} object pointing to the specified storage account + * @return A {@link BlobServiceClient} object pointing to the specified storage account */ - public StorageClient getStorageClient() { - return new StorageClient(containerAsyncClient.getStorageAsyncClient()); + public BlobServiceClient getBlobServiceClient() { + return new BlobServiceClient(containerAsyncClient.getBlobServiceAsyncClient()); } /** diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/DownloadAsyncResponse.java b/storage/client/blob/src/main/java/com/azure/storage/blob/DownloadAsyncResponse.java index e22a3fa72a16..c27ad3645d20 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/DownloadAsyncResponse.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/DownloadAsyncResponse.java @@ -18,7 +18,7 @@ /** * {@code DownloadAsyncResponse} wraps the protocol-layer response from {@link BlobAsyncClient#download(BlobRange, - * BlobAccessConditions, boolean, ReliableDownloadOptions)} to automatically retry failed reads from the body as + * ReliableDownloadOptions, BlobAccessConditions, boolean)} to automatically retry failed reads from the body as * appropriate. If the download is interrupted, the {@code DownloadAsyncResponse} will make a request to resume the download * from where it left off, allowing the user to consume the data as one continuous stream, for any interruptions are * hidden. The retry behavior is defined by the options passed to the {@link #body(ReliableDownloadOptions)}. The diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java index 925f167b2ad9..3f5467a7a6a7 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobAsyncClient.java @@ -37,7 +37,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient}, - * and operations on the service are available on {@link StorageAsyncClient}. + * and operations on the service are available on {@link BlobServiceAsyncClient}. * *

* Please refer diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobClient.java b/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobClient.java index 14c0ea4644de..fc84f9c9ea21 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobClient.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/PageBlobClient.java @@ -34,7 +34,7 @@ * *

* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient}, - * and operations on the service are available on {@link StorageClient}. + * and operations on the service are available on {@link BlobServiceClient}. * *

* Please refer to the Azure Docs diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/implementation/SignedIdentifierWrapper.java b/storage/client/blob/src/main/java/com/azure/storage/blob/implementation/SignedIdentifierWrapper.java index 8ad4982f3220..69a4eb5ed6c5 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/implementation/SignedIdentifierWrapper.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/implementation/SignedIdentifierWrapper.java @@ -14,7 +14,7 @@ /** * A wrapper around List<SignedIdentifier> which provides top-level metadata for serialization. */ -@JacksonXmlRootElement(localName = "SignedIdentifier") +@JacksonXmlRootElement(localName = "SignedIdentifiers") public final class SignedIdentifierWrapper { @JacksonXmlProperty(localName = "SignedIdentifier") private final List signedIdentifier; diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/models/ContainerListDetails.java b/storage/client/blob/src/main/java/com/azure/storage/blob/models/ContainerListDetails.java index f51d897112d5..fbca16f733d7 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/models/ContainerListDetails.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/models/ContainerListDetails.java @@ -3,11 +3,11 @@ package com.azure.storage.blob.models; -import com.azure.storage.blob.StorageClient; +import com.azure.storage.blob.BlobServiceClient; /** * This type allows users to specify additional information the service should return with each container when listing - * containers in an account (via a {@link StorageClient} object). This type is immutable to ensure thread-safety of + * containers in an account (via a {@link BlobServiceClient} object). This type is immutable to ensure thread-safety of * requests, so changing the details for a different listing operation requires construction of a new object. Null may * be passed if none of the options are desirable. */ diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/models/ListContainersOptions.java b/storage/client/blob/src/main/java/com/azure/storage/blob/models/ListContainersOptions.java index 19d3e61a2c75..ed6c27b57d90 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/models/ListContainersOptions.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/models/ListContainersOptions.java @@ -3,10 +3,10 @@ package com.azure.storage.blob.models; -import com.azure.storage.blob.StorageClient; +import com.azure.storage.blob.BlobServiceClient; /** - * Defines options available to configure the behavior of a call to listContainersSegment on a {@link StorageClient} + * Defines options available to configure the behavior of a call to listContainersSegment on a {@link BlobServiceClient} * object. See the constructor for details on each of the options. Null may be passed in place of an object of this * type if no options are desirable. */ diff --git a/storage/client/blob/src/main/java/com/azure/storage/blob/package-info.java b/storage/client/blob/src/main/java/com/azure/storage/blob/package-info.java index 6048911e2d09..54ad22687275 100644 --- a/storage/client/blob/src/main/java/com/azure/storage/blob/package-info.java +++ b/storage/client/blob/src/main/java/com/azure/storage/blob/package-info.java @@ -3,6 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator /** - * Package containing the classes for StorageClient. + * Package containing the classes for BlobServiceClient. */ package com.azure.storage.blob; diff --git a/storage/client/blob/src/samples/java/AzureIdentityExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java similarity index 89% rename from storage/client/blob/src/samples/java/AzureIdentityExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java index 6550c8c02a76..9945273cbccd 100644 --- a/storage/client/blob/src/samples/java/AzureIdentityExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/AzureIdentityExample.java @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +package com.azure.storage.blob; + import com.azure.identity.credential.DefaultAzureCredential; -import com.azure.storage.blob.StorageClient; -import com.azure.storage.blob.StorageClientBuilder; import java.util.Locale; @@ -30,7 +30,7 @@ public static void main(String[] args) { /* * Create a storage client using the Azure Identity credentials. */ - StorageClient storageClient = new StorageClientBuilder() + BlobServiceClient storageClient = new BlobServiceClientBuilder() .endpoint(endpoint) .credential(new DefaultAzureCredential()) .buildClient(); diff --git a/storage/client/blob/src/samples/java/BasicExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/BasicExample.java similarity index 91% rename from storage/client/blob/src/samples/java/BasicExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/BasicExample.java index 3f8edbd367cb..c47e753b3f07 100644 --- a/storage/client/blob/src/samples/java/BasicExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/BasicExample.java @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import com.azure.storage.blob.BlockBlobClient; -import com.azure.storage.blob.ContainerClient; -import com.azure.storage.blob.StorageClient; -import com.azure.storage.blob.StorageClientBuilder; +package com.azure.storage.blob; + import com.azure.storage.common.credentials.SharedKeyCredential; import java.io.ByteArrayInputStream; @@ -46,9 +44,9 @@ public static void main(String[] args) throws IOException { String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); /* - * Create a StorageClient object that wraps the service endpoint, credential and a request pipeline. + * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. */ - StorageClient storageClient = new StorageClientBuilder().endpoint(endpoint).credential(credential).buildClient(); + BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); /* * This example shows several common operations just to get you started. diff --git a/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..3b82eabc7bcf --- /dev/null +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobAsyncClientJavaDocCodeSnippets.java @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob; + +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobAccessConditions; +import com.azure.storage.blob.models.BlobHTTPHeaders; +import com.azure.storage.blob.models.BlobRange; +import com.azure.storage.blob.models.DeleteSnapshotsOptionType; +import com.azure.storage.blob.models.LeaseAccessConditions; +import com.azure.storage.blob.models.Metadata; +import com.azure.storage.blob.models.ModifiedAccessConditions; +import com.azure.storage.blob.models.ReliableDownloadOptions; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.net.URL; +import java.time.OffsetDateTime; +import java.util.Collections; + +/** + * Code snippets for {@link BlobAsyncClient} + */ +@SuppressWarnings("unused") +public class BlobAsyncClientJavaDocCodeSnippets { + private BlobAsyncClient client = JavaDocCodeSnippetsHelpers.getBlobAsyncClient("blobName"); + private String leaseId = "leaseId"; + private String copyId = "copyId"; + private URL url = JavaDocCodeSnippetsHelpers.generateURL("https://sample.com"); + private String file = "file"; + + /** + * Code snippet for {@link BlobAsyncClient#exists()} + */ + public void existsCodeSnippet() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.exists + client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.exists + } + + /** + * Code snippets for {@link BlobAsyncClient#startCopyFromURL(URL)} and + * {@link BlobAsyncClient#startCopyFromURL(URL, Metadata, ModifiedAccessConditions, BlobAccessConditions)} + */ + public void startCopyFromURL() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL + client.startCopyFromURL(url) + .subscribe(response -> System.out.printf("Copy identifier: %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions + Metadata metadata = new Metadata(Collections.singletonMap("metadata", "value")); + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + BlobAccessConditions blobAccessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.startCopyFromURL(url, metadata, modifiedAccessConditions, blobAccessConditions) + .subscribe(response -> System.out.printf("Copy identifier: %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#abortCopyFromURL(String)} and + * {@link BlobAsyncClient#abortCopyFromURL(String, LeaseAccessConditions)} + */ + public void abortCopyFromURL() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String + client.abortCopyFromURL(copyId) + .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String-LeaseAccessConditions + LeaseAccessConditions leaseAccessConditions = new LeaseAccessConditions().leaseId(leaseId); + client.abortCopyFromURL(copyId, leaseAccessConditions) + .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.abortCopyFromURL#String-LeaseAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#copyFromURL(URL)} and + * {@link BlobAsyncClient#copyFromURL(URL, Metadata, ModifiedAccessConditions, BlobAccessConditions)} + */ + public void copyFromURL() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL + client.copyFromURL(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions + Metadata metadata = new Metadata(Collections.singletonMap("metadata", "value")); + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + BlobAccessConditions blobAccessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.copyFromURL(url, metadata, modifiedAccessConditions, blobAccessConditions) + .subscribe(response -> System.out.printf("Copy identifier: %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#download()} and + * {@link BlobAsyncClient#download(BlobRange, ReliableDownloadOptions, BlobAccessConditions, boolean)} + * + * @throws UncheckedIOException If an I/O error occurs + */ + public void download() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.download + client.download().subscribe(response -> { + ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + response.value().subscribe(piece -> { + try { + downloadData.write(piece.array()); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + }); + }); + // END: com.azure.storage.blob.BlobAsyncClient.download + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.download#BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean + BlobRange range = new BlobRange(1024, 2048); + ReliableDownloadOptions options = new ReliableDownloadOptions().maxRetryRequests(5); + + client.download(range, options, null, false).subscribe(response -> { + ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + response.value().subscribe(piece -> { + try { + downloadData.write(piece.array()); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + }); + }); + // END: com.azure.storage.blob.BlobAsyncClient.download#BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean + } + + /** + * Code snippets for {@link BlobAsyncClient#downloadToFile(String)} and + * {@link BlobAsyncClient#downloadToFile(String, BlobRange, Integer, ReliableDownloadOptions, BlobAccessConditions, boolean)} + */ + public void downloadToFile() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String + client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file")); + // END: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean + BlobRange range = new BlobRange(1024, 2048); + ReliableDownloadOptions options = new ReliableDownloadOptions().maxRetryRequests(5); + + client.downloadToFile(file, range, null, options, null, false) + .subscribe(response -> System.out.println("Completed download to file")); + // END: com.azure.storage.blob.BlobAsyncClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean + } + + /** + * Code snippets for {@link BlobAsyncClient#delete()} and + * {@link BlobAsyncClient#delete(DeleteSnapshotsOptionType, BlobAccessConditions)} + */ + public void delete() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.delete + client.delete() + .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.delete + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions + client.delete(DeleteSnapshotsOptionType.INCLUDE, null) + .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#getProperties()} and + * {@link BlobAsyncClient#getProperties(BlobAccessConditions)} + */ + public void getProperties() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.getProperties + client.getProperties().subscribe(response -> + System.out.printf("Type: %s, Size: %d%n", response.value().blobType(), response.value().blobSize())); + // END: com.azure.storage.blob.BlobAsyncClient.getProperties + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.getProperties#BlobAccessConditions + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.getProperties(accessConditions).subscribe(response -> + System.out.printf("Type: %s, Size: %d%n", response.value().blobType(), response.value().blobSize())); + // END: com.azure.storage.blob.BlobAsyncClient.getProperties#BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#setHTTPHeaders(BlobHTTPHeaders)} and + * {@link BlobAsyncClient#setHTTPHeaders(BlobHTTPHeaders, BlobAccessConditions)} + */ + public void setHTTPHeaders() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders + client.setHTTPHeaders(new BlobHTTPHeaders() + .blobContentLanguage("en-US") + .blobContentType("binary")).subscribe(response -> + System.out.printf("Set HTTP headers completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.setHTTPHeaders(new BlobHTTPHeaders() + .blobContentLanguage("en-US") + .blobContentType("binary"), accessConditions).subscribe(response -> + System.out.printf("Set HTTP headers completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#setMetadata(Metadata)} and + * {@link BlobAsyncClient#setMetadata(Metadata, BlobAccessConditions)} + */ + public void setMetadata() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata + client.setMetadata(new Metadata(Collections.singletonMap("metadata", "value"))) + .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata-BlobAccessConditions + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.setMetadata(new Metadata(Collections.singletonMap("metadata", "value")), accessConditions) + .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setMetadata#Metadata-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#createSnapshot()} and + * {@link BlobAsyncClient#createSnapshot(Metadata, BlobAccessConditions)} + */ + public void createSnapshot() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.createSnapshot + client.createSnapshot() + .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.createSnapshot + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.createSnapshot#Metadata-BlobAccessConditions + Metadata snapshotMetadata = new Metadata(Collections.singletonMap("metadata", "value")); + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + client.createSnapshot(snapshotMetadata, accessConditions) + .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.createSnapshot#Metadata-BlobAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#setTier(AccessTier)} and + * {@link BlobAsyncClient#setTier(AccessTier, LeaseAccessConditions)} + */ + public void setTier() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier + client.setTier(AccessTier.HOT) + .subscribe(response -> System.out.printf("Set tier completed with status code %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier-LeaseAccessConditions + LeaseAccessConditions accessConditions = new LeaseAccessConditions().leaseId(leaseId); + + client.setTier(AccessTier.HOT, accessConditions) + .subscribe(response -> System.out.printf("Set tier completed with status code %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.setTier#AccessTier-LeaseAccessConditions + } + + /** + * Code snippet for {@link BlobAsyncClient#undelete()} + */ + public void undelete() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.undelete + client.undelete() + .subscribe(response -> System.out.printf("Undelete completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.undelete + } + + /** + * Code snippets for {@link BlobAsyncClient#acquireLease(String, int)} and + * {@link BlobAsyncClient#acquireLease(String, int, ModifiedAccessConditions)} + */ + public void acquireLease() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int + client.acquireLease("proposedId", 60) + .subscribe(response -> System.out.printf("Lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int-ModifiedAccessConditions + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifModifiedSince(OffsetDateTime.now().minusDays(3)); + + client.acquireLease("proposedId", 60, modifiedAccessConditions) + .subscribe(response -> System.out.printf("Lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.acquireLease#String-int-ModifiedAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#renewLease(String)} and + * {@link BlobAsyncClient#renewLease(String, ModifiedAccessConditions)} + */ + public void renewLease() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.renewLease#String + client.renewLease(leaseId) + .subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.renewLease#String + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.renewLease#String-ModifiedAccessConditions + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + client.renewLease(leaseId, modifiedAccessConditions) + .subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.renewLease#String-ModifiedAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#releaseLease(String)} and + * {@link BlobAsyncClient#releaseLease(String, ModifiedAccessConditions)} + */ + public void releaseLease() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.releaseLease#String + client.releaseLease(leaseId) + .subscribe(response -> System.out.printf("Release lease completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.releaseLease#String + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.releaseLease#String-ModifiedAccessConditions + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + client.releaseLease(leaseId, modifiedAccessConditions) + .subscribe(response -> System.out.printf("Release lease completed with status %d%n", response.statusCode())); + // END: com.azure.storage.blob.BlobAsyncClient.releaseLease#String-ModifiedAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#breakLease()} and + * {@link BlobAsyncClient#breakLease(Integer, ModifiedAccessConditions)} + */ + public void breakLease() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.breakLease + client.breakLease() + .subscribe(response -> + System.out.printf("The broken lease has %d seconds remaining on the lease", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.breakLease + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.breakLease#Integer-ModifiedAccessConditions + Integer retainLeaseInSeconds = 5; + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + client.breakLease(retainLeaseInSeconds, modifiedAccessConditions) + .subscribe(response -> + System.out.printf("The broken lease has %d seconds remaining on the lease", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.breakLease#Integer-ModifiedAccessConditions + } + + /** + * Code snippets for {@link BlobAsyncClient#changeLease(String, String)} and + * {@link BlobAsyncClient#changeLease(String, String, ModifiedAccessConditions)} + */ + public void changeLease() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.changeLease#String-String + client.changeLease(leaseId, "proposedId") + .subscribe(response -> System.out.printf("Changed lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.changeLease#String-String + + // BEGIN: com.azure.storage.blob.BlobAsyncClient.changeLease#String-String-ModifiedAccessConditions + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + client.changeLease(leaseId, "proposedId", modifiedAccessConditions) + .subscribe(response -> System.out.printf("Changed lease ID is %s%n", response.value())); + // END: com.azure.storage.blob.BlobAsyncClient.changeLease#String-String-ModifiedAccessConditions + } + + /** + * Code snippet for {@link BlobAsyncClient#getAccountInfo()} + */ + public void getAccountInfo() { + // BEGIN: com.azure.storage.blob.BlobAsyncClient.getAccountInfo + client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", + response.value().accountKind(), response.value().skuName())); + // END: com.azure.storage.blob.BlobAsyncClient.getAccountInfo + } +} diff --git a/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..d99b83f910ad --- /dev/null +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/BlobClientJavaDocCodeSnippets.java @@ -0,0 +1,387 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob; + +import com.azure.storage.blob.models.AccessTier; +import com.azure.storage.blob.models.BlobAccessConditions; +import com.azure.storage.blob.models.BlobHTTPHeaders; +import com.azure.storage.blob.models.BlobRange; +import com.azure.storage.blob.models.DeleteSnapshotsOptionType; +import com.azure.storage.blob.models.LeaseAccessConditions; +import com.azure.storage.blob.models.Metadata; +import com.azure.storage.blob.models.ModifiedAccessConditions; +import com.azure.storage.blob.models.ReliableDownloadOptions; +import com.azure.storage.blob.models.StorageAccountInfo; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.net.URL; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Collections; + +/** + * Code snippets for {@link BlobClient} + */ +@SuppressWarnings("unused") +public class BlobClientJavaDocCodeSnippets { + private BlobClient client = JavaDocCodeSnippetsHelpers.getBlobClient("blobName"); + private String leaseId = "leaseId"; + private String copyId = "copyId"; + private URL url = JavaDocCodeSnippetsHelpers.generateURL("https://sample.com"); + private String file = "file"; + private Duration timeout = Duration.ofSeconds(30); + + /** + * Code snippets for {@link BlobClient#exists()} and {@link BlobClient#exists(Duration)} + */ + public void existsCodeSnippet() { + // BEGIN: com.azure.storage.blob.BlobClient.exists + System.out.printf("Exists? %b%n", client.exists().value()); + // END: com.azure.storage.blob.BlobClient.exists + + // BEGIN: com.azure.storage.blob.BlobClient.exists#Duration + System.out.printf("Exists? %b%n", client.exists(timeout).value()); + // END: com.azure.storage.blob.BlobClient.exists#Duration + } + + /** + * Code snippets for {@link BlobClient#startCopyFromURL(URL)} and + * {@link BlobClient#startCopyFromURL(URL, Metadata, ModifiedAccessConditions, BlobAccessConditions, Duration)} + */ + public void startCopyFromURL() { + // BEGIN: com.azure.storage.blob.BlobClient.startCopyFromURL#URL + System.out.printf("Copy identifier: %s%n", client.startCopyFromURL(url).value()); + // END: com.azure.storage.blob.BlobClient.startCopyFromURL#URL + + // BEGIN: com.azure.storage.blob.BlobClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration + Metadata metadata = new Metadata(Collections.singletonMap("metadata", "value")); + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + BlobAccessConditions blobAccessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + System.out.printf("Copy identifier: %s%n", + client.startCopyFromURL(url, metadata, modifiedAccessConditions, blobAccessConditions, timeout)); + // END: com.azure.storage.blob.BlobClient.startCopyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#abortCopyFromURL(String)} and + * {@link BlobClient#abortCopyFromURL(String, LeaseAccessConditions, Duration)} + */ + public void abortCopyFromURL() { + // BEGIN: com.azure.storage.blob.BlobClient.abortCopyFromURL#String + System.out.printf("Aborted copy completed with status %d%n", client.abortCopyFromURL(copyId).statusCode()); + // END: com.azure.storage.blob.BlobClient.abortCopyFromURL#String + + // BEGIN: com.azure.storage.blob.BlobClient.abortCopyFromURL#String-LeaseAccessConditions-Duration + LeaseAccessConditions leaseAccessConditions = new LeaseAccessConditions().leaseId(leaseId); + System.out.printf("Aborted copy completed with status %d%n", + client.abortCopyFromURL(copyId, leaseAccessConditions, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.abortCopyFromURL#String-LeaseAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#copyFromURL(URL)} and + * {@link BlobClient#copyFromURL(URL, Metadata, ModifiedAccessConditions, BlobAccessConditions, Duration)} + */ + public void copyFromURL() { + // BEGIN: com.azure.storage.blob.BlobClient.copyFromURL#URL + System.out.printf("Copy identifier: %s%n", client.copyFromURL(url).value()); + // END: com.azure.storage.blob.BlobClient.copyFromURL#URL + + // BEGIN: com.azure.storage.blob.BlobClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration + Metadata metadata = new Metadata(Collections.singletonMap("metadata", "value")); + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + BlobAccessConditions blobAccessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + System.out.printf("Copy identifier: %s%n", + client.copyFromURL(url, metadata, modifiedAccessConditions, blobAccessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.copyFromURL#URL-Metadata-ModifiedAccessConditions-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#download(OutputStream)} and + * {@link BlobClient#download(OutputStream, BlobRange, ReliableDownloadOptions, BlobAccessConditions, boolean, Duration)} + */ + public void download() { + // BEGIN: com.azure.storage.blob.BlobClient.download#OutputStream + System.out.printf("Download completed with status %d%n", + client.download(new ByteArrayOutputStream()).statusCode()); + // END: com.azure.storage.blob.BlobClient.download#OutputStream + + // BEGIN: com.azure.storage.blob.BlobClient.download#OutputStream-BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration + BlobRange range = new BlobRange(1024, 2048); + ReliableDownloadOptions options = new ReliableDownloadOptions().maxRetryRequests(5); + + System.out.printf("Download completed with status %d%n", + client.download(new ByteArrayOutputStream(), range, options, null, false, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.download#OutputStream-BlobRange-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration + } + + /** + * Code snippets for {@link BlobClient#downloadToFile(String)} and + * {@link BlobClient#downloadToFile(String, BlobRange, Integer, ReliableDownloadOptions, BlobAccessConditions, boolean, Duration)} + */ + public void downloadToFile() { + // BEGIN: com.azure.storage.blob.BlobClient.downloadToFile#String + client.downloadToFile(file); + System.out.println("Completed download to file"); + // END: com.azure.storage.blob.BlobClient.downloadToFile#String + + // BEGIN: com.azure.storage.blob.BlobClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration + BlobRange range = new BlobRange(1024, 2048); + ReliableDownloadOptions options = new ReliableDownloadOptions().maxRetryRequests(5); + + client.downloadToFile(file, range, null, options, null, false, timeout); + System.out.println("Completed download to file"); + // END: com.azure.storage.blob.BlobClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration + } + + /** + * Code snippets for {@link BlobClient#delete()} and + * {@link BlobClient#delete(DeleteSnapshotsOptionType, BlobAccessConditions, Duration)} + */ + public void delete() { + // BEGIN: com.azure.storage.blob.BlobClient.delete + System.out.printf("Delete completed with status %d%n", client.delete().statusCode()); + // END: com.azure.storage.blob.BlobClient.delete + + // BEGIN: com.azure.storage.blob.BlobClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions-Duration + System.out.printf("Delete completed with status %d%n", + client.delete(DeleteSnapshotsOptionType.INCLUDE, null, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.delete#DeleteSnapshotsOptionType-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#getProperties()} + */ + public void getProperties() { + // BEGIN: com.azure.storage.blob.BlobClient.getProperties + BlobProperties properties = client.getProperties().value(); + System.out.printf("Type: %s, Size: %d%n", properties.blobType(), properties.blobSize()); + // END: com.azure.storage.blob.BlobClient.getProperties + } + + /** + * Code snippet for {@link BlobClient#getProperties(BlobAccessConditions, Duration)} + */ + public void getPropertiesWithTimeout() { + // BEGIN: com.azure.storage.blob.BlobClient.getProperties#BlobAccessConditions-Duration + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + BlobProperties properties = client.getProperties(accessConditions, timeout).value(); + System.out.printf("Type: %s, Size: %d%n", properties.blobType(), properties.blobSize()); + // END: com.azure.storage.blob.BlobClient.getProperties#BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#setHTTPHeaders(BlobHTTPHeaders)} and + * {@link BlobClient#setHTTPHeaders(BlobHTTPHeaders, BlobAccessConditions, Duration)} + */ + public void setHTTPHeaders() { + // BEGIN: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders + System.out.printf("Set HTTP headers completed with status %d%n", + client.setHTTPHeaders(new BlobHTTPHeaders() + .blobContentLanguage("en-US") + .blobContentType("binary")) + .statusCode()); + // END: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders + + // BEGIN: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions-Duration + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + System.out.printf("Set HTTP headers completed with status %d%n", + client.setHTTPHeaders(new BlobHTTPHeaders() + .blobContentLanguage("en-US") + .blobContentType("binary"), accessConditions, timeout) + .statusCode()); + // END: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#setMetadata(Metadata)} and + * {@link BlobClient#setMetadata(Metadata, BlobAccessConditions, Duration)} + */ + public void setMetadata() { + // BEGIN: com.azure.storage.blob.BlobClient.setMetadata#Metadata + System.out.printf("Set metadata completed with status %d%n", + client.setMetadata(new Metadata(Collections.singletonMap("metadata", "value"))).statusCode()); + // END: com.azure.storage.blob.BlobClient.setMetadata#Metadata + + // BEGIN: com.azure.storage.blob.BlobClient.setMetadata#Metadata-BlobAccessConditions-Duration + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + System.out.printf("Set metadata completed with status %d%n", + client.setMetadata( + new Metadata(Collections.singletonMap("metadata", "value")), accessConditions, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.setMetadata#Metadata-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#createSnapshot()} and + * {@link BlobClient#createSnapshot(Metadata, BlobAccessConditions, Duration)} + */ + public void createSnapshot() { + // BEGIN: com.azure.storage.blob.BlobClient.createSnapshot + System.out.printf("Identifier for the snapshot is %s%n", client.createSnapshot().value()); + // END: com.azure.storage.blob.BlobClient.createSnapshot + + // BEGIN: com.azure.storage.blob.BlobClient.createSnapshot#Metadata-BlobAccessConditions-Duration + Metadata snapshotMetadata = new Metadata(Collections.singletonMap("metadata", "value")); + BlobAccessConditions accessConditions = new BlobAccessConditions() + .leaseAccessConditions(new LeaseAccessConditions().leaseId(leaseId)); + + System.out.printf("Identifier for the snapshot is %s%n", + client.createSnapshot(snapshotMetadata, accessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.createSnapshot#Metadata-BlobAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#setTier(AccessTier)} and + * {@link BlobClient#setTier(AccessTier, LeaseAccessConditions, Duration)} + */ + public void setTier() { + // BEGIN: com.azure.storage.blob.BlobClient.setTier#AccessTier + System.out.printf("Set tier completed with status code %d%n", client.setTier(AccessTier.HOT).statusCode()); + // END: com.azure.storage.blob.BlobClient.setTier#AccessTier + + // BEGIN: com.azure.storage.blob.BlobClient.setTier#AccessTier-LeaseAccessConditions-Duration + LeaseAccessConditions accessConditions = new LeaseAccessConditions().leaseId(leaseId); + + System.out.printf("Set tier completed with status code %d%n", + client.setTier(AccessTier.HOT, accessConditions, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.setTier#AccessTier-LeaseAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#undelete()} and {@link BlobClient#undelete(Duration)} + */ + public void undelete() { + // BEGIN: com.azure.storage.blob.BlobClient.undelete + System.out.printf("Undelete completed with status %d%n", client.undelete().statusCode()); + // END: com.azure.storage.blob.BlobClient.undelete + + // BEGIN: com.azure.storage.blob.BlobClient.undelete#Duration + System.out.printf("Undelete completed with status %d%n", client.undelete(timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.undelete#Duration + } + + /** + * Code snippets for {@link BlobClient#acquireLease(String, int)} and + * {@link BlobClient#acquireLease(String, int, ModifiedAccessConditions, Duration)} + */ + public void acquireLease() { + // BEGIN: com.azure.storage.blob.BlobClient.acquireLease#String-int + System.out.printf("Lease ID is %s%n", client.acquireLease("proposedId", 60).value()); + // END: com.azure.storage.blob.BlobClient.acquireLease#String-int + + // BEGIN: com.azure.storage.blob.BlobClient.acquireLease#String-int-ModifiedAccessConditions-Duration + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifModifiedSince(OffsetDateTime.now().minusDays(3)); + + System.out.printf("Lease ID is %s%n", + client.acquireLease("proposedId", 60, modifiedAccessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.acquireLease#String-int-ModifiedAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#renewLease(String)} and + * {@link BlobClient#renewLease(String, ModifiedAccessConditions, Duration)} + */ + public void renewLease() { + // BEGIN: com.azure.storage.blob.BlobClient.renewLease#String + System.out.printf("Renewed lease ID is %s%n", client.renewLease(leaseId).value()); + // END: com.azure.storage.blob.BlobClient.renewLease#String + + // BEGIN: com.azure.storage.blob.BlobClient.renewLease#String-ModifiedAccessConditions-Duration + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + System.out.printf("Renewed lease ID is %s%n", + client.renewLease(leaseId, modifiedAccessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.renewLease#String-ModifiedAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#releaseLease(String)} and + * {@link BlobClient#releaseLease(String, ModifiedAccessConditions, Duration)} + */ + public void releaseLease() { + // BEGIN: com.azure.storage.blob.BlobClient.releaseLease#String + System.out.printf("Release lease completed with status %d%n", client.releaseLease(leaseId).statusCode()); + // END: com.azure.storage.blob.BlobClient.releaseLease#String + + // BEGIN: com.azure.storage.blob.BlobClient.releaseLease#String-ModifiedAccessConditions-Duration + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + System.out.printf("Release lease completed with status %d%n", + client.releaseLease(leaseId, modifiedAccessConditions, timeout).statusCode()); + // END: com.azure.storage.blob.BlobClient.releaseLease#String-ModifiedAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#breakLease()} and + * {@link BlobClient#breakLease(Integer, ModifiedAccessConditions, Duration)} + */ + public void breakLease() { + // BEGIN: com.azure.storage.blob.BlobClient.breakLease + System.out.printf("The broken lease has %d seconds remaining on the lease", client.breakLease().value()); + // END: com.azure.storage.blob.BlobClient.breakLease + + // BEGIN: com.azure.storage.blob.BlobClient.breakLease#Integer-ModifiedAccessConditions-Duration + Integer retainLeaseInSeconds = 5; + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + System.out.printf("The broken lease has %d seconds remaining on the lease", + client.breakLease(retainLeaseInSeconds, modifiedAccessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.breakLease#Integer-ModifiedAccessConditions-Duration + } + + /** + * Code snippets for {@link BlobClient#changeLease(String, String)} and + * {@link BlobClient#changeLease(String, String, ModifiedAccessConditions, Duration)} + */ + public void changeLease() { + // BEGIN: com.azure.storage.blob.BlobClient.changeLease#String-String + System.out.printf("Changed lease ID is %s%n", client.changeLease(leaseId, "proposedId").value()); + // END: com.azure.storage.blob.BlobClient.changeLease#String-String + + // BEGIN: com.azure.storage.blob.BlobClient.changeLease#String-String-ModifiedAccessConditions-Duration + ModifiedAccessConditions modifiedAccessConditions = new ModifiedAccessConditions() + .ifUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + + System.out.printf("Changed lease ID is %s%n", + client.changeLease(leaseId, "proposedId", modifiedAccessConditions, timeout).value()); + // END: com.azure.storage.blob.BlobClient.changeLease#String-String-ModifiedAccessConditions-Duration + } + + /** + * Code snippet for {@link BlobClient#getAccountInfo()} + */ + public void getAccountInfo() { + // BEGIN: com.azure.storage.blob.BlobClient.getAccountInfo + StorageAccountInfo accountInfo = client.getAccountInfo().value(); + System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.accountKind(), accountInfo.skuName()); + // END: com.azure.storage.blob.BlobClient.getAccountInfo + } + + /** + * Code snippet for {@link BlobClient#getAccountInfo(Duration)} + */ + public void getAccountInfoWithTimeout() { + // BEGIN: com.azure.storage.blob.BlobClient.getAccountInfo#Duration + StorageAccountInfo accountInfo = client.getAccountInfo(timeout).value(); + System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.accountKind(), accountInfo.skuName()); + // END: com.azure.storage.blob.BlobClient.getAccountInfo#Duration + } +} diff --git a/storage/client/blob/src/samples/java/FileTransferExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java similarity index 93% rename from storage/client/blob/src/samples/java/FileTransferExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java index cfd281c1e3f8..33886cd10750 100644 --- a/storage/client/blob/src/samples/java/FileTransferExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/FileTransferExample.java @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import com.azure.storage.blob.BlockBlobClient; -import com.azure.storage.blob.ContainerClient; -import com.azure.storage.blob.StorageClient; -import com.azure.storage.blob.StorageClientBuilder; +package com.azure.storage.blob; + import com.azure.storage.common.credentials.SharedKeyCredential; import java.io.File; @@ -52,10 +50,10 @@ public static void main(String[] args) throws IOException, NoSuchAlgorithmExcept String endPoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); /* - * Create a StorageClient object that wraps the service endpoint, credential and a request pipeline. + * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. * Now you can use the storageClient to perform various container and blob operations. */ - StorageClient storageClient = new StorageClientBuilder().endpoint(endPoint).credential(credential).buildClient(); + BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endPoint).credential(credential).buildClient(); /* diff --git a/storage/client/blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java new file mode 100644 index 000000000000..febf2861cad9 --- /dev/null +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/JavaDocCodeSnippetsHelpers.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.blob; + +import java.net.MalformedURLException; +import java.net.URL; + +final class JavaDocCodeSnippetsHelpers { + static ContainerAsyncClient getContainerAsyncClient() { + return new ContainerClientBuilder().buildAsyncClient(); + } + + static BlobAsyncClient getBlobAsyncClient(String blobName) { + return getContainerAsyncClient().getBlobAsyncClient(blobName); + } + + static BlobClient getBlobClient(String blobName) { + return new BlobClient(getBlobAsyncClient(blobName)); + } + + static URL generateURL(String urlString) { + try { + return new URL(urlString); + } catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/storage/client/blob/src/samples/java/ListContainersExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java similarity index 84% rename from storage/client/blob/src/samples/java/ListContainersExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java index ab8c9b3709bc..5588ef64241c 100644 --- a/storage/client/blob/src/samples/java/ListContainersExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/ListContainersExample.java @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import com.azure.storage.blob.StorageClient; -import com.azure.storage.blob.StorageClientBuilder; +package com.azure.storage.blob; + import com.azure.storage.common.credentials.SharedKeyCredential; import java.util.Locale; @@ -32,9 +32,9 @@ public static void main(String[] args) { String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); /* - * Create a StorageClient object that wraps the service endpoint, credential and a request pipeline. + * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. */ - StorageClient storageClient = new StorageClientBuilder().endpoint(endpoint).credential(credential).buildClient(); + BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); /* * Create 3 different containers from the storageClient. diff --git a/storage/client/blob/src/samples/java/SampleHelper.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/SampleHelper.java similarity index 94% rename from storage/client/blob/src/samples/java/SampleHelper.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/SampleHelper.java index d841413f06bc..f72655d856bd 100644 --- a/storage/client/blob/src/samples/java/SampleHelper.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/SampleHelper.java @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +package com.azure.storage.blob; + import com.azure.core.util.configuration.ConfigurationManager; /** diff --git a/storage/client/blob/src/samples/java/SetMetadataAndHTTPHeadersExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java similarity index 87% rename from storage/client/blob/src/samples/java/SetMetadataAndHTTPHeadersExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java index 6b475499eab2..591e78141f70 100644 --- a/storage/client/blob/src/samples/java/SetMetadataAndHTTPHeadersExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/SetMetadataAndHTTPHeadersExample.java @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import com.azure.storage.blob.BlockBlobClient; -import com.azure.storage.blob.ContainerClient; -import com.azure.storage.blob.StorageClient; -import com.azure.storage.blob.StorageClientBuilder; +package com.azure.storage.blob; + import com.azure.storage.blob.models.BlobHTTPHeaders; import com.azure.storage.blob.models.Metadata; import com.azure.storage.common.credentials.SharedKeyCredential; @@ -42,9 +40,9 @@ public static void main(String[] args) throws IOException { String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName); /* - * Create a StorageClient object that wraps the service endpoint, credential and a request pipeline. + * Create a BlobServiceClient object that wraps the service endpoint, credential and a request pipeline. */ - StorageClient storageClient = new StorageClientBuilder().endpoint(endpoint).credential(credential).buildClient(); + BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); /* * Create a container client from storageClient. diff --git a/storage/client/blob/src/samples/java/StorageErrorHandlingExample.java b/storage/client/blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java similarity index 94% rename from storage/client/blob/src/samples/java/StorageErrorHandlingExample.java rename to storage/client/blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java index 50d4e81d600c..3a84d7026f7b 100644 --- a/storage/client/blob/src/samples/java/StorageErrorHandlingExample.java +++ b/storage/client/blob/src/samples/java/com/azure/storage/blob/StorageErrorHandlingExample.java @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +package com.azure.storage.blob; + import com.azure.core.http.HttpResponse; -import com.azure.storage.blob.ContainerClient; -import com.azure.storage.blob.ContainerClientBuilder; -import com.azure.storage.blob.StorageException; import com.azure.storage.blob.models.StorageErrorCode; /** diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/APISpec.groovy b/storage/client/blob/src/test/java/com/azure/storage/blob/APISpec.groovy index daf12f13fb8e..abac9b167e18 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/APISpec.groovy +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/APISpec.groovy @@ -56,7 +56,7 @@ class APISpec extends Specification { static defaultDataSize = defaultData.remaining() // If debugging is enabled, recordings cannot run as there can only be one proxy at a time. - static boolean enableDebugging = true + static boolean enableDebugging = false // Prefixes for blobs and containers static String containerPrefix = "jtc" // java test container @@ -98,16 +98,16 @@ class APISpec extends Specification { /* URLs to various kinds of accounts. */ - StorageClient primaryServiceURL + BlobServiceClient primaryServiceURL @Shared - static StorageClient alternateServiceURL + static BlobServiceClient alternateServiceURL @Shared - static StorageClient blobStorageServiceURL + static BlobServiceClient blobStorageServiceURL @Shared - static StorageClient premiumServiceURL + static BlobServiceClient premiumServiceURL /* Constants for testing that the context parameter is properly passed to the pipeline. @@ -195,10 +195,10 @@ class APISpec extends Specification { } } - static StorageClient getGenericServiceURL(SharedKeyCredential creds) { + static BlobServiceClient getGenericServiceURL(SharedKeyCredential creds) { // TODO: logging? - return new StorageClientBuilder() + return new BlobServiceClientBuilder() .endpoint("https://" + creds.accountName() + ".blob.core.windows.net") .httpClient(getHttpClient()) .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS) @@ -207,7 +207,7 @@ class APISpec extends Specification { } static void cleanupContainers() throws MalformedURLException { - StorageClient serviceURL = new StorageClientBuilder() + BlobServiceClient serviceURL = new BlobServiceClientBuilder() .endpoint("http://" + primaryCreds.accountName() + ".blob.core.windows.net") .credential(primaryCreds) .buildClient() @@ -556,7 +556,7 @@ class APISpec extends Specification { } def getOAuthServiceURL() { - return new StorageClientBuilder() + return new BlobServiceClientBuilder() .endpoint(String.format("https://%s.blob.core.windows.net/", primaryCreds.accountName())) .credential(new EnvironmentCredential()) // AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET .buildClient() diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/AadLoginTest.java b/storage/client/blob/src/test/java/com/azure/storage/blob/AadLoginTest.java index 3c2ee324d196..b284e65beb8c 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/AadLoginTest.java +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/AadLoginTest.java @@ -11,11 +11,11 @@ public class AadLoginTest { private static final Random RANDOM = new Random(); - private static StorageClient storageClient; + private static BlobServiceClient storageClient; @BeforeClass public static void setup() { - storageClient = new StorageClientBuilder() + storageClient = new BlobServiceClientBuilder() .endpoint("https://" + System.getenv("ACCOUNT_NAME") + ".blob.core.windows.net") .credential(new EnvironmentCredential()) // .httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888)))) diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy b/storage/client/blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy index d0be4d532642..5c1bd1178736 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/BlobAPITest.groovy @@ -138,7 +138,7 @@ class BlobAPITest extends APISpec { when: def outStream = new ByteArrayOutputStream() - bu.download(outStream, null, range, null, false, null) + bu.download(outStream, range, null, null, false, null) String bodyStr = outStream.toString() then: @@ -208,7 +208,7 @@ class BlobAPITest extends APISpec { def "Download md5"() { when: - VoidResponse response = bu.download(new ByteArrayOutputStream(), null, new BlobRange(0 ,3), null, true, null) + VoidResponse response = bu.download(new ByteArrayOutputStream(), new BlobRange(0 ,3), null, null, true, null) byte[] contentMD5 = response.headers().value("content-md5").getBytes() then: @@ -1872,7 +1872,7 @@ class BlobAPITest extends APISpec { def "Get account info error"() { when: - StorageClient serviceURL = new StorageClientBuilder() + BlobServiceClient serviceURL = new BlobServiceClientBuilder() .endpoint(primaryServiceURL.getAccountUrl().toString()) .buildClient() serviceURL.getContainerClient(generateContainerName()).getBlobClient(generateBlobName()) diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTest.java b/storage/client/blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTest.java index 7ebc5e8487cf..e7955c9b7be9 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTest.java +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/BlobOutputStreamTest.java @@ -17,12 +17,12 @@ public class BlobOutputStreamTest { private static final Random RANDOM = new Random(); - private static StorageClient storageClient; + private static BlobServiceClient storageClient; private static ContainerClient containerClient; @BeforeClass public static void setup() { - storageClient = new StorageClientBuilder() + storageClient = new BlobServiceClientBuilder() .endpoint("https://" + System.getenv("ACCOUNT_NAME") + ".blob.core.windows.net") .credential(new SharedKeyCredential(System.getenv("ACCOUNT_NAME"), System.getenv("ACCOUNT_KEY"))) // .httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888)))) diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy b/storage/client/blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy index 86da9838d53b..f82f1d4220eb 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/ContainerAPITest.groovy @@ -1624,7 +1624,7 @@ class ContainerAPITest extends APISpec { def "Get account info error"() { when: - StorageClient serviceURL = new StorageClientBuilder() + BlobServiceClient serviceURL = new BlobServiceClientBuilder() .endpoint(primaryServiceURL.getAccountUrl().toString()) .buildClient() diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/LargeFileTest.java b/storage/client/blob/src/test/java/com/azure/storage/blob/LargeFileTest.java index a692d6d4c3c3..8bff57d55951 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/LargeFileTest.java +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/LargeFileTest.java @@ -13,12 +13,12 @@ public class LargeFileTest { private static final Random RANDOM = new Random(); private static final String FILE_PATH = "C:\\Users\\jianghlu\\10g.dat"; - private static StorageClient storageClient; + private static BlobServiceClient storageClient; private static ContainerClient containerClient; //@BeforeClass public static void setup() { - storageClient = new StorageClientBuilder() + storageClient = new BlobServiceClientBuilder() .credential(new SharedKeyCredential(System.getenv("ACCOUNT_NAME"), System.getenv("ACCOUNT_KEY"))) .endpoint("https://" + System.getenv("ACCOUNT_NAME") + ".blob.core.windows.net") // .httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888)))) diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/SASTest.groovy b/storage/client/blob/src/test/java/com/azure/storage/blob/SASTest.groovy index 2824ac1d3067..705453b54968 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/SASTest.groovy +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/SASTest.groovy @@ -482,7 +482,7 @@ class SASTest extends APISpec { when: def sas = primaryServiceURL.generateAccountSAS(service, resourceType, permissions, expiryTime, null, null, null, null) - def scBuilder = new StorageClientBuilder() + def scBuilder = new BlobServiceClientBuilder() scBuilder.endpoint(primaryServiceURL.getAccountUrl().toString()) .httpClient(getHttpClient()) .credential(SASTokenCredential.fromSASTokenString(sas)) @@ -509,7 +509,7 @@ class SASTest extends APISpec { when: def sas = primaryServiceURL.generateAccountSAS(service, resourceType, permissions, expiryTime, null, null, null, null) - def scBuilder = new StorageClientBuilder() + def scBuilder = new BlobServiceClientBuilder() scBuilder.endpoint(primaryServiceURL.getAccountUrl().toString()) .httpClient(getHttpClient()) .credential(SASTokenCredential.fromSASTokenString(sas)) diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/Sample.java b/storage/client/blob/src/test/java/com/azure/storage/blob/Sample.java index f6d19d6b8416..d5955365880a 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/Sample.java +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/Sample.java @@ -30,7 +30,7 @@ public class Sample { //@Test public void sample() throws IOException { // get service client - StorageClient serviceClient = new StorageClientBuilder().endpoint(ACCOUNT_ENDPOINT) + BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(ACCOUNT_ENDPOINT) .credential(new SharedKeyCredential(ACCOUNT_NAME, ACCOUNT_KEY)) .httpClient(HttpClient.createDefault()/*.proxy(() -> new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888)))*/) .buildClient(); @@ -82,7 +82,7 @@ public void sample() throws IOException { //@Test public void asyncSample() throws IOException { // get service client - StorageAsyncClient serviceClient = new StorageClientBuilder().endpoint(ACCOUNT_ENDPOINT) + BlobServiceAsyncClient serviceClient = new BlobServiceClientBuilder().endpoint(ACCOUNT_ENDPOINT) .credential(new SharedKeyCredential(ACCOUNT_NAME, ACCOUNT_KEY)) .httpClient(HttpClient.createDefault()/*.proxy(() -> new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888)))*/) .buildAsyncClient(); @@ -161,7 +161,7 @@ public void uploadDownloadFromFile() throws IOException { fstream.close(); // get service client - StorageClient serviceClient = new StorageClientBuilder().endpoint(ACCOUNT_ENDPOINT) + BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(ACCOUNT_ENDPOINT) .credential(new SharedKeyCredential(ACCOUNT_NAME, ACCOUNT_KEY)) .httpClient(HttpClient.createDefault()/*.proxy(() -> new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888)))*/) .buildClient(); @@ -191,7 +191,7 @@ public void uploadDownloadFromFileAsync() throws IOException { fstream.close(); // get service client - StorageAsyncClient serviceClient = new StorageClientBuilder().endpoint(ACCOUNT_ENDPOINT) + BlobServiceAsyncClient serviceClient = new BlobServiceClientBuilder().endpoint(ACCOUNT_ENDPOINT) .credential(new SharedKeyCredential(ACCOUNT_NAME, ACCOUNT_KEY)) .httpClient(HttpClient.createDefault()/*.proxy(() -> new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888)))*/) .buildAsyncClient(); diff --git a/storage/client/blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy b/storage/client/blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy index d6e8861b4739..830dd34c2203 100644 --- a/storage/client/blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy +++ b/storage/client/blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy @@ -234,7 +234,7 @@ class ServiceAPITest extends APISpec { def "Set props error"() { when: - new StorageClientBuilder() + new BlobServiceClientBuilder() .endpoint("https://error.blob.core.windows.net") .credential(primaryCreds) .buildClient() @@ -251,7 +251,7 @@ class ServiceAPITest extends APISpec { def "Get props error"() { when: - new StorageClientBuilder() + new BlobServiceClientBuilder() .endpoint("https://error.blob.core.windows.net") .credential(primaryCreds) .buildClient() @@ -306,7 +306,7 @@ class ServiceAPITest extends APISpec { def "Get stats"() { setup: String secondaryEndpoint = String.format("https://%s-secondary.blob.core.windows.net", primaryCreds.accountName()) - StorageClient serviceClient = new StorageClientBuilder().endpoint(secondaryEndpoint) + BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(secondaryEndpoint) .credential(primaryCreds).buildClient() Response response = serviceClient.getStatistics() @@ -321,7 +321,7 @@ class ServiceAPITest extends APISpec { def "Get stats min"() { setup: String secondaryEndpoint = String.format("https://%s-secondary.blob.core.windows.net", primaryCreds.accountName()) - StorageClient serviceClient = new StorageClientBuilder().endpoint(secondaryEndpoint) + BlobServiceClient serviceClient = new BlobServiceClientBuilder().endpoint(secondaryEndpoint) .credential(primaryCreds).buildClient() expect: serviceClient.getStatistics().statusCode() == 200 @@ -354,7 +354,7 @@ class ServiceAPITest extends APISpec { def "Get account info error"() { when: - StorageClient serviceURL = new StorageClientBuilder() + BlobServiceClient serviceURL = new BlobServiceClientBuilder() .endpoint(primaryServiceURL.getAccountUrl().toString()) .buildClient() serviceURL.getAccountInfo() @@ -368,7 +368,7 @@ class ServiceAPITest extends APISpec { def "Invalid account name"() { setup: URL badURL = new URL("http://fake.blobfake.core.windows.net") - StorageClient client = new StorageClientBuilder() + BlobServiceClient client = new BlobServiceClientBuilder() .endpoint(badURL.toString()) .credential(primaryCreds) .retryOptions(new RequestRetryOptions(null, 2, null, null, null, null)) diff --git a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java index 4bd8de4b8f13..659d128dc243 100644 --- a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java +++ b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java @@ -108,6 +108,9 @@ public URL getQueueUrl() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.create} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If a queue with the same name already exists in the queue service. */ @@ -124,6 +127,9 @@ public Mono create() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.create#map} * + *

For more information, see the + * Azure Docs.

+ * * @param metadata Metadata to associate with the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If a queue with the same name and different metadata already exists in the queue service. @@ -142,6 +148,9 @@ public Mono create(Map metadata) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.delete} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist */ @@ -159,6 +168,9 @@ public Mono delete() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.getProperties} * + *

For more information, see the + * Azure Docs.

+ * * @return A response containing a {@link QueueProperties} value which contains the metadata and approximate * messages count of the queue. * @throws StorageErrorException If the queue doesn't exist @@ -183,6 +195,9 @@ public Mono> getProperties() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.clearMetadata#map} * + *

For more information, see the + * Azure Docs.

+ * * @param metadata Metadata to set on the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist @@ -201,6 +216,9 @@ public Mono setMetadata(Map metadata) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.getAccessPolicy} * + *

For more information, see the + * Azure Docs.

+ * * @return The stored access policies specified on the queue. * @throws StorageErrorException If the queue doesn't exist */ @@ -218,6 +236,9 @@ public Flux getAccessPolicy() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.setAccessPolicy} * + *

For more information, see the + * Azure Docs.

+ * * @param permissions Access policies to set on the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist, a stored access policy doesn't have all fields filled out, @@ -237,6 +258,9 @@ public Mono setAccessPolicy(List permissions) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.clearMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist */ @@ -254,6 +278,9 @@ public Mono clearMessages() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.enqueueMessage#string} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Message text * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata @@ -277,6 +304,9 @@ public Mono> enqueueMessage(String messageText) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.enqueueMessageLiveTime#string-duration-duration} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Message text * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. * If unset the value will default to 0 and the message will be instantly visible. The timeout must be between 0 @@ -307,6 +337,9 @@ public Mono> enqueueMessage(String messageText, Durati * * {@codesnippet com.azure.storage.queue.queueAsyncClient.dequeueMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return The first {@link DequeuedMessage} in the queue, it contains * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact * with the message, additionally it contains other metadata about the message. @@ -325,6 +358,9 @@ public Flux dequeueMessages() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.dequeueMessages#integer} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 * messages. @@ -347,6 +383,9 @@ public Flux dequeueMessages(Integer maxMessages) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.dequeueMessages#integer-duration} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 * messages. @@ -376,6 +415,9 @@ public Flux dequeueMessages(Integer maxMessages, Duration visib * * {@codesnippet com.azure.storage.queue.queueAsyncClient.peekMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return A {@link PeekedMessage} that contains metadata about the message. */ public Flux peekMessages() { @@ -394,6 +436,9 @@ public Flux peekMessages() { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.peekMessages#integer} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to peek, if there are less messages exist in the queue than requested * all the messages will be peeked. If left empty only 1 message will be peeked, the allowed range is 1 to 32 * messages. @@ -415,6 +460,9 @@ public Flux peekMessages(Integer maxMessages) { * * {@codesnippet com.azure.storage.queue.queueAsyncClient.updateMessage} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Updated value for the message * @param messageId Id of the message to update * @param popReceipt Unique identifier that must match for the message to be updated @@ -440,6 +488,9 @@ public Mono> updateMessage(String messageText, String m * * {@codesnippet com.azure.storage.queue.queueAsyncClient.deleteMessage} * + *

For more information, see the + * Azure Docs.

+ * * @param messageId Id of the message to deleted * @param popReceipt Unique identifier that must match for the message to be deleted * @return A response that only contains headers and response status code diff --git a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueClient.java b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueClient.java index 763c58560871..3e55da311b15 100644 --- a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueClient.java +++ b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueClient.java @@ -63,6 +63,9 @@ public URL getQueueUrl() { * *{@codesnippet com.azure.storage.queue.queueClient.create} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If a queue with the same name already exists in the queue service. */ @@ -79,6 +82,9 @@ public VoidResponse create() { * * {@codesnippet com.azure.storage.queue.queueClient.create#map} * + *

For more information, see the + * Azure Docs.

+ * * @param metadata Metadata to associate with the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If a queue with the same name and different metadata already exists in the queue service. @@ -96,6 +102,9 @@ public VoidResponse create(Map metadata) { * * {@codesnippet com.azure.storage.queue.queueClient.delete} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist */ @@ -112,6 +121,9 @@ public VoidResponse delete() { * * {@codesnippet com.azure.storage.queue.queueClient.getProperties} * + *

For more information, see the + * Azure Docs.

+ * * @return A response containing a {@link QueueProperties} value which contains the metadata and approximate * messages count of the queue. * @throws StorageErrorException If the queue doesn't exist @@ -135,6 +147,9 @@ public Response getProperties() { * * {@codesnippet com.azure.storage.queue.queueClient.clearMetadata#map} * + *

For more information, see the + * Azure Docs.

+ * * @param metadata Metadata to set on the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist @@ -152,6 +167,9 @@ public VoidResponse setMetadata(Map metadata) { * * {@codesnippet com.azure.storage.queue.queueClient.getAccessPolicy} * + *

For more information, see the + * Azure Docs.

+ * * @return The stored access policies specified on the queue. * @throws StorageErrorException If the queue doesn't exist */ @@ -168,6 +186,9 @@ public Iterable getAccessPolicy() { * * {@codesnippet com.azure.storage.queue.queueClient.setAccessPolicy} * + *

For more information, see the + * Azure Docs.

+ * * @param permissions Access policies to set on the queue * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist, a stored access policy doesn't have all fields filled out, @@ -186,6 +207,9 @@ public VoidResponse setAccessPolicy(List permissions) { * * {@codesnippet com.azure.storage.queue.queueClient.clearMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return A response that only contains headers and response status code * @throws StorageErrorException If the queue doesn't exist */ @@ -202,6 +226,9 @@ public VoidResponse clearMessages() { * * {@codesnippet com.azure.storage.queue.queueClient.enqueueMessage#string} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Message text * @return A {@link EnqueuedMessage} value that contains the {@link EnqueuedMessage#messageId() messageId} and * {@link EnqueuedMessage#popReceipt() popReceipt} that are used to interact with the message and other metadata @@ -225,6 +252,9 @@ public Response enqueueMessage(String messageText) { * * {@codesnippet com.azure.storage.queue.queueClient.enqueueMessageLiveTime#string-duration-duration} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Message text * @param visibilityTimeout Optional. The timeout period for how long the message is invisible in the queue in seconds. * If unset the value will default to 0 and the message will be instantly visible. The timeout must be between 0 @@ -250,6 +280,9 @@ public Response enqueueMessage(String messageText, Duration vis * * {@codesnippet com.azure.storage.queue.queueClient.dequeueMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return The first {@link DequeuedMessage} in the queue, it contains * {@link DequeuedMessage#messageId() messageId} and {@link DequeuedMessage#popReceipt() popReceipt} used to interact * with the message, additionally it contains other metadata about the message. @@ -268,6 +301,9 @@ public Iterable dequeueMessages() { * * {@codesnippet com.azure.storage.queue.queueClient.dequeueMessages#integer} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 * messages. @@ -290,6 +326,9 @@ public Iterable dequeueMessages(Integer maxMessages) { * * {@codesnippet com.azure.storage.queue.queueClient.dequeueMessages#integer-duration} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to get, if there are less messages exist in the queue than requested * all the messages will be returned. If left empty only 1 message will be retrieved, the allowed range is 1 to 32 * messages. @@ -317,6 +356,9 @@ public Iterable dequeueMessages(Integer maxMessages, Duration v * * {@codesnippet com.azure.storage.queue.queueClient.peekMessages} * + *

For more information, see the + * Azure Docs.

+ * * @return A {@link PeekedMessage} that contains metadata about the message. */ public Iterable peekMessages() { @@ -335,6 +377,9 @@ public Iterable peekMessages() { * * {@codesnippet com.azure.storage.queue.queueClient.peekMessages#integer} * + *

For more information, see the + * Azure Docs.

+ * * @param maxMessages Optional. Maximum number of messages to peek, if there are less messages exist in the queue than requested * all the messages will be peeked. If left empty only 1 message will be peeked, the allowed range is 1 to 32 * messages. @@ -355,6 +400,9 @@ public Iterable peekMessages(Integer maxMessages) { * * {@codesnippet com.azure.storage.queue.queueClient.updateMessage} * + *

For more information, see the + * Azure Docs.

+ * * @param messageText Updated value for the message * @param messageId Id of the message to update * @param popReceipt Unique identifier that must match for the message to be updated @@ -378,6 +426,9 @@ public Response updateMessage(String messageText, String message * * {@codesnippet com.azure.storage.queue.queueClient.deleteMessage} * + *

For more information, see the + * Azure Docs.

+ * * @param messageId Id of the message to deleted * @param popReceipt Unique identifier that must match for the message to be deleted * @return A response that only contains headers and response status code diff --git a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java index 6e6b099653bc..74a6e978a4f0 100644 --- a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java +++ b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java @@ -21,13 +21,14 @@ import com.azure.storage.queue.models.StorageErrorException; import com.azure.storage.queue.models.StorageServiceProperties; import com.azure.storage.queue.models.StorageServiceStats; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; /** * This class provides a client that contains all the operations for interacting with a queue account in Azure Storage. @@ -153,6 +154,9 @@ public Mono deleteQueue(String queueName) { * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.listQueues} * + *

For more information, see the + * Azure Docs.

+ * * @return {@link QueueItem Queues} in the storage account */ public Flux listQueues() { @@ -171,6 +175,9 @@ public Flux listQueues() { * * {@codesnippet com.azure.storage.queue.queueServiceClient.listQueues#queueSergmentOptions} * + *

For more information, see the + * Azure Docs.

+ * * @param options Options for listing queues * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements */ @@ -240,6 +247,9 @@ private Flux extractAndFetchQueues(ServicesListQueuesSegmentResponse * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.getProperties} * + *

For more information, see the + * Azure Docs.

+ * * @return Storage account Queue service properties */ public Mono> getProperties() { @@ -264,6 +274,9 @@ public Mono> getProperties() { * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.setPropertiesEnableMetrics#storageServiceProperties} * + *

For more information, see the + * Azure Docs.

+ * * @param properties Storage account Queue service properties * @return A response that only contains headers and response status code * @throws StorageErrorException When one of the following is true @@ -292,6 +305,9 @@ public Mono setProperties(StorageServiceProperties properties) { * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.getStatistics} * + *

For more information, see the + * Azure Docs.

+ * * @return The geo replication information about the Queue service */ public Mono> getStatistics() { diff --git a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java index a002e5b12f87..78ef5b204281 100644 --- a/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java +++ b/storage/client/queue/src/main/java/com/azure/storage/queue/QueueServiceClient.java @@ -127,6 +127,9 @@ public VoidResponse deleteQueue(String queueName) { * * {@codesnippet com.azure.storage.queue.queueServiceClient.listQueues} * + *

For more information, see the + * Azure Docs.

+ * * @return {@link QueueItem Queues} in the storage account */ public Iterable listQueues() { @@ -145,6 +148,9 @@ public Iterable listQueues() { * * {@codesnippet com.azure.storage.queue.queueServiceClient.listQueues#queueSergmentOptions} * + *

For more information, see the + * Azure Docs.

+ * * @param options Options for listing queues * @return {@link QueueItem Queues} in the storage account that satisfy the filter requirements */ @@ -176,6 +182,9 @@ Iterable listQueues(String marker, QueuesSegmentOptions options) { * * {@codesnippet com.azure.storage.queue.queueServiceClient.getProperties} * + *

For more information, see the + * Azure Docs.

+ * * @return Storage account Queue service properties */ public Response getProperties() { @@ -199,6 +208,9 @@ public Response getProperties() { * * {@codesnippet com.azure.storage.queue.queueServiceClient.setPropertiesEnableMetrics#storageServiceProperties} * + *

For more information, see the + * Azure Docs.

+ * * @param properties Storage account Queue service properties * @return A response that only contains headers and response status code * @throws StorageErrorException When one of the following is true @@ -226,6 +238,9 @@ public VoidResponse setProperties(StorageServiceProperties properties) { * * {@codesnippet com.azure.storage.queue.queueServiceClient.getStatistics} * + *

For more information, see the + * Azure Docs.

+ * * @return The geo replication information about the Queue service */ public Response getStatistics() {