Skip to content

Commit

Permalink
Update Storage to azure-core preview 3 (#4482)
Browse files Browse the repository at this point in the history
* Storage SAS implementation (#4404)

* SAS implementation

* Fixed some minor formatting issues

* Fixed checkstyle problems and test issue

* Remove RawClients from Blobs (#4375)

Removes RawClients from Storage Blobs

* Add storage swaggers

* Update Storage to azure-core preview 3

* Add deleteContainer to StorageClient and getBlobClient with Snapshot to ContainerClient (#4376)

* Removed raw clients

* Added deleteContainer to StorageClient

* Added getAppendBlob with snapshot to ContainerClient

* Storage queue linting, builder refactor, tests (#4383)

* Initial check in for storage queue

* Address code review feedback in AutoRest

* Initial checkin for Storage file (#4414)

* Finished the restructure, refactor builder. Added sleep in record feature. Linting

* Merge Storage Blob Client Builders (#4468)

Merges AppendBlobClientBuilder, BlobClientBuilder, BlockBlobClientBuilder, and PageBlobClientBuilder into a single builder class BlobClientBuilder. Additionally, JavaDoc comments for the other builder classes, ContainerClientBuilder and StorageAccountClientBuilder, were cleaned up and the way the endpoint is handled in builders was changed.

* Regenerate blob file queue after merge

* Up azure core version for file & queue

* Apply all the manual fixes in swagger

* Change directoryName to directoryPath

* Use non-fluent pattern for generated clients

* Fix build after merging with master

* Return void on setters

* Revert spotbugs config change
  • Loading branch information
jianghaolu authored Jul 29, 2019
1 parent 7ca6b86 commit 7ec7ffa
Show file tree
Hide file tree
Showing 232 changed files with 1,801 additions and 1,016 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
<Bug pattern="NP_NULL_PARAM_DEREF"/>
</Match>

<!-- The switch cases are encoded version of all SAS query parameters, which will further be appended to a request URL it seems like. A default case wouldn't make sense -->
<!-- The switch cases are encoded version of all SAS query parameters, which will further be appended to a request URL it seems like. A default case wouldn't make sense -->
<Match>
<Class name="com.microsoft.azure.storage.blob.SASQueryParameters"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* <p>Create a pipeline without configuration</p>
*
* <pre>
* HttpPipeline.builder()
* new HttpPipelineBuilder()
* .build();
* </pre>
*
* <p>Create a pipeline using the default HTTP client and a retry policy</p>
*
* <pre>
* HttpPipeline.builder()
* new HttpPipelineBuilder()
* .httpClient(HttpClient.createDefault())
* .policies(new RetryPolicy())
* .build();
Expand Down
4 changes: 2 additions & 2 deletions storage/client/blob/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.0.0-preview.2</version>
<version>1.0.0-preview.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -69,7 +69,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.0.0-preview.2</version>
<version>1.0.0-preview.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class BlobAsyncClient {
public BlockBlobAsyncClient asBlockBlobAsyncClient() {
return new BlockBlobAsyncClient(new AzureBlobStorageBuilder()
.url(getBlobUrl().toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand All @@ -110,7 +110,7 @@ public BlockBlobAsyncClient asBlockBlobAsyncClient() {
public AppendBlobAsyncClient asAppendBlobAsyncClient() {
return new AppendBlobAsyncClient(new AzureBlobStorageBuilder()
.url(getBlobUrl().toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand All @@ -122,7 +122,7 @@ public AppendBlobAsyncClient asAppendBlobAsyncClient() {
public PageBlobAsyncClient asPageBlobAsyncClient() {
return new PageBlobAsyncClient(new AzureBlobStorageBuilder()
.url(getBlobUrl().toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand All @@ -136,7 +136,7 @@ public ContainerAsyncClient getContainerAsyncClient() {
BlobURLParts parts = URLParser.parse(getBlobUrl());
return new ContainerAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s://%s/%s", parts.scheme(), parts.host(), parts.containerName()))
.pipeline(azureBlobStorage.httpPipeline()));
.pipeline(azureBlobStorage.getHttpPipeline()));
}

/**
Expand All @@ -147,13 +147,13 @@ public ContainerAsyncClient getContainerAsyncClient() {
*/
public URL getBlobUrl() {
try {
UrlBuilder urlBuilder = UrlBuilder.parse(azureBlobStorage.url());
UrlBuilder urlBuilder = UrlBuilder.parse(azureBlobStorage.getUrl());
if (snapshot != null) {
urlBuilder.query("snapshot=" + snapshot);
}
return urlBuilder.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.url()), e);
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.getUrl()), e);
}
}

Expand Down Expand Up @@ -925,7 +925,7 @@ public String generateSAS(String identifier, BlobSASPermission permissions, Offs
cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType);

SharedKeyCredential sharedKeyCredential =
Utility.getSharedKeyCredential(this.azureBlobStorage.httpPipeline());
Utility.getSharedKeyCredential(this.azureBlobStorage.getHttpPipeline());

Utility.assertNotNull("sharedKeyCredential", sharedKeyCredential);

Expand All @@ -944,7 +944,7 @@ ServiceSASSignatureValues configureServiceSASSignatureValues(ServiceSASSignature
String accountName) {

// Set canonical name
serviceSASSignatureValues.canonicalName(this.azureBlobStorage.url(), accountName);
serviceSASSignatureValues.canonicalName(this.azureBlobStorage.getUrl(), accountName);

// Set snapshotId
serviceSASSignatureValues.snapshotId(getSnapshotId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.credentials.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogDetailLevel;
Expand Down Expand Up @@ -120,7 +121,7 @@ private AzureBlobStorageBuilder buildImpl() {
policies.addAll(this.policies);
policies.add(new HttpLoggingPolicy(logLevel));

HttpPipeline pipeline = HttpPipeline.builder()
HttpPipeline pipeline = new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public BlockBlobAsyncClient getBlockBlobAsyncClient(String blobName) {
public BlockBlobAsyncClient getBlockBlobAsyncClient(String blobName, String snapshot) {
return new BlockBlobAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.appendToURLPath(getContainerUrl(), blobName).toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ public PageBlobAsyncClient getPageBlobAsyncClient(String blobName) {
public PageBlobAsyncClient getPageBlobAsyncClient(String blobName, String snapshot) {
return new PageBlobAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.appendToURLPath(getContainerUrl(), blobName).toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand Down Expand Up @@ -173,7 +173,7 @@ public AppendBlobAsyncClient getAppendBlobAsyncClient(String blobName) {
public AppendBlobAsyncClient getAppendBlobAsyncClient(String blobName, String snapshot) {
return new AppendBlobAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.appendToURLPath(getContainerUrl(), blobName).toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand Down Expand Up @@ -202,7 +202,7 @@ public BlobAsyncClient getBlobAsyncClient(String blobName) {
public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) {
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.appendToURLPath(getContainerUrl(), blobName).toString())
.pipeline(azureBlobStorage.httpPipeline()), snapshot);
.pipeline(azureBlobStorage.getHttpPipeline()), snapshot);
}

/**
Expand All @@ -213,7 +213,7 @@ public BlobAsyncClient getBlobAsyncClient(String blobName, String snapshot) {
public StorageAsyncClient getStorageAsyncClient() {
return new StorageAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.stripLastPathSegment(getContainerUrl()).toString())
.pipeline(azureBlobStorage.httpPipeline()));
.pipeline(azureBlobStorage.getHttpPipeline()));
}

/**
Expand All @@ -224,9 +224,9 @@ public StorageAsyncClient getStorageAsyncClient() {
*/
public URL getContainerUrl() {
try {
return new URL(azureBlobStorage.url());
return new URL(azureBlobStorage.getUrl());
} catch (MalformedURLException e) {
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.url()), e);
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.getUrl()), e);
}
}

Expand Down Expand Up @@ -681,7 +681,7 @@ private Flux<BlobItem> listBlobsHierarchyHelper(String delimiter, ListBlobsOptio
} else {
prefixes = Flux.empty();
}
Flux<BlobItem> result = blobs.concatWith(prefixes.map(prefix -> new BlobItem().name(prefix.name()).isPrefix(true)));
Flux<BlobItem> result = blobs.map(item -> item.isPrefix(false)).concatWith(prefixes.map(prefix -> new BlobItem().name(prefix.name()).isPrefix(true)));

if (response.value().nextMarker() != null) {
// Recursively add the continuation items to the observable.
Expand Down Expand Up @@ -1102,7 +1102,7 @@ public String generateSAS(String identifier, ContainerSASPermission permissions,
cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType);

SharedKeyCredential sharedKeyCredential =
Utility.getSharedKeyCredential(this.azureBlobStorage.httpPipeline());
Utility.getSharedKeyCredential(this.azureBlobStorage.getHttpPipeline());

Utility.assertNotNull("sharedKeyCredential", sharedKeyCredential);

Expand All @@ -1119,7 +1119,7 @@ public String generateSAS(String identifier, ContainerSASPermission permissions,
*/
private ServiceSASSignatureValues configureServiceSASSignatureValues(ServiceSASSignatureValues serviceSASSignatureValues, String accountName) {
// Set canonical name
serviceSASSignatureValues.canonicalName(this.azureBlobStorage.url(), accountName);
serviceSASSignatureValues.canonicalName(this.azureBlobStorage.getUrl(), accountName);

// Set snapshotId to null
serviceSASSignatureValues.snapshotId(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.credentials.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogDetailLevel;
Expand Down Expand Up @@ -110,7 +111,7 @@ private AzureBlobStorageBuilder buildImpl() {
policies.addAll(this.policies);
policies.add(new HttpLoggingPolicy(logLevel));

HttpPipeline pipeline = HttpPipeline.builder()
HttpPipeline pipeline = new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public final class StorageAsyncClient {
public ContainerAsyncClient getContainerAsyncClient(String containerName) {
return new ContainerAsyncClient(new AzureBlobStorageBuilder()
.url(Utility.appendToURLPath(getAccountUrl(), containerName).toString())
.pipeline(azureBlobStorage.httpPipeline()));
.pipeline(azureBlobStorage.getHttpPipeline()));
}

/**
Expand Down Expand Up @@ -125,9 +125,9 @@ public Mono<VoidResponse> deleteContainer(String containerName) {
*/
public URL getAccountUrl() {
try {
return new URL(azureBlobStorage.url());
return new URL(azureBlobStorage.getUrl());
} catch (MalformedURLException e) {
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.url()), e);
throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureBlobStorage.getUrl()), e);
}
}

Expand Down Expand Up @@ -318,7 +318,7 @@ public String generateAccountSAS(AccountSASService accountSASService, AccountSAS
accountSASSignatureValues.ipRange(ipRange);
accountSASSignatureValues.protocol(sasProtocol);

SharedKeyCredential sharedKeyCredential = Utility.getSharedKeyCredential(this.azureBlobStorage.httpPipeline());
SharedKeyCredential sharedKeyCredential = Utility.getSharedKeyCredential(this.azureBlobStorage.getHttpPipeline());

SASQueryParameters sasQueryParameters = accountSASSignatureValues.generateSASQueryParameters(sharedKeyCredential);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.credentials.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogDetailLevel;
Expand Down Expand Up @@ -104,7 +105,7 @@ private AzureBlobStorageBuilder buildImpl() {
policies.addAll(this.policies);
policies.add(new HttpLoggingPolicy(logLevel));

HttpPipeline pipeline = HttpPipeline.builder()
HttpPipeline pipeline = new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.build();
Expand Down
Loading

0 comments on commit 7ec7ffa

Please sign in to comment.