/** * Get the SwaggerMethodParser for the provided method. The Method must exist on the Swagger * interface that this RestProxy was created to "implement". * @param method The method to get a SwaggerMethodParser for. * @return The SwaggerMethodParser for the provided method. */ private SwaggerMethodParser methodParser(Method method) { return interfaceParser.methodParser(method); }
/** * Create a proxy implementation of the provided Swagger interface. * @param swaggerInterface The Swagger interface to provide a proxy implementation for. * @param httpPipeline The RequestPolicy and HttpClient pipline that will be used to send Http * requests. * @param serializer The serializer that will be used to convert POJOs to and from request and * response bodies. * @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, HttpPipeline httpPipeline, SerializerAdapter<?> serializer) { final SwaggerInterfaceParser interfaceParser = new SwaggerInterfaceParser(swaggerInterface, serializer); final RestProxy restProxy = new RestProxy(httpPipeline, serializer, interfaceParser); return (A) Proxy.newProxyInstance(swaggerInterface.getClassLoader(), new Class[]{swaggerInterface}, restProxy); } }
/** * Get the method parser that is associated with the provided swaggerMethod. The method parser * can be used to get details about the Swagger REST API call. * @param swaggerMethod The method to generate a parser for. * @return The SwaggerMethodParser associated with the provided swaggerMethod. */ public SwaggerMethodParser methodParser(Method swaggerMethod) { SwaggerMethodParser result = methodParsers.get(swaggerMethod); if (result == null) { result = new SwaggerMethodParser(swaggerMethod, serializer, host()); methodParsers.put(swaggerMethod, result); } return result; }
/** * Create a proxy implementation of the provided Swagger interface. * @param swaggerInterface The Swagger interface to provide a proxy implementation for. * @param azureEnvironment The azure environment that the proxy implementation will target. * @param httpPipeline The HTTP httpPipeline will be used to make REST calls. * @param serializer The serializer that will be used to convert POJOs to and from request and * response bodies. * @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, AzureEnvironment azureEnvironment, HttpPipeline httpPipeline, SerializerAdapter<?> serializer) { String baseUrl = null; if (azureEnvironment != null) { final AzureHost azureHost = swaggerInterface.getAnnotation(AzureHost.class); if (azureHost != null) { baseUrl = azureEnvironment.url(azureHost.endpoint()); } } final SwaggerInterfaceParser interfaceParser = new SwaggerInterfaceParser(swaggerInterface, serializer, baseUrl); final AzureProxy azureProxy = new AzureProxy(httpPipeline, serializer, interfaceParser); return (A) Proxy.newProxyInstance(swaggerInterface.getClassLoader(), new Class[]{swaggerInterface}, azureProxy); }