Skip to content

Commit

Permalink
Add a RestProxy.create() overload that takes a ServiceClient parameter (
Browse files Browse the repository at this point in the history
Azure#332)

* Add a RestProxy.create() overload that takes a ServiceClient parameter

* Rename AzureProxy.defaultPipeline() to AzureProxy.createDefaultPipeline()
  • Loading branch information
Dan Schulte authored Dec 22, 2017
1 parent ec1d82e commit 3c7587e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ private static <T> String getDefaultUserAgentString(Class<?> swaggerInterface) {
* string.
* @return the default HttpPipeline.
*/
public static HttpPipeline defaultPipeline(Class<?> swaggerInterface) {
return defaultPipeline(swaggerInterface, (RequestPolicyFactory) null);
public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface) {
return createDefaultPipeline(swaggerInterface, (RequestPolicyFactory) null);
}

/**
Expand All @@ -154,8 +154,8 @@ public static HttpPipeline defaultPipeline(Class<?> swaggerInterface) {
* @param credentials The credentials to use to apply authentication to the pipeline.
* @return the default HttpPipeline.
*/
public static HttpPipeline defaultPipeline(Class<?> swaggerInterface, ServiceClientCredentials credentials) {
return defaultPipeline(swaggerInterface, new CredentialsPolicy.Factory(credentials));
public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface, ServiceClientCredentials credentials) {
return createDefaultPipeline(swaggerInterface, new CredentialsPolicy.Factory(credentials));
}

/**
Expand All @@ -166,7 +166,7 @@ public static HttpPipeline defaultPipeline(Class<?> swaggerInterface, ServiceCli
* pipeline.
* @return the default HttpPipeline.
*/
public static HttpPipeline defaultPipeline(Class<?> swaggerInterface, RequestPolicyFactory credentialsPolicy) {
public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface, RequestPolicyFactory credentialsPolicy) {
final HttpClient httpClient = new NettyClient.Factory().create(null);
final HttpPipelineBuilder builder = new HttpPipelineBuilder().withHttpClient(httpClient);
builder.withUserAgent(getDefaultUserAgentString(swaggerInterface));
Expand Down
13 changes: 13 additions & 0 deletions client-runtime/src/main/java/com/microsoft/rest/v2/RestProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,19 @@ public static <A> A create(Class<A> swaggerInterface, HttpPipeline httpPipeline)
return create(swaggerInterface, httpPipeline, createDefaultSerializer());
}

/**
* Create a proxy implementation of the provided Swagger interface.
* @param swaggerInterface The Swagger interface to provide a proxy implementation for.
* @param serviceClient The ServiceClient that contains the details to use to create the
* RestProxy implementation of the swagger interface.
* @param <A> The type of the Swagger interface.
* @return A proxy implementation of the provided Swagger interface.
*/
@SuppressWarnings("unchecked")
public static <A> A create(Class<A> swaggerInterface, ServiceClient serviceClient) {
return create(swaggerInterface, serviceClient.httpPipeline(), serviceClient.serializerAdapter());
}

/**
* Create a proxy implementation of the provided Swagger interface.
* @param swaggerInterface The Swagger interface to provide a proxy implementation for.
Expand Down

0 comments on commit 3c7587e

Please sign in to comment.