public class RestProxy extends Object implements InvocationHandler
| Constructor and Description |
|---|
RestProxy(HttpPipeline httpPipeline,
SerializerAdapter<?> serializer,
SwaggerInterfaceParser interfaceParser)
Create a new instance of RestProxy.
|
| Modifier and Type | Method and Description |
|---|---|
static <A> A |
create(Class<A> swaggerInterface)
Create a proxy implementation of the provided Swagger interface.
|
static <A> A |
create(Class<A> swaggerInterface,
HttpPipeline httpPipeline)
Create a proxy implementation of the provided Swagger interface.
|
static <A> A |
create(Class<A> swaggerInterface,
HttpPipeline httpPipeline,
SerializerAdapter<?> serializer)
Create a proxy implementation of the provided Swagger interface.
|
static <A> A |
create(Class<A> swaggerInterface,
ServiceClient serviceClient)
Create a proxy implementation of the provided Swagger interface.
|
static HttpPipeline |
createDefaultPipeline()
Create the default HttpPipeline.
|
static HttpPipeline |
createDefaultPipeline(RequestPolicyFactory credentialsPolicy)
Create the default HttpPipeline.
|
static HttpPipeline |
createDefaultPipeline(ServiceClientCredentials credentials)
Create the default HttpPipeline.
|
static SerializerAdapter<?> |
createDefaultSerializer()
Create an instance of the default serializer.
|
io.reactivex.Single<HttpResponse> |
ensureExpectedStatus(HttpResponse response,
SwaggerMethodParser methodParser,
int[] additionalAllowedStatusCodes)
Ensure that the provided HttpResponse has a status code that is defined in the provided
SwaggerMethodParser or is in the int[] of additional allowed status codes.
|
Constructor<? extends RestResponse<?,?>> |
getRestResponseConstructor(Type entityType) |
protected Object |
handleAsyncHttpResponse(HttpRequest httpRequest,
io.reactivex.Single<HttpResponse> asyncHttpResponse,
SwaggerMethodParser methodParser,
Type returnType) |
protected io.reactivex.Maybe<?> |
handleBodyReturnTypeAsync(HttpResponse response,
SwaggerMethodParser methodParser,
Type entityType) |
Object |
handleRestReturnType(HttpRequest httpRequest,
io.reactivex.Single<HttpResponse> asyncHttpResponse,
SwaggerMethodParser methodParser,
Type returnType)
Handle the provided asynchronous HTTP response and return the deserialized value.
|
protected Object |
handleResumeOperation(HttpRequest httpRequest,
OperationDescription operationDescription,
SwaggerMethodParser methodParser,
Type returnType) |
Object |
invoke(Object proxy,
Method method,
Object[] args) |
io.reactivex.Single<HttpResponse> |
sendHttpRequestAsync(HttpRequest request)
Send the provided request asynchronously, applying any request policies provided to the HttpClient instance.
|
SerializerAdapter<?> |
serializer()
Get the SerializerAdapter used by this RestProxy.
|
public RestProxy(HttpPipeline httpPipeline, SerializerAdapter<?> serializer, SwaggerInterfaceParser interfaceParser)
httpPipeline - The RequestPolicy and HttpClient httpPipeline that will be used to send HTTP
requests.serializer - The serializer that will be used to convert response bodies to POJOs.interfaceParser - The parser that contains information about the swagger interface that
this RestProxy "implements".public SerializerAdapter<?> serializer()
public io.reactivex.Single<HttpResponse> sendHttpRequestAsync(HttpRequest request)
request - The HTTP request to send.Single representing the HTTP response that will arrive asynchronously.public Object invoke(Object proxy, Method method, Object[] args)
invoke in interface InvocationHandlerpublic io.reactivex.Single<HttpResponse> ensureExpectedStatus(HttpResponse response, SwaggerMethodParser methodParser, int[] additionalAllowedStatusCodes)
response - The HttpResponse to check.methodParser - The method parser that contains information about the service interface
method that initiated the HTTP request.additionalAllowedStatusCodes - Additional allowed status codes that are permitted based
on the context of the HTTP request.public Constructor<? extends RestResponse<?,?>> getRestResponseConstructor(Type entityType)
entityType - the RestResponse subtype to get a constructor for.protected final io.reactivex.Maybe<?> handleBodyReturnTypeAsync(HttpResponse response, SwaggerMethodParser methodParser, Type entityType)
protected Object handleAsyncHttpResponse(HttpRequest httpRequest, io.reactivex.Single<HttpResponse> asyncHttpResponse, SwaggerMethodParser methodParser, Type returnType)
protected Object handleResumeOperation(HttpRequest httpRequest, OperationDescription operationDescription, SwaggerMethodParser methodParser, Type returnType) throws Exception
Exceptionpublic final Object handleRestReturnType(HttpRequest httpRequest, io.reactivex.Single<HttpResponse> asyncHttpResponse, SwaggerMethodParser methodParser, Type returnType)
httpRequest - The original HTTP request.asyncHttpResponse - The asynchronous HTTP response to the original HTTP request.methodParser - The SwaggerMethodParser that the request originates from.returnType - The type of value that will be returned.public static SerializerAdapter<?> createDefaultSerializer()
public static HttpPipeline createDefaultPipeline()
public static HttpPipeline createDefaultPipeline(ServiceClientCredentials credentials)
credentials - The credentials to use to apply authentication to the pipeline.public static HttpPipeline createDefaultPipeline(RequestPolicyFactory credentialsPolicy)
credentialsPolicy - The credentials policy factory to use to apply authentication to the
pipeline.public static <A> A create(Class<A> swaggerInterface)
A - The type of the Swagger interface.swaggerInterface - The Swagger interface to provide a proxy implementation for.public static <A> A create(Class<A> swaggerInterface, HttpPipeline httpPipeline)
A - The type of the Swagger interface.swaggerInterface - The Swagger interface to provide a proxy implementation for.httpPipeline - The RequestPolicy and HttpClient pipline that will be used to send Http
requests.public static <A> A create(Class<A> swaggerInterface, ServiceClient serviceClient)
A - The type of the Swagger interface.swaggerInterface - The Swagger interface to provide a proxy implementation for.serviceClient - The ServiceClient that contains the details to use to create the
RestProxy implementation of the swagger interface.public static <A> A create(Class<A> swaggerInterface, HttpPipeline httpPipeline, SerializerAdapter<?> serializer)
A - The type of the Swagger interface.swaggerInterface - The Swagger interface to provide a proxy implementation for.httpPipeline - The RequestPolicy and HttpClient pipline that will be used to send Http
requests.serializer - The serializer that will be used to convert POJOs to and from request and
response bodies./**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/