Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Storage to azure-core preview 3 #4489

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
10a85ad
Add storage swaggers
jianghaolu Jul 17, 2019
593ebf2
Update Storage to azure-core preview 3
jianghaolu Jul 19, 2019
b602214
Address code review feedback in AutoRest
jianghaolu Jul 24, 2019
9cbf411
Merge branch 'storage-post-review1-dev' of github.com:Azure/azure-sdk…
jianghaolu Jul 24, 2019
822b41d
Merge branch 'storage-post-review1-dev' of github.com:Azure/azure-sdk…
jianghaolu Jul 24, 2019
e19ea2b
Regenerate blob file queue after merge
jianghaolu Jul 24, 2019
7149824
Up azure core version for file & queue
jianghaolu Jul 24, 2019
efc335c
Apply all the manual fixes in swagger
jianghaolu Jul 24, 2019
87f3090
Change directoryName to directoryPath
jianghaolu Jul 24, 2019
5ce9473
Merge branch 'storage-post-review1-dev' of github.com:Azure/azure-sdk…
jianghaolu Jul 24, 2019
28beb79
Use non-fluent pattern for generated clients
jianghaolu Jul 24, 2019
570632c
Feature Work for Storage (#4584)
alzimmermsft Jul 25, 2019
ea2f43a
Removing the Jackson leak in HttpHeaders, instead registering a separ…
JonathanGiles Jul 26, 2019
9739dc6
Batch #2 - 11. No .builder() API: No classes should have a .builder()…
Jul 26, 2019
dd272bf
Add Tracing context in Key Vault keys package (#4500)
samvaity Jul 26, 2019
62c2dfc
Merge branch 'storage-post-review1-dev' of github.com:Azure/azure-sdk…
jianghaolu Jul 26, 2019
a5bc2dd
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into sto…
jianghaolu Jul 26, 2019
a2b67ea
Fix build after merging with master
jianghaolu Jul 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ page at http://checkstyle.sourceforge.net/config.html -->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="MethodName">
<!-- Use default MethodName but block the use of 'builder' as method name -->
<property name="format" value="(?=^[a-z][a-zA-Z0-9]*$)(?!^(?i)builder$)"/>
<!-- allow the name on private methods -->
<property name="applyToPrivate" value="false"/>
</module>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.data.appconfiguration;

import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.implementation.annotation.ServiceClientBuilder;
import com.azure.core.util.logging.ClientLogger;
import com.azure.data.appconfiguration.credentials.ConfigurationClientCredentials;
Expand Down Expand Up @@ -165,7 +166,7 @@ public ConfigurationAsyncClient buildAsyncClient() {
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogDetailLevel));

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 @@ -4,6 +4,7 @@
package com.azure.data.appconfiguration;

import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.rest.Response;
import com.azure.core.test.models.RecordedData;
import com.azure.core.test.policy.RecordNetworkCallPolicy;
Expand Down Expand Up @@ -34,7 +35,7 @@ public ConfigurationClient createAsyncConfigurationClientWithPipeline() {
String connectionString = getConnectionString();
// BEGIN: com.azure.data.applicationconfig.configurationclient.pipeline.instantiation
RecordedData networkData = new RecordedData();
HttpPipeline pipeline = HttpPipeline.builder().policies(new RecordNetworkCallPolicy(networkData)).build();
HttpPipeline pipeline = new HttpPipelineBuilder().policies(new RecordNetworkCallPolicy(networkData)).build();

ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.pipeline(pipeline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
Expand Down Expand Up @@ -189,7 +190,7 @@ public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface, Http
policies.add(credentialsPolicy);
}

return HttpPipeline.builder()
return new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.core.management;

import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.implementation.annotation.BodyParam;
import com.azure.core.implementation.annotation.Delete;
import com.azure.core.implementation.annotation.ExpectedResponses;
Expand Down Expand Up @@ -764,7 +765,7 @@ public void service18GetStatus500WithExpectedResponse500() {
}

private <T> T createService(Class<T> serviceClass) {
HttpPipeline pipeline = HttpPipeline.builder()
HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(createHttpClient())
.build();
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.core.management.implementation;

import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.implementation.annotation.Delete;
import com.azure.core.implementation.annotation.ExpectedResponses;
import com.azure.core.implementation.annotation.Get;
Expand Down Expand Up @@ -851,7 +852,7 @@ public Mono<HttpResponse> send(HttpRequest request) {
}

private static <T> T createMockService(Class<T> serviceClass, MockAzureHttpClient httpClient) {
HttpPipeline pipeline = HttpPipeline.builder()
HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(httpClient)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

package com.azure.core.http;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializable;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
Expand All @@ -17,7 +11,7 @@
/**
* A collection of headers on an HTTP request or response.
*/
public class HttpHeaders implements Iterable<HttpHeader>, JsonSerializable {
public class HttpHeaders implements Iterable<HttpHeader> {
private final Map<String, HttpHeader> headers = new HashMap<>();

/**
Expand Down Expand Up @@ -128,14 +122,4 @@ public Map<String, String> toMap() {
public Iterator<HttpHeader> iterator() {
return headers.values().iterator();
}

@Override
public void serialize(JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeObject(toMap());
}

@Override
public void serializeWithType(JsonGenerator jsonGenerator, SerializerProvider serializerProvider, TypeSerializer typeSerializer) throws IOException {
serialize(jsonGenerator, serializerProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ public final class HttpPipeline {
private final HttpPipelinePolicy[] pipelinePolicies;


/**
* Creates a builder that can configure options for the HttpPipeline before creating an instance of it.
*
* @return A new {@link HttpPipelineBuilder} to create a HttpPipeline from.
*/
public static HttpPipelineBuilder builder() {
return new HttpPipelineBuilder();
}

/**
* Creates a HttpPipeline holding array of policies that gets applied to all request initiated through
* {@link HttpPipeline#send(HttpPipelineCallContext)} and it's response.
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 All @@ -41,7 +41,12 @@ public class HttpPipelineBuilder {
private List<HttpPipelinePolicy> pipelinePolicies;


HttpPipelineBuilder() {
/**
- * Creates a builder that can configure options for the HttpPipeline before creating an instance of it.
- *
- * @return A new {@link HttpPipelineBuilder} to create a HttpPipeline from.
*/
public HttpPipelineBuilder() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
Expand Down Expand Up @@ -624,7 +625,7 @@ public static HttpPipeline createDefaultPipeline(HttpPipelinePolicy credentialsP
policies.add(credentialsPolicy);
}

return HttpPipeline.builder()
return new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.core.implementation.serializer.jackson;

import com.azure.core.http.HttpHeaders;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.module.SimpleModule;

import java.io.IOException;

/**
* Custom serializer for serializing {@code HttpHeaders} objects into Base64 strings.
*/
final class HttpHeadersSerializer extends JsonSerializer<HttpHeaders> {
/**
* Gets a module wrapping this serializer as an adapter for the Jackson
* ObjectMapper.
*
* @return a simple module to be plugged onto Jackson ObjectMapper.
*/
public static SimpleModule getModule() {
SimpleModule module = new SimpleModule();
module.addSerializer(HttpHeaders.class, new HttpHeadersSerializer());
return module;
}

@Override
public void serialize(HttpHeaders value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeObject(value.toMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ private static <T extends ObjectMapper> T initializeObjectMapper(T mapper) {
.registerModule(Base64UrlSerializer.getModule())
.registerModule(DateTimeSerializer.getModule())
.registerModule(DateTimeRfc1123Serializer.getModule())
.registerModule(DurationSerializer.getModule());
.registerModule(DurationSerializer.getModule())
.registerModule(HttpHeadersSerializer.getModule());
mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.core.implementation.util;

import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
Expand Down Expand Up @@ -199,6 +200,16 @@ public static <T> Mono<T> withContext(Function<Context, Mono<T>> serviceCall) {
.flatMap(serviceCall);
}

/**
* Converts the incoming content to Mono.
*
* @param response whose {@link Response#value() value} is to be converted
* @return The converted {@link Mono}
*/
public static <T> Mono<T> toMono(Response<T> response) {
return Mono.justOrEmpty(response.value());
}

/**
* This method converts the incoming {@code subscriberContext} from {@link reactor.util.context.Context Reactor
* Context} to {@link Context Azure Context} and calls the given lambda function with this context and returns a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

package com.azure.core.implementation.util;

import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -54,4 +57,33 @@ private Mono<String> serviceCallReturnsSingle(String prefix, Context context) {
return Mono.empty();
}

/**
* Implementation not provided
* @param value The value
* @return A {@link Mono} containing a {@link Response} containing a {@link Response#value() value}.
*/
private <T> Mono<Response<T>> getMonoRestResponse(T value) {
Response<T> response = new Response<T>() {
@Override
public int statusCode() {
return 200;
}

@Override
public HttpHeaders headers() {
return null;
}

@Override
public HttpRequest request() {
return null;
}

@Override
public T value() {
return value;
}
};
return Mono.just(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.MockHttpClient;
import com.azure.core.http.MockHttpResponse;
Expand All @@ -19,7 +20,7 @@
public class UserAgentTests {
@Test
public void defaultUserAgentTests() throws Exception {
final HttpPipeline pipeline = HttpPipeline.builder()
final HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(new MockHttpClient() {
@Override
public Mono<HttpResponse> send(HttpRequest request) {
Expand All @@ -40,7 +41,7 @@ public Mono<HttpResponse> send(HttpRequest request) {

@Test
public void customUserAgentTests() throws Exception {
final HttpPipeline pipeline = HttpPipeline.builder()
final HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(new MockHttpClient() {
@Override
public Mono<HttpResponse> send(HttpRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.MockHttpClient;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
Expand All @@ -28,7 +29,7 @@ public void basicCredentialsTest() throws Exception {
return next.process();
};
//
final HttpPipeline pipeline = HttpPipeline.builder()
final HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(new MockHttpClient())
.policies((context, next) -> credentials.getToken("scope./default")
.flatMap(token -> {
Expand Down Expand Up @@ -56,7 +57,7 @@ public Mono<AccessToken> getToken(String... scopes) {
return next.process();
};

final HttpPipeline pipeline = HttpPipeline.builder()
final HttpPipeline pipeline = new HttpPipelineBuilder()
.httpClient(new MockHttpClient())
.policies(new BearerTokenAuthenticationPolicy(credentials, "scope./default"), auditorPolicy)
.build();
Expand Down
Loading