From a4293d730c6f7a602de678221901e22516141f3e Mon Sep 17 00:00:00 2001 From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com> Date: Mon, 15 Nov 2021 16:33:53 -0800 Subject: [PATCH] Transition Storage SDKs to New Codesnippet Tooling (#25346) Transition Storage SDKs to New Codesnippet Tooling --- .../azure/storage/blob/batch/BlobBatch.java | 74 +- .../blob/batch/BlobBatchAsyncClient.java | 60 +- .../storage/blob/batch/BlobBatchClient.java | 106 ++- .../blob/batch/BlobBatchClientBuilder.java | 12 +- .../storage/blob/batch/ReadmeSamples.java | 34 +- .../changefeed/BlobChangefeedAsyncClient.java | 26 +- .../blob/changefeed/BlobChangefeedClient.java | 45 +- .../BlobChangefeedClientBuilder.java | 12 +- .../blob/changefeed/ReadmeSamples.java | 14 +- .../EncryptedBlobAsyncClient.java | 130 ++- .../cryptography/EncryptedBlobClient.java | 74 +- .../EncryptedBlobClientBuilder.java | 20 +- .../cryptography/ReadmeSamples.java | 8 + sdk/storage/azure-storage-blob-nio/README.md | 1 - .../azure/storage/blob/nio/ReadmeSamples.java | 34 +- .../azure/storage/blob/BlobAsyncClient.java | 195 ++++- .../com/azure/storage/blob/BlobClient.java | 74 +- .../azure/storage/blob/BlobClientBuilder.java | 16 +- .../blob/BlobContainerAsyncClient.java | 309 +++++++- .../storage/blob/BlobContainerClient.java | 335 +++++++- .../blob/BlobContainerClientBuilder.java | 16 +- .../storage/blob/BlobServiceAsyncClient.java | 242 +++++- .../azure/storage/blob/BlobServiceClient.java | 240 +++++- .../specialized/AppendBlobAsyncClient.java | 119 ++- .../blob/specialized/AppendBlobClient.java | 132 +++- .../blob/specialized/BlobAsyncClientBase.java | 586 ++++++++++++-- .../blob/specialized/BlobClientBase.java | 572 ++++++++++++-- .../specialized/BlobLeaseAsyncClient.java | 165 +++- .../blob/specialized/BlobLeaseClient.java | 175 +++- .../specialized/BlobLeaseClientBuilder.java | 36 +- .../specialized/BlockBlobAsyncClient.java | 240 +++++- .../blob/specialized/BlockBlobClient.java | 248 +++++- .../blob/specialized/PageBlobAsyncClient.java | 352 ++++++++- .../blob/specialized/PageBlobClient.java | 369 ++++++++- .../SpecializedBlobClientBuilder.java | 9 +- .../com/azure/storage/blob/ReadmeSamples.java | 253 +++--- .../common/StorageSharedKeyCredential.java | 6 +- .../credentials/SasTokenCredential.java | 4 - .../DataLakeDirectoryAsyncClient.java | 154 +++- .../datalake/DataLakeDirectoryClient.java | 154 +++- .../datalake/DataLakeFileAsyncClient.java | 352 ++++++++- .../file/datalake/DataLakeFileClient.java | 321 +++++++- .../DataLakeFileSystemAsyncClient.java | 355 ++++++++- .../datalake/DataLakeFileSystemClient.java | 387 ++++++++- .../DataLakeFileSystemClientBuilder.java | 18 +- .../datalake/DataLakePathAsyncClient.java | 353 ++++++++- .../file/datalake/DataLakePathClient.java | 370 ++++++++- .../datalake/DataLakePathClientBuilder.java | 36 +- .../datalake/DataLakeServiceAsyncClient.java | 199 ++++- .../file/datalake/DataLakeServiceClient.java | 214 ++++- .../specialized/DataLakeLeaseAsyncClient.java | 106 ++- .../specialized/DataLakeLeaseClient.java | 111 ++- .../DataLakeLeaseClientBuilder.java | 54 +- .../storage/file/datalake/ReadmeSamples.java | 48 +- .../storage/file/share/ShareAsyncClient.java | 519 ++++++++++-- .../azure/storage/file/share/ShareClient.java | 452 +++++++++-- .../file/share/ShareClientBuilder.java | 58 +- .../file/share/ShareDirectoryAsyncClient.java | 389 ++++++++- .../file/share/ShareDirectoryClient.java | 349 +++++++- .../file/share/ShareFileAsyncClient.java | 747 ++++++++++++++++-- .../storage/file/share/ShareFileClient.java | 703 ++++++++++++++-- .../file/share/ShareFileClientBuilder.java | 64 +- .../file/share/ShareServiceAsyncClient.java | 221 +++++- .../file/share/ShareServiceClient.java | 200 ++++- .../file/share/ShareServiceClientBuilder.java | 54 +- .../specialized/ShareLeaseAsyncClient.java | 88 ++- .../share/specialized/ShareLeaseClient.java | 95 ++- .../specialized/ShareLeaseClientBuilder.java | 36 +- .../storage/file/share/ReadmeSamples.java | 163 ++-- .../azure/storage/queue/QueueAsyncClient.java | 374 ++++++++- .../com/azure/storage/queue/QueueClient.java | 291 ++++++- .../storage/queue/QueueClientBuilder.java | 119 ++- .../queue/QueueServiceAsyncClient.java | 182 ++++- .../storage/queue/QueueServiceClient.java | 174 +++- .../queue/QueueServiceClientBuilder.java | 117 ++- .../azure/storage/queue/ReadmeSamples.java | 109 ++- 76 files changed, 12634 insertions(+), 1445 deletions(-) diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatch.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatch.java index b32a9682d3db7..b659c5f79a7d1 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatch.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatch.java @@ -45,7 +45,17 @@ *
Azure Storage Blob batches are homogeneous which means a {@link #deleteBlob(String) delete} and {@link * #setBlobAccessTier(String, AccessTier) set tier} are not allowed to be in the same batch.
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.illegalBatchOperation} + * + *+ * try { + * Response<Void> deleteResponse = batch.deleteBlob("{url of blob}"); + * Response<Void> setTierResponse = batch.setBlobAccessTier("{url of another blob}", AccessTier.HOT); + * } catch (UnsupportedOperationException ex) { + * System.err.printf("This will fail as Azure Storage Blob batch operations are homogeneous. Exception: %s%n", + * ex.getMessage()); + * } + *+ * * *
Please refer to the Azure Docs * for more information.
@@ -109,7 +119,11 @@ public final class BlobBatch { * *Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String-String} + * + *+ * Response<Void> deleteResponse = batch.deleteBlob("{container name}", "{blob name}"); + *+ * * * @param containerName The container of the blob. * @param blobName The name of the blob. @@ -127,7 +141,14 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String-String-DeleteSnapshotsOptionType-BlobRequestConditions} + * + *+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId("{lease ID}"); + * + * Response<Void> deleteResponse = batch.deleteBlob("{container name}", "{blob name}", + * DeleteSnapshotsOptionType.INCLUDE, blobRequestConditions); + *+ * * * @param containerName The container of the blob. * @param blobName The name of the blob. @@ -148,7 +169,11 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String} + * + *+ * Response<Void> deleteResponse = batch.deleteBlob("{url of blob}"); + *+ * * * @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. * @return a {@link Response} that will be used to associate this operation to the response when the batch is @@ -164,7 +189,14 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.deleteBlob#String-DeleteSnapshotsOptionType-BlobRequestConditions} + * + *+ * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId("{lease ID}"); + * + * Response<Void> deleteResponse = batch.deleteBlob("{url of blob}", DeleteSnapshotsOptionType.INCLUDE, + * blobRequestConditions); + *+ * * * @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. * @param deleteOptions Delete options for the blob and its snapshots. @@ -190,7 +222,11 @@ private Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-String-AccessTier} + * + *+ * Response<Void> setTierResponse = batch.setBlobAccessTier("{container name}", "{blob name}", AccessTier.HOT); + *+ * * * @param containerName The container of the blob. * @param blobName The name of the blob. @@ -209,7 +245,12 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-String-AccessTier-String} + * + *+ * Response<Void> setTierResponse = batch.setBlobAccessTier("{container name}", "{blob name}", AccessTier.HOT, + * "{lease ID}"); + *+ * * * @param containerName The container of the blob. * @param blobName The name of the blob. @@ -230,7 +271,11 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-AccessTier} + * + *+ * Response<Void> setTierResponse = batch.setBlobAccessTier("{url of blob}", AccessTier.HOT); + *+ * * * @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. * @param accessTier The tier to set on the blob. @@ -247,7 +292,11 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#String-AccessTier-String} + * + *+ * Response<Void> setTierResponse = batch.setBlobAccessTier("{url of blob}", AccessTier.HOT, "{lease ID}"); + *+ * * * @param blobUrl URL of the blob. Blob name must be encoded to UTF-8. * @param accessTier The tier to set on the blob. @@ -265,7 +314,12 @@ public Response
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatch.setBlobAccessTier#BlobBatchSetBlobAccessTierOptions} + * + *+ * Response<Void> setTierResponse = batch.setBlobAccessTier( + * new BlobBatchSetBlobAccessTierOptions("{url of blob}", AccessTier.HOT).setLeaseId("{lease ID}")); + *+ * * * @param options {@link BlobBatchSetBlobAccessTierOptions} * @return a {@link Response} that will be used to associate this operation to the response when the batch is diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java index 4eb1a58594fd4..ae838eb9bd846 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchAsyncClient.java @@ -80,7 +80,21 @@ public BlobBatch getBlobBatch() { * *
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchAsyncClient.submitBatch#BlobBatch} + * + *+ * BlobBatch batch = batchAsyncClient.getBlobBatch(); + * + * Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1"); + * Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE, + * new BlobRequestConditions().setLeaseId("leaseId")); + * + * batchAsyncClient.submitBatch(batch).subscribe(response -> { + * System.out.println("Batch submission completed successfully."); + * System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode()); + * System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode()); + * }, error -> System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage())); + *+ * * * @param batch Batch to submit. * @return An empty response indicating that the batch operation has completed. @@ -104,7 +118,21 @@ public Mono
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchAsyncClient.submitBatch#BlobBatch-boolean} + * + *+ * BlobBatch batch = batchAsyncClient.getBlobBatch(); + * + * Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1"); + * Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE, + * new BlobRequestConditions().setLeaseId("leaseId")); + * + * batchAsyncClient.submitBatchWithResponse(batch, true).subscribe(response -> { + * System.out.printf("Batch submission completed with status code: %d%n", response.getStatusCode()); + * System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode()); + * System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode()); + * }, error -> System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage())); + *+ * * * @param batch Batch to submit. * @param throwOnAnyFailure Flag to indicate if an exception should be thrown if any request in the batch fails. @@ -146,7 +174,19 @@ Mono
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchAsyncClient.deleteBlobs#List-DeleteSnapshotsOptionType} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * batchAsyncClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE).subscribe(response -> + * System.out.printf("Deleting blob with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode()), + * error -> System.err.printf("Deleting blob failed with exception: %s%n", error.getMessage())); + *+ * * * @param blobUrls Urls of the blobs to delete. Blob names must be encoded to UTF-8. * @param deleteOptions The deletion option for all blobs. @@ -180,7 +220,19 @@ private Mono
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchAsyncClient.setBlobsAccessTier#List-AccessTier} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * batchAsyncClient.setBlobsAccessTier(blobUrls, AccessTier.HOT).subscribe(response -> + * System.out.printf("Setting blob access tier with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode()), + * error -> System.err.printf("Setting blob access tier failed with exception: %s%n", error.getMessage())); + *+ * * * @param blobUrls Urls of the blobs to set their access tier. Blob names must be encoded to UTF-8. * @param accessTier {@link AccessTier} to set on each blob. diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java index a5bb7e94f3ca0..1147f3420d02d 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClient.java @@ -49,7 +49,24 @@ public BlobBatch getBlobBatch() { * *
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.submitBatch#BlobBatch} + * + *+ * BlobBatch batch = batchClient.getBlobBatch(); + * + * Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1"); + * Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE, + * new BlobRequestConditions().setLeaseId("leaseId")); + * + * try { + * batchClient.submitBatch(batch); + * System.out.println("Batch submission completed successfully."); + * System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode()); + * System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode()); + * } catch (BlobStorageException error) { + * System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage()); + * } + *+ * * * @param batch Batch to submit. * @throws BlobStorageException If the batch request is malformed. @@ -68,7 +85,24 @@ public void submitBatch(BlobBatch batch) { * *
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.submitBatch#BlobBatch-boolean-Duration-Context} + * + *+ * BlobBatch batch = batchClient.getBlobBatch(); + * + * Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1"); + * Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE, + * new BlobRequestConditions().setLeaseId("leaseId")); + * + * try { + * System.out.printf("Batch submission completed with status code: %d%n", + * batchClient.submitBatchWithResponse(batch, true, timeout, Context.NONE).getStatusCode()); + * System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode()); + * System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode()); + * } catch (BlobStorageException error) { + * System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage()); + * } + *+ * * * @param batch Batch to submit. * @param throwOnAnyFailure Flag to indicate if an exception should be thrown if any request in the batch fails. @@ -93,7 +127,22 @@ public Response
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.deleteBlobs#List-DeleteSnapshotsOptionType} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * try { + * batchClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE).forEach(response -> + * System.out.printf("Deleting blob with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode())); + * } catch (Throwable error) { + * System.err.printf("Deleting blob failed with exception: %s%n", error.getMessage()); + * } + *+ * * * @param blobUrls Urls of the blobs to delete. Blob names must be encoded to UTF-8. * @param deleteOptions The deletion option for all blobs. @@ -111,7 +160,22 @@ public PagedIterable
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.deleteBlobs#List-DeleteSnapshotsOptionType-Duration-Context} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * try { + * batchClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE, timeout, Context.NONE) + * .forEach(response -> System.out.printf("Deleting blob with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode())); + * } catch (Throwable error) { + * System.err.printf("Deleting blob failed with exception: %s%n", error.getMessage()); + * } + *+ * * * @param blobUrls Urls of the blobs to delete. Blob names must be encoded to UTF-8. * @param deleteOptions The deletion option for all blobs. @@ -133,7 +197,22 @@ public PagedIterable
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.setBlobsAccessTier#List-AccessTier} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * try { + * batchClient.setBlobsAccessTier(blobUrls, AccessTier.HOT).forEach(response -> + * System.out.printf("Setting blob access tier with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode())); + * } catch (Throwable error) { + * System.err.printf("Setting blob access tier failed with exception: %s%n", error.getMessage()); + * } + *+ * * * @param blobUrls Urls of the blobs to set their access tier. Blob names must be encoded to UTF-8. * @param accessTier {@link AccessTier} to set on each blob. @@ -151,7 +230,22 @@ public PagedIterable
Code samples
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClient.setBlobsAccessTier#List-AccessTier-Duration-Context} + * + *+ * List<String> blobUrls = new ArrayList<>(); + * blobUrls.add(blobClient1.getBlobUrl()); + * blobUrls.add(blobClient2.getBlobUrl()); + * blobUrls.add(blobClient3.getBlobUrl()); + * + * try { + * batchClient.setBlobsAccessTier(blobUrls, AccessTier.HOT, timeout, Context.NONE).forEach(response -> + * System.out.printf("Setting blob access tier with URL %s completed with status code %d%n", + * response.getRequest().getUrl(), response.getStatusCode())); + * } catch (Throwable error) { + * System.err.printf("Setting blob access tier failed with exception: %s%n", error.getMessage()); + * } + *+ * * * @param blobUrls Urls of the blobs to set their access tier. Blob names must be encoded to UTF-8. * @param accessTier {@link AccessTier} to set on each blob. diff --git a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClientBuilder.java b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClientBuilder.java index 9e10599c1bdc5..511cea147a754 100644 --- a/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClientBuilder.java +++ b/sdk/storage/azure-storage-blob-batch/src/main/java/com/azure/storage/blob/batch/BlobBatchClientBuilder.java @@ -99,7 +99,11 @@ public BlobBatchClientBuilder(BlobContainerAsyncClient client) { * *
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClientBuilder#buildClient} + * + *+ * BlobBatchClient batchClient = new BlobBatchClientBuilder(blobServiceClient).buildClient(); + *+ * * * @return a {@link BlobBatchClient} created from the configurations in this builder. */ @@ -112,7 +116,11 @@ public BlobBatchClient buildClient() { * *
Code sample
* - * {@codesnippet com.azure.storage.blob.batch.BlobBatchClientBuilder#buildAsyncClient} + * + *+ * BlobBatchAsyncClient batchClient = new BlobBatchClientBuilder(blobServiceAsyncClient).buildAsyncClient(); + *+ * * * @return a {@link BlobBatchAsyncClient} created from the configurations in this builder. */ diff --git a/sdk/storage/azure-storage-blob-batch/src/samples/java/com/azure/storage/blob/batch/ReadmeSamples.java b/sdk/storage/azure-storage-blob-batch/src/samples/java/com/azure/storage/blob/batch/ReadmeSamples.java index 847b3fc54e476..f88eee9345a85 100644 --- a/sdk/storage/azure-storage-blob-batch/src/samples/java/com/azure/storage/blob/batch/ReadmeSamples.java +++ b/sdk/storage/azure-storage-blob-batch/src/samples/java/com/azure/storage/blob/batch/ReadmeSamples.java @@ -22,14 +22,22 @@ * * Code samples for the README.md */ +@SuppressWarnings("unused") public class ReadmeSamples { - private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint("
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedAsyncClient.getEvents} + * + *+ * client.getEvents().subscribe(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @return A reactive response emitting the changefeed events. */ @@ -60,7 +65,15 @@ public BlobChangefeedPagedFlux getEvents() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedAsyncClient.getEvents#OffsetDateTime-OffsetDateTime} + * + *+ * OffsetDateTime startTime = OffsetDateTime.MIN; + * OffsetDateTime endTime = OffsetDateTime.now(); + * + * client.getEvents(startTime, endTime).subscribe(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param startTime Filters the results to return events approximately after the start time. Note: A few events * belonging to the previous hour can also be returned. A few events belonging to this hour can be missing; to @@ -86,7 +99,14 @@ public BlobChangefeedPagedFlux getEvents(OffsetDateTime startTime, OffsetDateTim * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedAsyncClient.getEvents#String} + * + *+ * String cursor = "cursor"; + * + * client.getEvents(cursor).subscribe(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param cursor Identifies the portion of the events to be returned with the next get operation. Events that * take place after the event identified by the cursor will be returned. diff --git a/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClient.java b/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClient.java index 9e5042b76490b..03ef27fa92e64 100644 --- a/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClient.java +++ b/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClient.java @@ -42,7 +42,12 @@ public class BlobChangefeedClient { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClient.getEvents} + * + *+ * client.getEvents().forEach(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @return The changefeed events. */ @@ -64,7 +69,15 @@ public BlobChangefeedPagedIterable getEvents() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClient.getEvents#OffsetDateTime-OffsetDateTime} + * + *+ * OffsetDateTime startTime = OffsetDateTime.MIN; + * OffsetDateTime endTime = OffsetDateTime.now(); + * + * client.getEvents(startTime, endTime).forEach(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param startTime Filters the results to return events approximately after the start time. Note: A few events * belonging to the previous hour can also be returned. A few events belonging to this hour can be missing; to @@ -92,7 +105,15 @@ public BlobChangefeedPagedIterable getEvents(OffsetDateTime startTime, OffsetDat * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClient.getEvents#OffsetDateTime-OffsetDateTime-Context} + * + *+ * OffsetDateTime startTime = OffsetDateTime.MIN; + * OffsetDateTime endTime = OffsetDateTime.now(); + * + * client.getEvents(startTime, endTime, new Context("key", "value")).forEach(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param startTime Filters the results to return events approximately after the start time. Note: A few events * belonging to the previous hour can also be returned. A few events belonging to this hour can be missing; to @@ -121,7 +142,14 @@ public BlobChangefeedPagedIterable getEvents(OffsetDateTime startTime, OffsetDat * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClient.getEvents#String} + * + *+ * String cursor = "cursor"; + * + * client.getEvents(cursor).forEach(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param cursor Identifies the portion of the events to be returned with the next get operation. Events that * take place after the event identified by the cursor will be returned. @@ -145,7 +173,14 @@ public BlobChangefeedPagedIterable getEvents(String cursor) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClient.getEvents#String-Context} + * + *+ * String cursor = "cursor"; + * + * client.getEvents(cursor, new Context("key", "value")).forEach(event -> + * System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + *+ * * * @param cursor Identifies the portion of the events to be returned with the next get operation. Events that * take place after the event identified by the cursor will be returned. diff --git a/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClientBuilder.java b/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClientBuilder.java index dc6bd2913e977..356203bdb9179 100644 --- a/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClientBuilder.java +++ b/sdk/storage/azure-storage-blob-changefeed/src/main/java/com/azure/storage/blob/changefeed/BlobChangefeedClientBuilder.java @@ -70,7 +70,11 @@ public BlobChangefeedClientBuilder(BlobServiceAsyncClient client) { * *
Code sample
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClientBuilder#buildClient} + * + *+ * BlobChangefeedClient changefeedClient = new BlobChangefeedClientBuilder(blobServiceClient).buildClient(); + *+ * *F * @return a {@link BlobChangefeedClient} created from the configurations in this builder. */ @@ -83,7 +87,11 @@ public BlobChangefeedClient buildClient() { * *
Code sample
* - * {@codesnippet com.azure.storage.blob.changefeed.BlobChangefeedClientBuilder#buildAsyncClient} + * + *+ * BlobChangefeedAsyncClient changefeedClient = new BlobChangefeedClientBuilder(blobServiceAsyncClient).buildAsyncClient(); + *+ * * * @return a {@link BlobChangefeedAsyncClient} created from the configurations in this builder. */ diff --git a/sdk/storage/azure-storage-blob-changefeed/src/samples/java/com/azure/storage/blob/changefeed/ReadmeSamples.java b/sdk/storage/azure-storage-blob-changefeed/src/samples/java/com/azure/storage/blob/changefeed/ReadmeSamples.java index 8339e044f1ca5..0f321bbed9afe 100644 --- a/sdk/storage/azure-storage-blob-changefeed/src/samples/java/com/azure/storage/blob/changefeed/ReadmeSamples.java +++ b/sdk/storage/azure-storage-blob-changefeed/src/samples/java/com/azure/storage/blob/changefeed/ReadmeSamples.java @@ -19,27 +19,34 @@ */ public class ReadmeSamples { - private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().buildClient(); + private final BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().buildClient(); private BlobChangefeedClient client = new BlobChangefeedClientBuilder(blobServiceClient).buildClient(); public void getClient() { + // BEGIN: readme-sample-getClient client = new BlobChangefeedClientBuilder(blobServiceClient).buildClient(); + // END: readme-sample-getClient } public void changefeed() { + // BEGIN: readme-sample-changefeed client.getEvents().forEach(event -> System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + // END: readme-sample-changefeed } public void changefeedBetweenDates() { + // BEGIN: readme-sample-changefeedBetweenDates OffsetDateTime startTime = OffsetDateTime.MIN; OffsetDateTime endTime = OffsetDateTime.now(); client.getEvents(startTime, endTime).forEach(event -> System.out.printf("Topic: %s, Subject: %s%n", event.getTopic(), event.getSubject())); + // END: readme-sample-changefeedBetweenDates } public void changefeedResumeWithCursor() { + // BEGIN: readme-sample-changefeedResumeWithCursor BlobChangefeedPagedIterable iterable = client.getEvents(); Iterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.upload#Flux-ParallelTransferOptions} + * + *+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * client.upload(data, parallelTransferOptions).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -221,7 +230,17 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.upload#Flux-ParallelTransferOptions-boolean} + * + *+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * boolean overwrite = false; // Default behavior + * client.upload(data, parallelTransferOptions, overwrite).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -273,7 +292,26 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * + * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -319,7 +357,29 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * Map<String, String> tags = new HashMap<>(Collections.singletonMap("tag", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * + * client.uploadWithResponse(new BlobParallelUploadOptions(data) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata) + * .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions)) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected * to produce the same values across subscriptions. @@ -355,7 +415,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadFromFile#String} + * + *+ * client.uploadFromFile(filePath) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @return An empty response @@ -376,7 +442,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadFromFile#String-boolean} + * + *+ * boolean overwrite = false; // Default behavior + * client.uploadFromFile(filePath, overwrite) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @param overwrite Whether to overwrite should the blob exist. @@ -406,7 +479,26 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize); + * + * client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. @@ -436,7 +528,29 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobAsyncClient.uploadFromFileWithResponse#BlobUploadFromFileOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * Map<String, String> tags = new HashMap<>(Collections.singletonMap("tag", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize); + * + * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags) + * .setTier(AccessTier.HOT).setRequestConditions(requestConditions)) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param options {@link BlobUploadFromFileOptions} * @return A reactive response containing the information of the uploaded block blob. diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java index 3fcda9b9d04f8..f43a046ee714b 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClient.java @@ -182,7 +182,16 @@ public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClient.uploadFromFile#String} + * + *+ * try { + * client.uploadFromFile(filePath); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload */ @@ -197,7 +206,17 @@ public void uploadFromFile(String filePath) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClient.uploadFromFile#String-boolean} + * + *+ * try { + * boolean overwrite = false; // Default value + * client.uploadFromFile(filePath, overwrite); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload * @param overwrite Whether or not to overwrite should data already exist on the blob @@ -216,7 +235,29 @@ public void uploadFromFile(String filePath, boolean overwrite) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * long blockSize = 100 * 1024 * 1024; // 100 MB; + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); + * + * try { + * client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata, AccessTier.HOT, + * requestConditions, timeout); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel @@ -245,7 +286,32 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClient.uploadFromFileWithResponse#BlobUploadFromFileOptions-Duration-Context} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value")); + * Map<String, String> tags = new HashMap<>(Collections.singletonMap("tag", "value")); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * long blockSize = 100 * 1024 * 1024; // 100 MB; + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); + * + * try { + * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata) + * .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout, + * Context.NONE); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param options {@link BlobUploadFromFileOptions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java index b0c85973f27c4..9384f33b32694 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java @@ -139,7 +139,15 @@ public EncryptedBlobClientBuilder() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClientBuilder.buildEncryptedBlobAsyncClient} + * + *+ * EncryptedBlobAsyncClient client = new EncryptedBlobClientBuilder() + * .key(key, keyWrapAlgorithm) + * .keyResolver(keyResolver) + * .connectionString(connectionString) + * .buildEncryptedBlobAsyncClient(); + *+ * * * @return a {@link EncryptedBlobClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. @@ -154,7 +162,15 @@ public EncryptedBlobClient buildEncryptedBlobClient() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.cryptography.EncryptedBlobClientBuilder.buildEncryptedBlobClient} + * + *+ * EncryptedBlobClient client = new EncryptedBlobClientBuilder() + * .key(key, keyWrapAlgorithm) + * .keyResolver(keyResolver) + * .connectionString(connectionString) + * .buildEncryptedBlobClient(); + *+ * * * @return a {@link EncryptedBlobAsyncClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}. diff --git a/sdk/storage/azure-storage-blob-cryptography/src/samples/java/com/azure/storage/blob/specialized/cryptography/ReadmeSamples.java b/sdk/storage/azure-storage-blob-cryptography/src/samples/java/com/azure/storage/blob/specialized/cryptography/ReadmeSamples.java index 21a925b94634e..34e27d3f7eec6 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/samples/java/com/azure/storage/blob/specialized/cryptography/ReadmeSamples.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/samples/java/com/azure/storage/blob/specialized/cryptography/ReadmeSamples.java @@ -41,14 +41,17 @@ public class ReadmeSamples { private String keyName; public void getEncryptedBlobClientBlobClient() { + // BEGIN: readme-sample-getEncryptedBlobClientBlobClient EncryptedBlobClient client = new EncryptedBlobClientBuilder() .key(key, keyWrapAlgorithm) .keyResolver(keyResolver) .blobClient(blobClient) .buildEncryptedBlobClient(); + // END: readme-sample-getEncryptedBlobClientBlobClient } public void getEncryptedBlobClient() { + // BEGIN: readme-sample-getEncryptedBlobClient EncryptedBlobClient client = new EncryptedBlobClientBuilder() .key(key, keyWrapAlgorithm) .keyResolver(keyResolver) @@ -56,9 +59,11 @@ public void getEncryptedBlobClient() { .containerName(containerName) .blobName(blobName) .buildEncryptedBlobClient(); + // END: readme-sample-getEncryptedBlobClient } public void getClientLocalKey() { + // BEGIN: readme-sample-getClientLocalKey JsonWebKey localKey = JsonWebKey.fromAes(new SecretKeySpec(keyBytes, secretKeyAlgorithm), Arrays.asList(KeyOperation.WRAP_KEY, KeyOperation.UNWRAP_KEY)) .setId("my-id"); @@ -71,9 +76,11 @@ public void getClientLocalKey() { .containerName(containerName) .blobName(blobName) .buildEncryptedBlobClient(); + // END: readme-sample-getClientLocalKey } public void getClientKeyVaultKey() { + // BEGIN: readme-sample-getClientKeyVaultKey KeyClient keyClient = new KeyClientBuilder() .vaultUrl(keyVaultUrl) .credential(tokenCredential) @@ -92,6 +99,7 @@ public void getClientKeyVaultKey() { .containerName(containerName) .blobName(blobName) .buildEncryptedBlobClient(); + // END: readme-sample-getClientKeyVaultKey } } diff --git a/sdk/storage/azure-storage-blob-nio/README.md b/sdk/storage/azure-storage-blob-nio/README.md index 0b31dbbd6d580..ffb95d920675d 100644 --- a/sdk/storage/azure-storage-blob-nio/README.md +++ b/sdk/storage/azure-storage-blob-nio/README.md @@ -194,7 +194,6 @@ to guarantee that the data is available to be read. try (OutputStream os = Files.newOutputStream(filePath)) { os.write(0); } -``` ### Copy a file diff --git a/sdk/storage/azure-storage-blob-nio/src/samples/java/com/azure/storage/blob/nio/ReadmeSamples.java b/sdk/storage/azure-storage-blob-nio/src/samples/java/com/azure/storage/blob/nio/ReadmeSamples.java index 8b84599807942..b3732ae9d585f 100644 --- a/sdk/storage/azure-storage-blob-nio/src/samples/java/com/azure/storage/blob/nio/ReadmeSamples.java +++ b/sdk/storage/azure-storage-blob-nio/src/samples/java/com/azure/storage/blob/nio/ReadmeSamples.java @@ -37,62 +37,84 @@ public ReadmeSamples() throws URISyntaxException, IOException { } public void createAFileSystem() throws URISyntaxException, IOException { + // BEGIN: readme-sample-createAFileSystem Map
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions} + * + *+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * client.upload(data, parallelTransferOptions).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -351,7 +360,17 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#Flux-ParallelTransferOptions-boolean} + * + *+ * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * boolean overwrite = false; // Default behavior + * client.upload(data, parallelTransferOptions, overwrite).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -391,7 +410,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#BinaryData} + * + *+ * client.upload(BinaryData.fromString("Data!")).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. * @return A reactive response containing the information of the uploaded block blob. @@ -410,7 +435,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.upload#BinaryData-boolean} + * + *+ * boolean overwrite = false; // Default behavior + * client.upload(BinaryData.fromString("Data!"), overwrite).subscribe(response -> + * System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getContentMd5()))); + *+ * * * @param data The data to write to the blob. * @param overwrite Whether or not to overwrite, should the blob already exist. @@ -467,11 +499,52 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency); + * + * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * *
Using Progress Reporting
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#Flux-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions.ProgressReporter} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions() + * .setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency) + * .setProgressReceiver(bytesTransferred -> System.out.printf("Upload progress: %s bytes sent", bytesTransferred)); + * + * client.uploadWithResponse(data, parallelTransferOptions, headers, metadata, AccessTier.HOT, requestConditions) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * * @param data The data to write to the blob. Unlike other upload methods, this method does not require that the * {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not expected @@ -519,11 +592,57 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency).setProgressReceiver(bytesTransferred -> + * System.out.printf("Upload progress: %s bytes sent", bytesTransferred)); + * + * client.uploadWithResponse(new BlobParallelUploadOptions(data) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags) + * .setTier(AccessTier.HOT).setRequestConditions(requestConditions)) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * *
Using Progress Reporting
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadWithResponse#BlobParallelUploadOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize) + * .setMaxConcurrency(maxConcurrency).setProgressReceiver(bytesTransferred -> + * System.out.printf("Upload progress: %s bytes sent", bytesTransferred)); + * + * client.uploadWithResponse(new BlobParallelUploadOptions(data) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata).setTags(tags) + * .setTier(AccessTier.HOT).setRequestConditions(requestConditions)) + * .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", + * Base64.getEncoder().encodeToString(response.getValue().getContentMd5()))); + *+ * * * @param options {@link BlobParallelUploadOptions}. Unlike other upload methods, this method does not require that * the {@code Flux} be replayable. In other words, it does not have to support multiple subscribers and is not @@ -689,7 +808,13 @@ private Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String} + * + *+ * client.uploadFromFile(filePath) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @return An empty response @@ -710,7 +835,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-boolean} + * + *+ * boolean overwrite = false; // Default behavior + * client.uploadFromFile(filePath, overwrite) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @param overwrite Whether or not to overwrite, should the blob already exist. @@ -749,7 +881,25 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.uploadFromFile(filePath, + * new ParallelTransferOptions().setBlockSizeLong(BlockBlobClient.MAX_STAGE_BLOCK_BYTES_LONG), + * headers, metadata, AccessTier.HOT, requestConditions) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param filePath Path to the upload file * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel @@ -780,7 +930,28 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.uploadFromFileWithResponse#BlobUploadFromFileOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) + * .setParallelTransferOptions( + * new ParallelTransferOptions().setBlockSizeLong(BlobAsyncClient.BLOB_MAX_UPLOAD_BLOCK_SIZE)) + * .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) + * .setRequestConditions(requestConditions)) + * .doOnError(throwable -> System.err.printf("Failed to upload from file %s%n", throwable.getMessage())) + * .subscribe(completion -> System.out.println("Upload from file succeeded")); + *+ * * * @param options {@link BlobUploadFromFileOptions} * @return A reactive response containing the information of the uploaded block blob. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java index 7a2557fc15429..b2f93561ece2b 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClient.java @@ -311,7 +311,16 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String} + * + *+ * try { + * client.uploadFromFile(filePath); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload * @throws UncheckedIOException If an I/O error occurs @@ -326,7 +335,17 @@ public void uploadFromFile(String filePath) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String-boolean} + * + *+ * try { + * boolean overwrite = false; + * client.uploadFromFile(filePath, overwrite); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload * @param overwrite Whether or not to overwrite, should the blob already exist @@ -354,7 +373,29 @@ public void uploadFromFile(String filePath, boolean overwrite) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFile#String-ParallelTransferOptions-BlobHttpHeaders-Map-AccessTier-BlobRequestConditions-Duration} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Long blockSize = 100L * 1024L * 1024L; // 100 MB; + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); + * + * try { + * client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata, + * AccessTier.HOT, requestConditions, timeout); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param filePath Path of the file to upload * @param parallelTransferOptions {@link ParallelTransferOptions} to use to upload from file. Number of parallel @@ -383,7 +424,32 @@ public void uploadFromFile(String filePath, ParallelTransferOptions parallelTran * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClient.uploadFromFileWithResponse#BlobUploadFromFileOptions-Duration-Context} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentMd5("data".getBytes(StandardCharsets.UTF_8)) + * .setContentLanguage("en-US") + * .setContentType("binary"); + * + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Long blockSize = 100 * 1024 * 1024L; // 100 MB; + * ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize); + * + * try { + * client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath) + * .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata) + * .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout, + * new Context(key2, value2)); + * System.out.println("Upload from file succeeded"); + * } catch (UncheckedIOException ex) { + * System.err.printf("Failed to upload from file %s%n", ex.getMessage()); + * } + *+ * * * @param options {@link BlobUploadFromFileOptions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java index 080e821a0afe6..21d35eaa40af0 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java @@ -92,7 +92,13 @@ public BlobClientBuilder() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClientBuilder.buildClient} + * + *+ * BlobClient client = new BlobClientBuilder() + * .connectionString(connectionString) + * .buildClient(); + *+ * * * @return a {@link BlobClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}. @@ -109,7 +115,13 @@ public BlobClient buildClient() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobClientBuilder.buildAsyncClient} + * + *+ * BlobAsyncClient client = new BlobClientBuilder() + * .connectionString(connectionString) + * .buildAsyncClient(); + *+ * * * @return a {@link BlobAsyncClient} created from the configurations in this builder. * @throws NullPointerException If {@code endpoint} or {@code blobName} is {@code null}. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java index 99e495de8aea8..c1308265e74e6 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerAsyncClient.java @@ -144,7 +144,11 @@ public final class BlobContainerAsyncClient { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String} + * + *+ * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName); + *+ * * * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, * pass in the url encoded version of the blob name. @@ -160,7 +164,11 @@ public BlobAsyncClient getBlobAsyncClient(String blobName) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobAsyncClient#String-String} + * + *+ * BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName, snapshot); + *+ * * * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, * pass in the url encoded version of the blob name. @@ -209,7 +217,12 @@ public String getBlobContainerUrl() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getBlobContainerName} + * + *+ * String containerName = client.getBlobContainerName(); + * System.out.println("The name of the blob is " + containerName); + *+ * * * @return The name of container. */ @@ -292,7 +305,11 @@ public String getEncryptionScope() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.exists} + * + *+ * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); + *+ * * * @return true if the container exists, false if it doesn't */ @@ -310,7 +327,11 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.existsWithResponse} + * + *+ * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); + *+ * * * @return true if the container exists, false if it doesn't */ @@ -346,7 +367,13 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.create} + * + *+ * client.create().subscribe( + * response -> System.out.printf("Create completed%n"), + * error -> System.out.printf("Error while creating container %s%n", error)); + *+ * * * @return A reactive response signalling completion. */ @@ -366,7 +393,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.createWithResponse#Map-PublicAccessType} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> + * System.out.printf("Create completed with status %d%n", response.getStatusCode())); + *+ * * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. @@ -399,7 +432,13 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.delete} + * + *+ * client.delete().subscribe( + * response -> System.out.printf("Delete completed%n"), + * error -> System.out.printf("Delete failed: %s%n", error)); + *+ * * * @return A reactive response signalling completion. */ @@ -419,7 +458,16 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.deleteWithResponse#BlobRequestConditions} + * + *+ * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.deleteWithResponse(requestConditions).subscribe(response -> + * System.out.printf("Delete completed with status %d%n", response.getStatusCode())); + *+ * * * @param requestConditions {@link BlobRequestConditions} * @return A reactive response signalling completion. @@ -459,7 +507,15 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getProperties} + * + *+ * client.getProperties().subscribe(response -> + * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", + * response.getBlobPublicAccess(), + * response.hasLegalHold(), + * response.hasImmutabilityPolicy())); + *+ * * * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the * container properties. @@ -479,7 +535,15 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getPropertiesWithResponse#String} + * + *+ * client.getPropertiesWithResponse(leaseId).subscribe(response -> + * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", + * response.getValue().getBlobPublicAccess(), + * response.getValue().hasLegalHold(), + * response.getValue().hasImmutabilityPolicy())); + *+ * * * @param leaseId The lease ID the active lease on the container must match. * @return A reactive response containing the container properties. @@ -516,7 +580,14 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setMetadata#Map} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * client.setMetadata(metadata).subscribe( + * response -> System.out.printf("Set metadata completed%n"), + * error -> System.out.printf("Set metadata failed: %s%n", error)); + *+ * * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. @@ -538,7 +609,17 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setMetadataWithResponse#Map-BlobRequestConditions} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.setMetadataWithResponse(metadata, requestConditions).subscribe(response -> + * System.out.printf("Set metadata completed with status %d%n", response.getStatusCode())); + *+ * * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. @@ -582,7 +663,19 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicy} + * + *+ * client.getAccessPolicy().subscribe(response -> { + * System.out.printf("Blob Access Type: %s%n", response.getBlobAccessType()); + * + * for (BlobSignedIdentifier identifier : response.getIdentifiers()) { + * System.out.printf("Identifier Name: %s, Permissions %s%n", + * identifier.getId(), + * identifier.getAccessPolicy().getPermissions()); + * } + * }); + *+ * * * @return A reactive response containing the container access policy. */ @@ -602,7 +695,19 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccessPolicyWithResponse#String} + * + *+ * client.getAccessPolicyWithResponse(leaseId).subscribe(response -> { + * System.out.printf("Blob Access Type: %s%n", response.getValue().getBlobAccessType()); + * + * for (BlobSignedIdentifier identifier : response.getValue().getIdentifiers()) { + * System.out.printf("Identifier Name: %s, Permissions %s%n", + * identifier.getId(), + * identifier.getAccessPolicy().getPermissions()); + * } + * }); + *+ * * * @param leaseId The lease ID the active lease on the container must match. * @return A reactive response containing the container access policy. @@ -634,7 +739,20 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.setAccessPolicy#PublicAccessType-List} + * + *+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier() + * .setId("name") + * .setAccessPolicy(new BlobAccessPolicy() + * .setStartsOn(OffsetDateTime.now()) + * .setExpiresOn(OffsetDateTime.now().plusDays(7)) + * .setPermissions("permissionString")); + * + * client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe( + * response -> System.out.printf("Set access policy completed%n"), + * error -> System.out.printf("Set access policy failed: %s%n", error)); + *+ * * * @param accessType Specifies how the data in this container is available to the public. See the * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. @@ -661,7 +779,24 @@ public Mono
+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier() + * .setId("name") + * .setAccessPolicy(new BlobAccessPolicy() + * .setStartsOn(OffsetDateTime.now()) + * .setExpiresOn(OffsetDateTime.now().plusDays(7)) + * .setPermissions("permissionString")); + * + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions) + * .subscribe(response -> + * System.out.printf("Set access policy completed with status %d%n", response.getStatusCode())); + *+ * * * @param accessType Specifies how the data in this container is available to the public. See the * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. @@ -744,7 +879,12 @@ OffsetDateTime.now will only give back milliseconds (more precise fields are zer * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobs} + * + *+ * client.listBlobs().subscribe(blob -> + * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); + *+ * * * @return A reactive response emitting the flattened blobs. */ @@ -777,7 +917,22 @@ public PagedFlux
+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("prefixToMatch") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * client.listBlobs(options).subscribe(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param options {@link ListBlobsOptions} * @return A reactive response emitting the listed blobs, flattened. @@ -811,7 +966,24 @@ public PagedFlux
+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("prefixToMatch") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * String continuationToken = "continuationToken"; + * + * client.listBlobs(options, continuationToken).subscribe(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param options {@link ListBlobsOptions} * @param continuationToken Identifies the portion of the list to be returned with the next list operation. @@ -928,7 +1100,12 @@ private Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String} + * + *+ * client.listBlobsByHierarchy("directoryName").subscribe(blob -> + * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isDeleted())); + *+ * * * @param directory The directory to list blobs underneath * @return A reactive response emitting the prefixes and blobs. @@ -968,7 +1145,22 @@ public PagedFlux
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.listBlobsByHierarchy#String-ListBlobsOptions} + * + *+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("directoryName") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * client.listBlobsByHierarchy("/", options).subscribe(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories * @param options {@link ListBlobsOptions} @@ -1061,7 +1253,14 @@ private Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfo} + * + *+ * client.getAccountInfo().subscribe(response -> + * System.out.printf("Account Kind: %s, SKU: %s%n", + * response.getAccountKind(), + * response.getSkuName())); + *+ * * * @return A reactive response containing the account info. */ @@ -1080,7 +1279,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.getAccountInfoWithResponse} + * + *+ * client.getAccountInfoWithResponse().subscribe(response -> + * System.out.printf("Account Kind: %s, SKU: %s%n", + * response.getValue().getAccountKind(), + * response.getValue().getSkuName())); + *+ * * * @return A reactive response containing the account info. */ @@ -1108,7 +1314,8 @@ Mono
Code Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.rename#String} +// * +// * // * // * @param destinationContainerName The new name of the container. // * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the renamed container. @@ -1123,7 +1330,8 @@ MonoCode Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.renameWithResponse#BlobContainerRenameOptions} +// * +// * // * // * @param options {@link BlobContainerRenameOptions} // * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a @@ -1171,7 +1379,17 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * + *+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateUserDelegationSas(values, userDelegationKey); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. @@ -1192,7 +1410,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context} + * + *+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value")); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. @@ -1216,7 +1444,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues} + * + *+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @@ -1233,7 +1471,18 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerAsyncClient.generateSas#BlobServiceSasSignatureValues-Context} + * + *+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * // Client must be authenticated via StorageSharedKeyCredential + * client.generateSas(values, new Context("key", "value")); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param context Additional context that is passed through the code when generating a SAS. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java index 2c6bf6ab69297..7a313b20c6759 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClient.java @@ -74,7 +74,11 @@ public final class BlobContainerClient { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobClient#String} + * + *+ * BlobClient blobClient = client.getBlobClient(blobName); + *+ * * @return A new {@link BlobClient} object which references the blob with the specified name in this container. */ public BlobClient getBlobClient(String blobName) { @@ -87,7 +91,11 @@ public BlobClient getBlobClient(String blobName) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobClient#String-String} + * + *+ * BlobClient blobClient = client.getBlobClient(blobName, snapshot); + *+ * * * @param blobName A {@code String} representing the name of the blob. If the blob name contains special characters, * pass in the url encoded version of the blob name. @@ -116,7 +124,12 @@ public BlobClient getBlobVersionClient(String blobName, String versionId) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getBlobContainerName} + * + *+ * String containerName = client.getBlobContainerName(); + * System.out.println("The name of the blob is " + containerName); + *+ * * * @return The name of container. */ @@ -202,7 +215,11 @@ public String getEncryptionScope() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.exists} + * + *+ * System.out.printf("Exists? %b%n", client.exists()); + *+ * * * @return true if the container exists, false if it doesn't */ @@ -215,7 +232,12 @@ public boolean exists() { * Gets if the container this client represents exists in the cloud. *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.existsWithResponse#Duration-Context} + * + *+ * Context context = new Context("Key", "Value"); + * System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue()); + *+ * * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -235,7 +257,18 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.create} + * + *+ * try { + * client.create(); + * System.out.printf("Create completed%n"); + * } catch (BlobStorageException error) { + * if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) { + * System.out.printf("Can't create container. It already exists %n"); + * } + * } + *+ * */ @ServiceMethod(returns = ReturnType.SINGLE) public void create() { @@ -249,7 +282,15 @@ public void create() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.createWithResponse#Map-PublicAccessType-Duration-Context} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Context context = new Context("Key", "Value"); + * + * System.out.printf("Create completed with status %d%n", + * client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).getStatusCode()); + *+ * * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. @@ -273,7 +314,18 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.delete} + * + *+ * try { + * client.delete(); + * System.out.printf("Delete completed%n"); + * } catch (BlobStorageException error) { + * if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_NOT_FOUND)) { + * System.out.printf("Delete failed. Container was not found %n"); + * } + * } + *+ * */ @ServiceMethod(returns = ReturnType.SINGLE) public void delete() { @@ -287,7 +339,17 @@ public void delete() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.deleteWithResponse#BlobRequestConditions-Duration-Context} + * + *+ * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Context context = new Context("Key", "Value"); + * + * System.out.printf("Delete completed with status %d%n", client.deleteWithResponse( + * requestConditions, timeout, context).getStatusCode()); + *+ * * * @param requestConditions {@link BlobRequestConditions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -308,7 +370,15 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getProperties} + * + *+ * BlobContainerProperties properties = client.getProperties(); + * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", + * properties.getBlobPublicAccess(), + * properties.hasLegalHold(), + * properties.hasImmutabilityPolicy()); + *+ * * * @return The container properties. */ @@ -323,7 +393,18 @@ public BlobContainerProperties getProperties() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getPropertiesWithResponse#String-Duration-Context} + * + *+ * Context context = new Context("Key", "Value"); + * + * BlobContainerProperties properties = client.getPropertiesWithResponse(leaseId, timeout, context) + * .getValue(); + * System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", + * properties.getBlobPublicAccess(), + * properties.hasLegalHold(), + * properties.hasImmutabilityPolicy()); + *+ * * * @param leaseId The lease ID the active lease on the container must match. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -342,7 +423,17 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.setMetadata#Map} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * try { + * client.setMetadata(metadata); + * System.out.printf("Set metadata completed with status %n"); + * } catch (UnsupportedOperationException error) { + * System.out.printf("Fail while setting metadata %n"); + * } + *+ * * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. @@ -358,7 +449,18 @@ public void setMetadata(Map
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.setMetadataWithResponse#Map-BlobRequestConditions-Duration-Context} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Context context = new Context("Key", "Value"); + * + * System.out.printf("Set metadata completed with status %d%n", + * client.setMetadataWithResponse(metadata, requestConditions, timeout, context).getStatusCode()); + *+ * * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any * metadata key or value, it must be removed or encoded. * @param requestConditions {@link BlobRequestConditions} @@ -381,7 +483,18 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccessPolicy} + * + *+ * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicy(); + * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType()); + * + * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) { + * System.out.printf("Identifier Name: %s, Permissions %s%n", + * identifier.getId(), + * identifier.getAccessPolicy().getPermissions()); + * } + *+ * * * @return The container access policy. */ @@ -397,7 +510,20 @@ public BlobContainerAccessPolicies getAccessPolicy() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccessPolicyWithResponse#String-Duration-Context} + * + *+ * Context context = new Context("Key", "Value"); + * BlobContainerAccessPolicies accessPolicies = client.getAccessPolicyWithResponse(leaseId, timeout, context) + * .getValue(); + * System.out.printf("Blob Access Type: %s%n", accessPolicies.getBlobAccessType()); + * + * for (BlobSignedIdentifier identifier : accessPolicies.getIdentifiers()) { + * System.out.printf("Identifier Name: %s, Permissions %s%n", + * identifier.getId(), + * identifier.getAccessPolicy().getPermissions()); + * } + *+ * * * @param leaseId The lease ID the active lease on the container must match. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -418,7 +544,23 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.setAccessPolicy#PublicAccessType-List} + * + *+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier() + * .setId("name") + * .setAccessPolicy(new BlobAccessPolicy() + * .setStartsOn(OffsetDateTime.now()) + * .setExpiresOn(OffsetDateTime.now().plusDays(7)) + * .setPermissions("permissionString")); + * + * try { + * client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)); + * System.out.printf("Set Access Policy completed %n"); + * } catch (UnsupportedOperationException error) { + * System.out.printf("Set Access Policy completed %s%n", error); + * } + *+ * * * @param accessType Specifies how the data in this container is available to the public. See the * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. @@ -441,7 +583,29 @@ public void setAccessPolicy(PublicAccessType accessType, * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.setAccessPolicyWithResponse#PublicAccessType-List-BlobRequestConditions-Duration-Context} + * + *+ * BlobSignedIdentifier identifier = new BlobSignedIdentifier() + * .setId("name") + * .setAccessPolicy(new BlobAccessPolicy() + * .setStartsOn(OffsetDateTime.now()) + * .setExpiresOn(OffsetDateTime.now().plusDays(7)) + * .setPermissions("permissionString")); + * + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * Context context = new Context("Key", "Value"); + * + * System.out.printf("Set access policy completed with status %d%n", + * client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, + * Collections.singletonList(identifier), + * requestConditions, + * timeout, + * context).getStatusCode()); + *+ * * * @param accessType Specifies how the data in this container is available to the public. See the * x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access. @@ -477,7 +641,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs} + * + *+ * client.listBlobs().forEach(blob -> + * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); + *+ * * * @return The listed blobs, flattened. */ @@ -499,7 +668,22 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-Duration} + * + *+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("prefixToMatch") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * client.listBlobs(options, timeout).forEach(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. @@ -524,7 +708,24 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobs#ListBlobsOptions-String-Duration} + * + *+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("prefixToMatch") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * String continuationToken = "continuationToken"; + * + * client.listBlobs(options, continuationToken, timeout).forEach(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. @@ -563,7 +764,12 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String} + * + *+ * client.listBlobsByHierarchy("directoryName").forEach(blob -> + * System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix())); + *+ * * * @param directory The directory to list blobs underneath * @return A reactive response emitting the prefixes and blobs. @@ -599,7 +805,22 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.listBlobsByHierarchy#String-ListBlobsOptions-Duration} + * + *+ * ListBlobsOptions options = new ListBlobsOptions() + * .setPrefix("directoryName") + * .setDetails(new BlobListDetails() + * .setRetrieveDeletedBlobs(true) + * .setRetrieveSnapshots(true)); + * + * client.listBlobsByHierarchy("/", options, timeout).forEach(blob -> + * System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", + * blob.getName(), + * blob.isPrefix(), + * blob.isDeleted(), + * blob.getSnapshot())); + *+ * * * @param delimiter The delimiter for blob hierarchy, "/" for hierarchy based on directories * @param options {@link ListBlobsOptions}. If iterating by page, the page size passed to byPage methods such as @@ -621,7 +842,12 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccountInfo#Duration} + * + *+ * StorageAccountInfo accountInfo = client.getAccountInfo(timeout); + * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); + *+ * * @return The account info. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -635,7 +861,13 @@ public StorageAccountInfo getAccountInfo(Duration timeout) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.getAccountInfoWithResponse#Duration-Context} + * + *+ * Context context = new Context("Key", "Value"); + * StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, context).getValue(); + * System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); + *+ * * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -653,7 +885,8 @@ public Response
Code Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobContainerClient.rename#String} +// * +// * // * // * @param destinationContainerName The new name of the container. // * @return A {@link BlobContainerClient} used to interact with the renamed container. @@ -669,7 +902,8 @@ public ResponseCode Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobContainerClient.renameWithResponse#BlobContainerRenameOptions-Duration-Context} +// * +// * // * // * @param options {@link BlobContainerRenameOptions} // * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -692,7 +926,17 @@ public ResponseCode Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey} + * + *+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateUserDelegationSas(values, userDelegationKey); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. @@ -712,7 +956,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateUserDelegationSas#BlobServiceSasSignatureValues-UserDelegationKey-String-Context} + * + *+ * OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value")); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param userDelegationKey A {@link UserDelegationKey} object used to sign the SAS values. @@ -736,7 +990,17 @@ public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServic * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues} + * + *+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @@ -753,7 +1017,18 @@ public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureV * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClient.generateSas#BlobServiceSasSignatureValues-Context} + * + *+ * OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); + * BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true); + * + * BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission) + * .setStartTime(OffsetDateTime.now()); + * + * // Client must be authenticated via StorageSharedKeyCredential + * client.generateSas(values, new Context("key", "value")); + *+ * * * @param blobServiceSasSignatureValues {@link BlobServiceSasSignatureValues} * @param context Additional context that is passed through the code when generating a SAS. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java index 1c7932727ad40..0db7b13389101 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java @@ -88,7 +88,13 @@ public BlobContainerClientBuilder() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClientBuilder.buildClient} + * + *+ * BlobContainerClient client = new BlobContainerClientBuilder() + * .connectionString(connectionString) + * .buildClient(); + *+ * * * @return a {@link BlobContainerClient} created from the configurations in this builder. * @throws IllegalStateException If multiple credentials have been specified. @@ -102,7 +108,13 @@ public BlobContainerClient buildClient() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobContainerClientBuilder.buildAsyncClient} + * + *+ * BlobContainerAsyncClient client = new BlobContainerClientBuilder() + * .connectionString(connectionString) + * .buildAsyncClient(); + *+ * * * @return a {@link BlobContainerAsyncClient} created from the configurations in this builder. * @throws IllegalStateException If multiple credentials have been specified. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java index 747fc45172762..a6951e7c416c2 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceAsyncClient.java @@ -141,7 +141,11 @@ public final class BlobServiceAsyncClient { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getBlobContainerAsyncClient#String} + * + *+ * BlobContainerAsyncClient blobContainerAsyncClient = client.getBlobContainerAsyncClient("containerName"); + *+ * * * @param containerName The name of the container to point to. A value of null or empty string will be interpreted * as pointing to the root container and will be replaced by "$root". @@ -181,7 +185,12 @@ public BlobServiceVersion getServiceVersion() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainer#String} + * + *+ * BlobContainerAsyncClient blobContainerAsyncClient = + * client.createBlobContainer("containerName").block(); + *+ * * * @param containerName Name of the container to create * @return A {@link Mono} containing a {@link BlobContainerAsyncClient} used to interact with the container created. @@ -202,7 +211,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.createBlobContainerWithResponse#String-Map-PublicAccessType} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * + * BlobContainerAsyncClient containerClient = client + * .createBlobContainerWithResponse("containerName", metadata, PublicAccessType.CONTAINER).block().getValue(); + *+ * * * @param containerName Name of the container to create * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any @@ -238,7 +254,13 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainer#String} + * + *+ * client.deleteBlobContainer("containerName").subscribe( + * response -> System.out.printf("Delete container completed%n"), + * error -> System.out.printf("Delete container failed: %s%n", error)); + *+ * * * @param containerName Name of the container to delete * @return A {@link Mono} containing containing status code and HTTP headers @@ -259,7 +281,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.deleteBlobContainerWithResponse#String-Context} + * + *+ * Context context = new Context("Key", "Value"); + * client.deleteBlobContainerWithResponse("containerName").subscribe(response -> + * System.out.printf("Delete container completed with status %d%n", response.getStatusCode())); + *+ * * * @param containerName Name of the container to delete * @return A {@link Mono} containing containing status code and HTTP headers @@ -293,7 +321,11 @@ public String getAccountUrl() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers} + * + *+ * client.listBlobContainers().subscribe(container -> System.out.printf("Name: %s%n", container.getName())); + *+ * * * @return A reactive response emitting the list of containers. */ @@ -312,7 +344,15 @@ public PagedFlux
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.listBlobContainers#ListBlobContainersOptions} + * + *+ * ListBlobContainersOptions options = new ListBlobContainersOptions() + * .setPrefix("containerNamePrefixToMatch") + * .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)); + * + * client.listBlobContainers(options).subscribe(container -> System.out.printf("Name: %s%n", container.getName())); + *+ * * * @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service. * @return A reactive response emitting the list of containers. @@ -367,7 +407,11 @@ private Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.findBlobsByTag#String} + * + *+ * client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); + *+ * * * @param query Filters the results to return only blobs whose tags match the specified expression. * @return A reactive response emitting the list of blobs. @@ -383,7 +427,12 @@ public PagedFlux
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncServiceClient.findBlobsByTag#FindBlobsOptions} + * + *+ * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10)) + * .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName())); + *+ * * * @param options {@link FindBlobsOptions} * @return A reactive response emitting the list of blobs. @@ -479,7 +528,14 @@ private List
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getProperties} + * + *+ * client.getProperties().subscribe(response -> + * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", + * response.getHourMetrics().isEnabled(), + * response.getMinuteMetrics().isEnabled())); + *+ * * * @return A reactive response containing the storage account properties. */ @@ -498,7 +554,14 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getPropertiesWithResponse} + * + *+ * client.getPropertiesWithResponse().subscribe(response -> + * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", + * response.getValue().getHourMetrics().isEnabled(), + * response.getValue().getMinuteMetrics().isEnabled())); + *+ * * * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the storage * account properties. @@ -530,7 +593,28 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.setProperties#BlobServiceProperties} + * + *+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); + * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); + * + * BlobServiceProperties properties = new BlobServiceProperties() + * .setLogging(new BlobAnalyticsLogging() + * .setWrite(true) + * .setDelete(true) + * .setRetentionPolicy(loggingRetentionPolicy)) + * .setHourMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)) + * .setMinuteMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)); + * + * client.setProperties(properties).subscribe( + * response -> System.out.printf("Setting properties completed%n"), + * error -> System.out.printf("Setting properties failed: %s%n", error)); + *+ * * * @param properties Configures the service. * @return A {@link Mono} containing the storage account properties. @@ -553,7 +637,27 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.setPropertiesWithResponse#BlobServiceProperties} + * + *+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); + * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); + * + * BlobServiceProperties properties = new BlobServiceProperties() + * .setLogging(new BlobAnalyticsLogging() + * .setWrite(true) + * .setDelete(true) + * .setRetentionPolicy(loggingRetentionPolicy)) + * .setHourMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)) + * .setMinuteMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)); + * + * client.setPropertiesWithResponse(properties).subscribe(response -> + * System.out.printf("Setting properties completed with status %d%n", response.getStatusCode())); + *+ * * * @param properties Configures the service. * @return A {@link Mono} containing the storage account properties. @@ -670,7 +774,12 @@ private void validateRetentionPolicy(BlobRetentionPolicy retentionPolicy, String * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime} + * + *+ * client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response -> + * System.out.printf("User delegation key: %s%n", response.getValue())); + *+ * * * @param start Start time for the key's validity. Null indicates immediate start. * @param expiry Expiration of the key's validity. @@ -694,7 +803,12 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime} + * + *+ * client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response -> + * System.out.printf("User delegation key: %s%n", response.getValue().getValue())); + *+ * * * @param start Start time for the key's validity. Null indicates immediate start. * @param expiry Expiration of the key's validity. @@ -739,7 +853,12 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getStatistics} + * + *+ * client.getStatistics().subscribe(response -> + * System.out.printf("Geo-replication status: %s%n", response.getGeoReplication().getStatus())); + *+ * * * @return A {@link Mono} containing the storage account statistics. */ @@ -760,7 +879,12 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getStatisticsWithResponse} + * + *+ * client.getStatisticsWithResponse().subscribe(response -> + * System.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus())); + *+ * * * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} containing the * storage account statistics. @@ -788,7 +912,12 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfo} + * + *+ * client.getAccountInfo().subscribe(response -> + * System.out.printf("Account kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName())); + *+ * * * @return A {@link Mono} containing containing the storage account info. */ @@ -807,7 +936,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.getAccountInfoWithResponse} + * + *+ * client.getAccountInfoWithResponse().subscribe(response -> + * System.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(), + * response.getValue().getSkuName())); + *+ * * * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} the storage account * info. @@ -846,7 +981,22 @@ public String getAccountName() { * *
The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob * containers and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues} + * + *+ * AccountSasPermission permissions = new AccountSasPermission() + * .setListPermission(true) + * .setReadPermission(true); + * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + * + * AccountSasSignatureValues sasValues = + * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + * + * // Client must be authenticated via StorageSharedKeyCredential + * String sas = client.generateAccountSas(sasValues); + *+ * * * @param accountSasSignatureValues {@link AccountSasSignatureValues} * @@ -863,7 +1013,22 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa * *
The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob * containers and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.generateAccountSas#AccountSasSignatureValues-Context} + * + *+ * AccountSasPermission permissions = new AccountSasPermission() + * .setListPermission(true) + * .setReadPermission(true); + * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + * + * AccountSasSignatureValues sasValues = + * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + * + * // Client must be authenticated via StorageSharedKeyCredential + * String sas = client.generateAccountSas(sasValues, new Context("key", "value")); + *+ * * * @param accountSasSignatureValues {@link AccountSasSignatureValues} * @param context Additional context that is passed through the code when generating a SAS. @@ -895,7 +1060,19 @@ private void throwOnAnonymousAccess() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainer#String-String} + * + *+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); + * listBlobContainersOptions.getDetails().setRetrieveDeleted(true); + * client.listBlobContainers(listBlobContainersOptions).flatMap( + * deletedContainer -> { + * Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainer( + * deletedContainer.getName(), deletedContainer.getVersion()); + * return blobContainerClient; + * } + * ).then().block(); + *+ * * * @param deletedContainerName The name of the previously deleted container. * @param deletedContainerVersion The version of the previously deleted container. @@ -921,7 +1098,20 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions} + * + *+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); + * listBlobContainersOptions.getDetails().setRetrieveDeleted(true); + * client.listBlobContainers(listBlobContainersOptions).flatMap( + * deletedContainer -> { + * Mono<BlobContainerAsyncClient> blobContainerClient = client.undeleteBlobContainerWithResponse( + * new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion())) + * .map(Response::getValue); + * return blobContainerClient; + * } + * ).then().block(); + *+ * * * @param options {@link UndeleteBlobContainerOptions}. * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains a {@link @@ -957,7 +1147,8 @@ Mono
Code Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainer#String-String} +// * +// * // * // * @param sourceContainerName The current name of the container. // * @param destinationContainerName The new name of the container. @@ -975,7 +1166,8 @@ MonoCode Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobServiceAsyncClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions} +// * +// * // * // * @param sourceContainerName The current name of the container. // * @param options {@link BlobContainerRenameOptions} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java index 7f15e0b63ee41..0a2e272e92e6a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClient.java @@ -63,7 +63,11 @@ public final class BlobServiceClient { * *Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getBlobContainerClient#String} + * + *+ * BlobContainerClient blobContainerClient = client.getBlobContainerClient("containerName"); + *+ * * * @param containerName The name of the container to point to. * @return A {@link BlobContainerClient} object pointing to the specified container @@ -97,7 +101,11 @@ public BlobServiceVersion getServiceVersion() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.createBlobContainer#String} + * + *+ * BlobContainerClient blobContainerClient = client.createBlobContainer("containerName"); + *+ * * * @param containerName Name of the container to create * @return The {@link BlobContainerClient} used to interact with the container created. @@ -114,7 +122,18 @@ public BlobContainerClient createBlobContainer(String containerName) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.createBlobContainerWithResponse#String-Map-PublicAccessType-Context} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Context context = new Context("Key", "Value"); + * + * BlobContainerClient blobContainerClient = client.createBlobContainerWithResponse( + * "containerName", + * metadata, + * PublicAccessType.CONTAINER, + * context).getValue(); + *+ * * * @param containerName Name of the container to create * @param metadata Metadata to associate with the container. If there is leading or trailing whitespace in any @@ -139,7 +158,16 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.deleteBlobContainer#String} + * + *+ * try { + * client.deleteBlobContainer("container Name"); + * System.out.printf("Delete container completed with status %n"); + * } catch (UnsupportedOperationException error) { + * System.out.printf("Delete container failed: %s%n", error); + * } + *+ * * * @param containerName Name of the container to delete */ @@ -178,7 +206,11 @@ public String getAccountUrl() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.listBlobContainers} + * + *+ * client.listBlobContainers().forEach(container -> System.out.printf("Name: %s%n", container.getName())); + *+ * * * @return The list of containers. */ @@ -194,7 +226,15 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.listBlobContainers#ListBlobContainersOptions-Duration} + * + *+ * ListBlobContainersOptions options = new ListBlobContainersOptions() + * .setPrefix("containerNamePrefixToMatch") + * .setDetails(new BlobContainerListDetails().setRetrieveMetadata(true)); + * + * client.listBlobContainers(options, timeout).forEach(container -> System.out.printf("Name: %s%n", container.getName())); + *+ * * * @param options A {@link ListBlobContainersOptions} which specifies what data should be returned by the service. * If iterating by page, the page size passed to byPage methods such as @@ -214,7 +254,11 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.findBlobsByTag#String} + * + *+ * client.findBlobsByTags("where=tag=value").forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); + *+ * * * @param query Filters the results to return only blobs whose tags match the specified expression. * @return The list of blobs. @@ -231,7 +275,13 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.findBlobsByTag#FindBlobsOptions-Duration} + * + *+ * Context context = new Context("Key", "Value"); + * client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10), timeout, context) + * .forEach(blob -> System.out.printf("Name: %s%n", blob.getName())); + *+ * * * @param options {@link FindBlobsOptions}. If iterating by page, the page size passed to byPage methods such as * {@link PagedIterable#iterableByPage(int)} will be preferred over the value set on these options. @@ -250,7 +300,15 @@ public PagedIterable
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getProperties} + * + *+ * BlobServiceProperties properties = client.getProperties(); + * + * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", + * properties.getHourMetrics().isEnabled(), + * properties.getMinuteMetrics().isEnabled()); + *+ * * * @return The storage account properties. */ @@ -265,7 +323,16 @@ public BlobServiceProperties getProperties() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getPropertiesWithResponse#Duration-Context} + * + *+ * Context context = new Context("Key", "Value"); + * BlobServiceProperties properties = client.getPropertiesWithResponse(timeout, context).getValue(); + * + * System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n", + * properties.getHourMetrics().isEnabled(), + * properties.getMinuteMetrics().isEnabled()); + *+ * * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -289,7 +356,31 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.setProperties#BlobServiceProperties} + * + *+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); + * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); + * + * BlobServiceProperties properties = new BlobServiceProperties() + * .setLogging(new BlobAnalyticsLogging() + * .setWrite(true) + * .setDelete(true) + * .setRetentionPolicy(loggingRetentionPolicy)) + * .setHourMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)) + * .setMinuteMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)); + * + * try { + * client.setProperties(properties); + * System.out.printf("Setting properties completed%n"); + * } catch (UnsupportedOperationException error) { + * System.out.printf("Setting properties failed: %s%n", error); + * } + *+ * * * @param properties Configures the service. */ @@ -308,7 +399,29 @@ public void setProperties(BlobServiceProperties properties) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.setPropertiesWithResponse#BlobServiceProperties-Duration-Context} + * + *+ * BlobRetentionPolicy loggingRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(3); + * BlobRetentionPolicy metricsRetentionPolicy = new BlobRetentionPolicy().setEnabled(true).setDays(1); + * + * BlobServiceProperties properties = new BlobServiceProperties() + * .setLogging(new BlobAnalyticsLogging() + * .setWrite(true) + * .setDelete(true) + * .setRetentionPolicy(loggingRetentionPolicy)) + * .setHourMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)) + * .setMinuteMetrics(new BlobMetrics() + * .setEnabled(true) + * .setRetentionPolicy(metricsRetentionPolicy)); + * + * Context context = new Context("Key", "Value"); + * + * System.out.printf("Setting properties completed with status %d%n", + * client.setPropertiesWithResponse(properties, timeout, context).getStatusCode()); + *+ * * * @param properties Configures the service. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -329,7 +442,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getUserDelegationKey#OffsetDateTime-OffsetDateTime} + * + *+ * System.out.printf("User delegation key: %s%n", + * client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime)); + *+ * * * @param start Start time for the key's validity. Null indicates immediate start. * @param expiry Expiration of the key's validity. @@ -346,7 +464,12 @@ public UserDelegationKey getUserDelegationKey(OffsetDateTime start, OffsetDateTi * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getUserDelegationKeyWithResponse#OffsetDateTime-OffsetDateTime-Duration-Context} + * + *+ * System.out.printf("User delegation key: %s%n", + * client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime, timeout, context)); + *+ * * * @param start Start time for the key's validity. Null indicates immediate start. * @param expiry Expiration of the key's validity. @@ -371,7 +494,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getStatistics} + * + *+ * System.out.printf("Geo-replication status: %s%n", + * client.getStatistics().getGeoReplication().getStatus()); + *+ * * * @return The storage account statistics. */ @@ -388,7 +516,12 @@ public BlobServiceStatistics getStatistics() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getStatisticsWithResponse#Duration-Context} + * + *+ * System.out.printf("Geo-replication status: %s%n", + * client.getStatisticsWithResponse(timeout, context).getValue().getGeoReplication().getStatus()); + *+ * * * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the Http pipeline during the service call. @@ -407,7 +540,13 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.getAccountInfo} + * + *+ * StorageAccountInfo accountInfo = client.getAccountInfo(); + * + * System.out.printf("Account kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName()); + *+ * * * @return The storage account info. */ @@ -448,7 +587,22 @@ public String getAccountName() { *
Generating an account SAS
*The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user * read and list access to blob and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues} + * + *+ * AccountSasPermission permissions = new AccountSasPermission() + * .setListPermission(true) + * .setReadPermission(true); + * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + * + * AccountSasSignatureValues sasValues = + * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + * + * // Client must be authenticated via StorageSharedKeyCredential + * String sas = client.generateAccountSas(sasValues); + *+ * * * @param accountSasSignatureValues {@link AccountSasSignatureValues} * @@ -467,7 +621,22 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa *
Generating an account SAS
*The snippet below generates an AccountSasSignatureValues object that lasts for two days and gives the user * read and list access to blob and file shares.
- * {@codesnippet com.azure.storage.blob.BlobServiceClient.generateAccountSas#AccountSasSignatureValues-Context} + * + *+ * AccountSasPermission permissions = new AccountSasPermission() + * .setListPermission(true) + * .setReadPermission(true); + * AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true); + * AccountSasService services = new AccountSasService().setBlobAccess(true).setFileAccess(true); + * OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2)); + * + * AccountSasSignatureValues sasValues = + * new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); + * + * // Client must be authenticated via StorageSharedKeyCredential + * String sas = client.generateAccountSas(sasValues, new Context("key", "value")); + *+ * * * @param accountSasSignatureValues {@link AccountSasSignatureValues} * @param context Additional context that is passed through the code when generating a SAS. @@ -487,7 +656,18 @@ public String generateAccountSas(AccountSasSignatureValues accountSasSignatureVa * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.undeleteBlobContainer#String-String} + * + *+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); + * listBlobContainersOptions.getDetails().setRetrieveDeleted(true); + * client.listBlobContainers(listBlobContainersOptions, null).forEach( + * deletedContainer -> { + * BlobContainerClient blobContainerClient = client.undeleteBlobContainer( + * deletedContainer.getName(), deletedContainer.getVersion()); + * } + * ); + *+ * * * @param deletedContainerName The name of the previously deleted container. * @param deletedContainerVersion The version of the previously deleted container. @@ -511,7 +691,19 @@ public BlobContainerClient undeleteBlobContainer(String deletedContainerName, St * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.BlobServiceClient.undeleteBlobContainerWithResponse#UndeleteBlobContainerOptions-Duration-Context} + * + *+ * ListBlobContainersOptions listBlobContainersOptions = new ListBlobContainersOptions(); + * listBlobContainersOptions.getDetails().setRetrieveDeleted(true); + * client.listBlobContainers(listBlobContainersOptions, null).forEach( + * deletedContainer -> { + * BlobContainerClient blobContainerClient = client.undeleteBlobContainerWithResponse( + * new UndeleteBlobContainerOptions(deletedContainer.getName(), deletedContainer.getVersion()), + * timeout, context).getValue(); + * } + * ); + *+ * * * @param options {@link UndeleteBlobContainerOptions}. * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -534,7 +726,8 @@ public Response
Code Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobServiceClient.renameBlobContainer#String-String} +// * +// * // * // * @param sourceContainerName The current name of the container. // * @param destinationContainerName The new name of the container. @@ -551,7 +744,8 @@ public ResponseCode Samples
// * -// * {@codesnippet com.azure.storage.blob.BlobServiceClient.renameBlobContainerWithResponse#String-BlobContainerRenameOptions-Duration-Context} +// * +// * // * // * @param options {@link BlobContainerRenameOptions} // * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java index cefa209cdfd64..7f8ba61608f6a 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobAsyncClient.java @@ -147,7 +147,12 @@ public AppendBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedK * *Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.create} + * + *+ * client.create().subscribe(response -> + * System.out.printf("Created AppendBlob at %s%n", response.getLastModified())); + *+ * * * @return A {@link Mono} containing the information of the created appended blob. */ @@ -165,7 +170,13 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.create#boolean} + * + *+ * boolean overwrite = false; // Default behavior + * client.create(overwrite).subscribe(response -> + * System.out.printf("Created AppendBlob at %s%n", response.getLastModified())); + *+ * * * @param overwrite Whether or not to overwrite, should data exist on the blob. * @@ -191,7 +202,19 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentType("binary") + * .setContentLanguage("en-US"); + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.createWithResponse(headers, metadata, requestConditions).subscribe(response -> + * System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified())); + *+ * * * @param headers {@link BlobHttpHeaders} * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any @@ -214,7 +237,21 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.createWithResponse#AppendBlobCreateOptions} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentType("binary") + * .setContentLanguage("en-US"); + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) + * .setTags(tags).setRequestConditions(requestConditions)).subscribe(response -> + * System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified())); + *+ * * * @param options {@link AppendBlobCreateOptions} * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the created @@ -262,7 +299,12 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlock#Flux-long} + * + *+ * client.appendBlock(data, length).subscribe(response -> + * System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount())); + *+ * * * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled * (the default). In other words, the Flux must produce the same data each time it is subscribed to. @@ -287,7 +329,17 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockWithResponse#Flux-long-byte-AppendBlobRequestConditions} + * + *+ * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); + * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * + * client.appendBlockWithResponse(data, length, md5, requestConditions).subscribe(response -> + * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); + *+ * * * @param data The data to write to the blob. Note that this {@code Flux} must be replayable if retries are enabled * (the default). In other words, the Flux must produce the same data each time it is subscribed to. @@ -339,7 +391,12 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrl#String-BlobRange} + * + *+ * client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).subscribe(response -> + * System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount())); + *+ * * * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob @@ -362,7 +419,20 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions} + * + *+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * + * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, + * appendBlobRequestConditions, modifiedRequestConditions).subscribe(response -> + * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); + *+ * * * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob @@ -395,7 +465,22 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions} + * + *+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * + * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) + * .setSourceRange(new BlobRange(offset, count)) + * .setDestinationRequestConditions(appendBlobRequestConditions) + * .setSourceRequestConditions(modifiedRequestConditions)).subscribe(response -> + * System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount())); + *+ * * * @param options Parameters for the operation. * @return A {@link Mono} containing {@link Response} whose {@link Response#getValue() value} contains the append @@ -450,7 +535,11 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.seal} + * + *+ * client.seal().subscribe(response -> System.out.println("Sealed AppendBlob")); + *+ * * * @return A reactive response signalling completion. */ @@ -469,7 +558,15 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobAsyncClient.sealWithResponse#AppendBlobSealOptions} + * + *+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions)) + * .subscribe(response -> System.out.println("Sealed AppendBlob")); + *+ * * * @param options {@link AppendBlobSealOptions} * @return A reactive response signalling completion. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java index 0f035b026c090..64f71c4a2f7aa 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/AppendBlobClient.java @@ -128,7 +128,11 @@ public BlobOutputStream getBlobOutputStream(AppendBlobRequestConditions requestC * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.create} + * + *+ * System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified()); + *+ * * * @return The information of the created appended blob. */ @@ -142,7 +146,12 @@ public AppendBlobItem create() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.create#boolean} + * + *+ * boolean overwrite = false; // Default value + * System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified()); + *+ * * * @param overwrite Whether or not to overwrite, should data exist on the blob. * @@ -164,7 +173,22 @@ public AppendBlobItem create(boolean overwrite) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#BlobHttpHeaders-Map-BlobRequestConditions-Duration-Context} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentType("binary") + * .setContentLanguage("en-US"); + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Context context = new Context("key", "value"); + * + * System.out.printf("Created AppendBlob at %s%n", + * client.createWithResponse(headers, metadata, requestConditions, timeout, context).getValue() + * .getLastModified()); + *+ * * * @param headers {@link BlobHttpHeaders} * @param metadata Metadata to associate with the blob. If there is leading or trailing whitespace in any @@ -188,7 +212,23 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.createWithResponse#AppendBlobCreateOptions-Duration-Context} + * + *+ * BlobHttpHeaders headers = new BlobHttpHeaders() + * .setContentType("binary") + * .setContentLanguage("en-US"); + * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tags", "value"); + * BlobRequestConditions requestConditions = new BlobRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Context context = new Context("key", "value"); + * + * System.out.printf("Created AppendBlob at %s%n", + * client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) + * .setTags(tags).setRequestConditions(requestConditions), timeout, context).getValue() + * .getLastModified()); + *+ * * * @param options {@link AppendBlobCreateOptions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -210,7 +250,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlock#InputStream-long} + * + *+ * System.out.printf("AppendBlob has %d committed blocks%n", + * client.appendBlock(data, length).getBlobCommittedBlockCount()); + *+ * * * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. @@ -232,7 +277,19 @@ public AppendBlobItem appendBlock(InputStream data, long length) { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockWithResponse#InputStream-long-byte-AppendBlobRequestConditions-Duration-Context} + * + *+ * byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); + * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * Context context = new Context("key", "value"); + * + * System.out.printf("AppendBlob has %d committed blocks%n", + * client.appendBlockWithResponse(data, length, md5, requestConditions, timeout, context) + * .getValue().getBlobCommittedBlockCount()); + *+ * * * @param data The data to write to the blob. The data must be markable. This is in order to support retries. If * the data is not markable, consider using {@link #getBlobOutputStream()} and writing to the returned OutputStream. @@ -265,7 +322,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrl#String-BlobRange} + * + *+ * System.out.printf("AppendBlob has %d committed blocks%n", + * client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).getBlobCommittedBlockCount()); + *+ * * * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob @@ -284,7 +346,23 @@ public AppendBlobItem appendBlockFromUrl(String sourceUrl, BlobRange sourceRange * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#String-BlobRange-byte-AppendBlobRequestConditions-BlobRequestConditions-Duration-Context} + * + *+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * + * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * Context context = new Context("key", "value"); + * + * System.out.printf("AppendBlob has %d committed blocks%n", + * client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, + * appendBlobRequestConditions, modifiedRequestConditions, timeout, + * context).getValue().getBlobCommittedBlockCount()); + *+ * * * @param sourceUrl The url to the blob that will be the source of the copy. A source blob in the same storage * account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob @@ -315,7 +393,25 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.appendBlockFromUrlWithResponse#AppendBlobAppendBlockFromUrlOptions-Duration-Context} + * + *+ * AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() + * .setAppendPosition(POSITION) + * .setMaxSize(maxSize); + * + * BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * + * Context context = new Context("key", "value"); + * + * System.out.printf("AppendBlob has %d committed blocks%n", + * client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) + * .setSourceRange(new BlobRange(offset, count)) + * .setDestinationRequestConditions(appendBlobRequestConditions) + * .setSourceRequestConditions(modifiedRequestConditions), timeout, + * context).getValue().getBlobCommittedBlockCount()); + *+ * * * @param options options for the operation * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. @@ -335,7 +431,12 @@ public Response
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.seal} + * + *+ * client.seal(); + * System.out.println("Sealed AppendBlob"); + *+ * */ @ServiceMethod(returns = ReturnType.SINGLE) public void seal() { @@ -347,7 +448,16 @@ public void seal() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.AppendBlobClient.sealWithResponse#AppendBlobSealOptions-Duration-Context} + * + *+ * AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); + * Context context = new Context("key", "value"); + * + * client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions), timeout, context); + * System.out.println("Sealed AppendBlob"); + *+ * * * @param options {@link AppendBlobSealOptions} * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java index 09c527614bd2d..450e71940eafa 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java @@ -329,7 +329,12 @@ public String getBlobUrl() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerName} + * + *+ * String containerName = client.getContainerName(); + * System.out.println("The name of the container is " + containerName); + *+ * * * @return The name of the container. */ @@ -342,7 +347,12 @@ public final String getContainerName() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getContainerAsyncClient} + * + *+ * BlobContainerAsyncClient containerClient = client.getContainerAsyncClient(); + * System.out.println("The name of the container is " + containerClient.getBlobContainerName()); + *+ * * * @return {@link BlobContainerAsyncClient} */ @@ -366,7 +376,12 @@ final BlobContainerClientBuilder getContainerClientBuilder() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getBlobName} + * + *+ * String blobName = client.getBlobName(); + * System.out.println("The name of the blob is " + blobName); + *+ * * * @return The decoded name of the blob. */ @@ -442,7 +457,11 @@ public String getVersionId() { * *
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.exists} + * + *+ * client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); + *+ * * * @return true if the blob exists, false if it doesn't */ @@ -460,7 +479,11 @@ public Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.existsWithResponse} + * + *+ * client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); + *+ * * * @return true if the blob exists, false if it doesn't */ @@ -502,7 +525,12 @@ Mono
Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Duration} + * + *+ * client.beginCopy(url, Duration.ofSeconds(3)) + * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); + *+ * * *
For more information, see the * Azure Docs
@@ -529,7 +557,21 @@ public PollerFluxStarting a copy operation
* Starting a copy operation and polling on the responses. * - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopy#String-Map-AccessTier-RehydratePriority-RequestConditions-BlobRequestConditions-Duration} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * RequestConditions modifiedRequestConditions = new RequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.beginCopy(url, metadata, AccessTier.HOT, RehydratePriority.STANDARD, + * modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2)) + * .subscribe(response -> { + * BlobCopyInfo info = response.getValue(); + * System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus()); + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -570,11 +612,52 @@ public PollerFlux+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) + * .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions) + * .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2))) + * .subscribe(response -> { + * BlobCopyInfo info = response.getValue(); + * System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus()); + * }); + *+ * * *
Cancelling a copy operation
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.beginCopyFromUrlCancel#BlobBeginCopyOptions} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * PollerFlux<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url) + * .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) + * .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions) + * .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2))); + * + * poller.take(Duration.ofMinutes(30)) + * .last() + * .flatMap(asyncPollResponse -> { + * if (!asyncPollResponse.getStatus().isComplete()) { + * return asyncPollResponse + * .cancelOperation() + * .then(Mono.error(new RuntimeException("Blob copy taking long time, " + * + "operation is cancelled!"))); + * } + * return Mono.just(asyncPollResponse); + * }).block(); + *+ * * *
For more information, see the * Azure Docs
@@ -733,7 +816,11 @@ private MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrl#String} + * + *+ * client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL")); + *+ * * *
For more information, see the * Azure Docs
@@ -758,7 +845,12 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.abortCopyFromUrlWithResponse#String-String} + * + *+ * client.abortCopyFromUrlWithResponse(copyId, leaseId) + * .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode())); + *+ * * *
For more information, see the * Azure Docs
@@ -793,7 +885,11 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrl#String} + * + *+ * client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); + *+ * * *
For more information, see the * Azure Docs
@@ -818,7 +914,17 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.copyFromUrlWithResponse#String-Map-AccessTier-RequestConditions-BlobRequestConditions} + * + *+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * RequestConditions modifiedRequestConditions = new RequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions) + * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); + *+ * * *
For more information, see the * Azure Docs
@@ -851,7 +957,20 @@ public Mono+ * Map<String, String> metadata = Collections.singletonMap("metadata", "value"); + * Map<String, String> tags = Collections.singletonMap("tag", "value"); + * RequestConditions modifiedRequestConditions = new RequestConditions() + * .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7)); + * BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags) + * .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions) + * .setDestinationRequestConditions(blobRequestConditions)) + * .subscribe(response -> System.out.printf("Copy identifier: %s%n", response)); + *+ * * *
For more information, see the * Azure Docs
@@ -904,7 +1023,18 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.download} + * + *+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + * client.download().subscribe(piece -> { + * try { + * downloadData.write(piece.array()); + * } catch (IOException ex) { + * throw new UncheckedIOException(ex); + * } + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -924,7 +1054,18 @@ public FluxCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStream} + * + *+ * ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + * client.downloadStream().subscribe(piece -> { + * try { + * downloadData.write(piece.array()); + * } catch (IOException ex) { + * throw new UncheckedIOException(ex); + * } + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -947,7 +1088,13 @@ public FluxCode Samples
* - * {@codesnippet com.azure.storage.blob.BlobAsyncClient.downloadContent} + * + *+ * client.downloadContent().subscribe(data -> { + * System.out.printf("Downloaded %s", data.toString()); + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -973,7 +1120,23 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean} + * + *+ * BlobRange range = new BlobRange(1024, (long) 2048); + * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); + * + * client.downloadWithResponse(range, options, null, false).subscribe(response -> { + * ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + * response.getValue().subscribe(piece -> { + * try { + * downloadData.write(piece.array()); + * } catch (IOException ex) { + * throw new UncheckedIOException(ex); + * } + * }); + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -999,7 +1162,23 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadStreamWithResponse#BlobRange-DownloadRetryOptions-BlobRequestConditions-boolean} + * + *+ * BlobRange range = new BlobRange(1024, (long) 2048); + * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); + * + * client.downloadStreamWithResponse(range, options, null, false).subscribe(response -> { + * ByteArrayOutputStream downloadData = new ByteArrayOutputStream(); + * response.getValue().subscribe(piece -> { + * try { + * downloadData.write(piece.array()); + * } catch (IOException ex) { + * throw new UncheckedIOException(ex); + * } + * }); + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -1028,7 +1207,16 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadContentWithResponse#DownloadRetryOptions-BlobRequestConditions} + * + *+ * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); + * + * client.downloadContentWithResponse(options, null).subscribe(response -> { + * BinaryData content = response.getValue(); + * System.out.println(content.toString()); + * }); + *+ * * *
For more information, see the * Azure Docs
@@ -1146,7 +1334,11 @@ private MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String} + * + *+ * client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file")); + *+ * * *
For more information, see the * Azure Docs
@@ -1167,7 +1359,12 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFile#String-boolean} + * + *+ * boolean overwrite = false; // Default value + * client.downloadToFile(file, overwrite).subscribe(response -> System.out.println("Completed download to file")); + *+ * * *
For more information, see the * Azure Docs
@@ -1203,7 +1400,15 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean} + * + *+ * BlobRange range = new BlobRange(1024, 2048L); + * DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5); + * + * client.downloadToFileWithResponse(file, range, null, options, null, false) + * .subscribe(response -> System.out.println("Completed download to file")); + *+ * * *
For more information, see the * Azure Docs
@@ -1236,7 +1441,17 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#String-BlobRange-ParallelTransferOptions-DownloadRetryOptions-BlobRequestConditions-boolean-Set} + * + *+ * BlobRange blobRange = new BlobRange(1024, 2048L); + * DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5); + * Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, + * StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options + * + * client.downloadToFileWithResponse(file, blobRange, null, downloadRetryOptions, null, false, openOptions) + * .subscribe(response -> System.out.println("Completed download to file")); + *+ * * *
For more information, see the * Azure Docs
@@ -1279,7 +1494,16 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.downloadToFileWithResponse#BlobDownloadToFileOptions} + * + *+ * client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file) + * .setRange(new BlobRange(1024, 2018L)) + * .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5)) + * .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, + * StandardOpenOption.READ)))) + * .subscribe(response -> System.out.println("Completed download to file")); + *+ * * *
For more information, see the * Azure Docs
@@ -1427,7 +1651,11 @@ private void downloadToFileCleanup(AsynchronousFileChannel channel, String fileP * *Code Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.delete} + * + *+ * client.delete().doOnSuccess(response -> System.out.println("Completed delete")); + *+ * * *
For more information, see the * Azure Docs
@@ -1450,7 +1678,12 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.deleteWithResponse#DeleteSnapshotsOptionType-BlobRequestConditions} + * + *+ * client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null) + * .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode())); + *+ * * *
For more information, see the * Azure Docs
@@ -1488,7 +1721,12 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getProperties} + * + *+ * client.getProperties().subscribe(response -> + * System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize())); + *+ * * *
For more information, see the * Azure Docs
@@ -1509,7 +1747,15 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getPropertiesWithResponse#BlobRequestConditions} + * + *+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.getPropertiesWithResponse(requestConditions).subscribe( + * response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(), + * response.getValue().getBlobSize())); + *+ * * *
For more information, see the * Azure Docs
@@ -1566,7 +1812,13 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeaders#BlobHttpHeaders} + * + *+ * client.setHttpHeaders(new BlobHttpHeaders() + * .setContentLanguage("en-US") + * .setContentType("binary")); + *+ * * *
For more information, see the * Azure Docs
@@ -1589,7 +1841,18 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setHttpHeadersWithResponse#BlobHttpHeaders-BlobRequestConditions} + * + *+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.setHttpHeadersWithResponse(new BlobHttpHeaders() + * .setContentLanguage("en-US") + * .setContentType("binary"), requestConditions).subscribe( + * response -> + * System.out.printf("Set HTTP headers completed with status %d%n", + * response.getStatusCode())); + *+ * * *
For more information, see the * Azure Docs
@@ -1625,7 +1888,11 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadata#Map} + * + *+ * client.setMetadata(Collections.singletonMap("metadata", "value")); + *+ * * *
For more information, see the * Azure Docs
@@ -1649,7 +1916,14 @@ public MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.setMetadataWithResponse#Map-BlobRequestConditions} + * + *+ * BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId); + * + * client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions) + * .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode())); + *+ * * *
For more information, see the * Azure Docs
@@ -1687,7 +1961,12 @@ MonoCode Samples
* - * {@codesnippet com.azure.storage.blob.specialized.BlobAsyncClientBase.getTags} + * + *+ * client.getTags().subscribe(response -> + * System.out.printf("Num tags: %d%n", response.size())); + *+ * * *
For more information, see the * Azure Docs
@@ -1704,7 +1983,12 @@ public Mono