Skip to content

Commit

Permalink
fix the issue 18809 (Azure#20773)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melanie-Ma authored May 13, 2021
1 parent b32689e commit d389bd0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.azure.core.http.rest.Response;
import com.azure.core.util.Configuration;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobClientBuilder;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.BlobRequestConditions;
Expand All @@ -22,10 +23,12 @@ public class BlobBatchAsyncClientJavaDocCodeSnippets {
private static final String ENDPOINT = Configuration.getGlobalConfiguration().get("PRIMARY_STORAGE_BLOB_ENDPOINT");
private static final String SASTOKEN = Configuration.getGlobalConfiguration().get("SAS_TOKEN");

private BlobBatchAsyncClient batchAsyncClient = new BlobBatchClientBuilder(new BlobServiceClientBuilder()
.encryptionScope(ENDPOINT)
.sasToken(SASTOKEN).buildClient())
.buildAsyncClient();
private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint(ENDPOINT)
.sasToken(SASTOKEN)
.buildClient();

private BlobBatchAsyncClient batchAsyncClient = new BlobBatchClientBuilder(blobServiceClient).buildAsyncClient();

/**
* Code snippet for {@link BlobBatchAsyncClient#submitBatch(BlobBatch)}
Expand Down Expand Up @@ -69,10 +72,10 @@ public void submitBatchWithResponse() {
* Code snippet for {@link BlobBatchAsyncClient#deleteBlobs(List, DeleteSnapshotsOptionType)}
*/
public void deleteBlobs() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchAsyncClient.deleteBlobs#List-DeleteSnapshotsOptionType
List<String> blobUrls = new ArrayList<>();
Expand All @@ -91,10 +94,10 @@ public void deleteBlobs() {
* Code snippet for {@link BlobBatchAsyncClient#setBlobsAccessTier(List, AccessTier)}
*/
public void setBlobsAccessTier() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchAsyncClient.setBlobsAccessTier#List-AccessTier
List<String> blobUrls = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import com.azure.core.util.Configuration;
import com.azure.core.util.Context;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobClientBuilder;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.BlobRequestConditions;
Expand All @@ -25,10 +26,13 @@ public class BlobBatchClientJavaDocCodeSnippets {
private static final String ENDPOINT = Configuration.getGlobalConfiguration().get("PRIMARY_STORAGE_BLOB_ENDPOINT");
private static final String SASTOKEN = Configuration.getGlobalConfiguration().get("SAS_TOKEN");

private BlobBatchClient batchClient = new BlobBatchClientBuilder(new BlobServiceClientBuilder()
.endpoint(ENDPOINT)
.sasToken(SASTOKEN).buildClient())
.buildClient();
private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint(ENDPOINT)
.sasToken(SASTOKEN)
.buildClient();

private BlobBatchClient batchClient = new BlobBatchClientBuilder(blobServiceClient).buildClient();

private Duration timeout = Duration.ofSeconds(30);

/**
Expand Down Expand Up @@ -79,10 +83,10 @@ public void submitBatchWithResponse() {
* Code snippet for {@link BlobBatchClient#deleteBlobs(List, DeleteSnapshotsOptionType)}
*/
public void deleteBlobs() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchClient.deleteBlobs#List-DeleteSnapshotsOptionType
List<String> blobUrls = new ArrayList<>();
Expand All @@ -104,10 +108,10 @@ public void deleteBlobs() {
* Code snippet for {@link BlobBatchClient#deleteBlobs(List, DeleteSnapshotsOptionType, Duration, Context)}
*/
public void deleteBlobsWithTimeoutAndContext() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchClient.deleteBlobs#List-DeleteSnapshotsOptionType-Duration-Context
List<String> blobUrls = new ArrayList<>();
Expand All @@ -129,10 +133,10 @@ public void deleteBlobsWithTimeoutAndContext() {
* Code snippet for {@link BlobBatchClient#setBlobsAccessTier(List, AccessTier)}
*/
public void setBlobsAccessTier() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchClient.setBlobsAccessTier#List-AccessTier
List<String> blobUrls = new ArrayList<>();
Expand All @@ -154,10 +158,10 @@ public void setBlobsAccessTier() {
* Code snippet for {@link BlobBatchClient#setBlobsAccessTier(List, AccessTier, Duration, Context)}
*/
public void setBlobsAccessTierWithTimeoutAndContext() {
BlobClientBuilder blobClientBuilder = new BlobClientBuilder();
BlobClient blobClient1 = blobClientBuilder.buildClient();
BlobClient blobClient2 = blobClientBuilder.buildClient();
BlobClient blobClient3 = blobClientBuilder.buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient("<CONTAINER_NAME>");
BlobClient blobClient1 = containerClient.getBlobClient("<BLOB_NAME1>");
BlobClient blobClient2 = containerClient.getBlobClient("<BLOB_NAME2>");
BlobClient blobClient3 = containerClient.getBlobClient("<BLOB_NAME3>");

// BEGIN: com.azure.storage.blob.batch.BlobBatchClient.setBlobsAccessTier#List-AccessTier-Duration-Context
List<String> blobUrls = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* Code samples for the README.md
*/
public class ReadmeSamples {
private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().buildClient();
private BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint("<YOUR_END_POINT>").sasToken("<YOUR_SAS_TOKEN>").buildClient();
private BlobBatchClient blobBatchClient = new BlobBatchClientBuilder(blobServiceClient).buildClient();
private String blobUrl = "https://account.core.windows.net/containerName/blobName";
private String blobUrl2 = "https://account.core.windows.net/containerName/blobName2";
private String blobUrlWithSnapshot = "https://account.core.windows.net/containerName/blobName?snapshot=<DateTime>";
private String blobUrlWithLease = "https://account.core.windows.net/containerName/blobNameWithLease";
private String blobUrl = String.format("https://%s.blob.core.windows.net/containerName/blobName", "<YOUR_STORAGE_ACCOUNT>");
private String blobUrl2 = String.format("https://%s.blob.core.windows.net/containerName/blobName2", "<YOUR_STORAGE_ACCOUNT>");
private String blobUrlWithSnapshot = String.format("https://%s.blob.core.windows.net/containerName/blobName?snapshot=<DateTime>", "<YOUR_STORAGE_ACCOUNT>");
private String blobUrlWithLease = String.format("https://%s.blob.core.windows.net/containerName/blobNameWithLease", "<YOUR_STORAGE_ACCOUNT>");
private List<String> blobUrls = Arrays.asList(blobUrl, blobUrl2, blobUrlWithSnapshot, blobUrlWithLease);

public void createHttpClient() {
Expand Down

0 comments on commit d389bd0

Please sign in to comment.