Class ApiClient
This class can be constructed and modified, then used to instantiate the various API classes. The API classes use the settings in this class to configure themselves, but otherwise do not store a link to this class.
This class is mutable and not synchronized, so it is not thread-safe. The API classes generated from this are immutable and thread-safe.
The setter methods of this class return the current object to facilitate a fluent style of configuration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Consumer<HttpResponse<InputStream>> Deprecated.protected StringDeprecated.protected HttpClient.BuilderDeprecated.protected DurationDeprecated.protected StringDeprecated.protected Consumer<HttpRequest.Builder> Deprecated.protected com.fasterxml.jackson.databind.ObjectMapperDeprecated.protected intDeprecated.protected DurationDeprecated.protected Consumer<HttpResponse<InputStream>> Deprecated.protected StringDeprecated. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Create an instance of ApiClient.ApiClient(HttpClient.Builder builder, com.fasterxml.jackson.databind.ObjectMapper mapper, String baseUri) Deprecated.Create an instance of ApiClient. -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpClient.BuilderDeprecated.static com.fasterxml.jackson.databind.ObjectMapperDeprecated.Deprecated.Get the custom async response interceptor.Deprecated.Get the base URI to resolve the endpoint paths against.Deprecated.Get connection timeout (in milliseconds).protected final StringDeprecated.Deprecated.Get anHttpClientbased on the currentHttpClient.Builder.com.fasterxml.jackson.databind.ObjectMapperDeprecated.Get a copy of the currentObjectMapper.Deprecated.Get the read timeout that was set.Deprecated.Get the custom interceptor.static InputStreamgetResponseBody(HttpResponse<InputStream> response) Deprecated.Returns the response body InputStream, transparently decoding gzip-compressed payloads when the server setsContent-Encoding: gzip.Deprecated.Get the custom response interceptor.parameterToPairs(String name, Object value) Deprecated.Convert a URL query name/value parameter to a list of encodedPairobjects.parameterToPairs(String collectionFormat, String name, Collection<?> values) Deprecated.Convert a URL query name/collection parameter to a list of encodedPairobjects.setAsyncResponseInterceptor(Consumer<HttpResponse<InputStream>> interceptor) Deprecated.Set a custom async response interceptor.setBasePath(String basePath) Deprecated.Set a custom base path for the target service, for example '/v2'.setConnectTimeout(Duration connectTimeout) Deprecated.Sets the connect timeout (in milliseconds) for the http client.Deprecated.Set a custom host name for the target service.setHttpClientBuilder(HttpClient.Builder builder) Deprecated.Set a customHttpClient.Builderobject to use when creating theHttpClientthat is used by the API client.setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) Deprecated.Set a customObjectMapperto serialize and deserialize the request and response bodies.setPort(int port) Deprecated.Set a custom port number for the target service.setReadTimeout(Duration readTimeout) Deprecated.Set the read timeout for the http client.setRequestInterceptor(Consumer<HttpRequest.Builder> interceptor) Deprecated.Set a custom request interceptor.setResponseInterceptor(Consumer<HttpResponse<InputStream>> interceptor) Deprecated.Set a custom response interceptor.Deprecated.Set a custom scheme for the target service, for example 'https'.final voidupdateBaseUri(String baseUri) Deprecated.static StringDeprecated.URL encode a string in the UTF-8 encoding.static StringvalueToString(Object value) Deprecated.
-
Field Details
-
builder
Deprecated. -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapperDeprecated. -
scheme
Deprecated. -
host
Deprecated. -
port
protected int portDeprecated. -
basePath
Deprecated. -
interceptor
Deprecated. -
responseInterceptor
Deprecated. -
asyncResponseInterceptor
Deprecated. -
readTimeout
Deprecated. -
connectTimeout
Deprecated.
-
-
Constructor Details
-
ApiClient
public ApiClient()Deprecated.Create an instance of ApiClient. -
ApiClient
public ApiClient(HttpClient.Builder builder, com.fasterxml.jackson.databind.ObjectMapper mapper, String baseUri) Deprecated.Create an instance of ApiClient.- Parameters:
builder- Http client builder.mapper- Object mapper.baseUri- Base URI
-
-
Method Details
-
valueToString
-
urlEncode
-
parameterToPairs
Deprecated.Convert a URL query name/value parameter to a list of encodedPairobjects.The value can be null, in which case an empty list is returned.
- Parameters:
name- The query name parameter.value- The query value, which may not be a collection but may be null.- Returns:
- A singleton list of the
Pairobjects representing the input parameters, which is encoded for use in a URL. If the value is null, an empty list is returned.
-
parameterToPairs
public static List<Pair> parameterToPairs(String collectionFormat, String name, Collection<?> values) Deprecated.Convert a URL query name/collection parameter to a list of encodedPairobjects.- Parameters:
collectionFormat- The swagger collectionFormat string (csv, tsv, etc).name- The query name parameter.values- A collection of values for the given query name, which may be null.- Returns:
- A list of
Pairobjects representing the input parameters, which is encoded for use in a URL. If the values collection is null, an empty list is returned.
-
createDefaultObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper createDefaultObjectMapper()Deprecated. -
getDefaultBaseUri
Deprecated. -
createDefaultHttpClientBuilder
Deprecated. -
updateBaseUri
Deprecated. -
setHttpClientBuilder
Deprecated.Set a customHttpClient.Builderobject to use when creating theHttpClientthat is used by the API client.- Parameters:
builder- Custom client builder.- Returns:
- This object.
-
getHttpClient
Deprecated.Get anHttpClientbased on the currentHttpClient.Builder.The returned object is immutable and thread-safe.
- Returns:
- The HTTP client.
-
setObjectMapper
Deprecated.Set a customObjectMapperto serialize and deserialize the request and response bodies.- Parameters:
mapper- Custom object mapper.- Returns:
- This object.
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Deprecated.Get a copy of the currentObjectMapper.- Returns:
- A copy of the current object mapper.
-
setHost
-
setPort
Deprecated.Set a custom port number for the target service.- Parameters:
port- The port of the target service. Set this to -1 to reset the value to the default for the scheme.- Returns:
- This object.
-
setBasePath
-
getBaseUri
Deprecated.Get the base URI to resolve the endpoint paths against.- Returns:
- The complete base URI that the rest of the API parameters are resolved against.
-
setScheme
-
setRequestInterceptor
Deprecated.Set a custom request interceptor.A request interceptor is a mechanism for altering each request before it is sent. After the request has been fully configured but not yet built, the request builder is passed into this function for further modification, after which it is sent out.
This is useful for altering the requests in a custom manner, such as adding headers. It could also be used for logging and monitoring.
- Parameters:
interceptor- A function invoked before creating each request. A value of null resets the interceptor to a no-op.- Returns:
- This object.
-
getRequestInterceptor
Deprecated.Get the custom interceptor.- Returns:
- The custom interceptor that was set, or null if there isn't any.
-
setResponseInterceptor
Deprecated.Set a custom response interceptor.This is useful for logging, monitoring or extraction of header variables
- Parameters:
interceptor- A function invoked before creating each request. A value of null resets the interceptor to a no-op.- Returns:
- This object.
-
getResponseInterceptor
Deprecated.Get the custom response interceptor.- Returns:
- The custom interceptor that was set, or null if there isn't any.
-
setAsyncResponseInterceptor
Deprecated.Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'.This is useful for logging, monitoring or extraction of header variables
- Parameters:
interceptor- A function invoked before creating each request. A value of null resets the interceptor to a no-op.- Returns:
- This object.
-
getAsyncResponseInterceptor
Deprecated.Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'.- Returns:
- The custom interceptor that was set, or null if there isn't any.
-
setReadTimeout
Deprecated.Set the read timeout for the http client.This is the value used by default for each request, though it can be overridden on a per-request basis with a request interceptor.
- Parameters:
readTimeout- The read timeout used by default by the http client. Setting this value to null resets the timeout to an effectively infinite value.- Returns:
- This object.
-
getReadTimeout
Deprecated.Get the read timeout that was set.- Returns:
- The read timeout, or null if no timeout was set. Null represents an infinite wait time.
-
setConnectTimeout
Deprecated.Sets the connect timeout (in milliseconds) for the http client.In the case where a new connection needs to be established, if the connection cannot be established within the given
duration, thenHttpClient::sendthrows anHttpConnectTimeoutException, orHttpClient::sendAsynccompletes exceptionally with anHttpConnectTimeoutException. If a new connection does not need to be established, for example if a connection can be reused from a previous request, then this timeout duration has no effect.- Parameters:
connectTimeout- connection timeout in milliseconds- Returns:
- This object.
-
getConnectTimeout
Deprecated.Get connection timeout (in milliseconds).- Returns:
- Timeout in milliseconds
-
getResponseBody
Deprecated.Returns the response body InputStream, transparently decoding gzip-compressed payloads when the server setsContent-Encoding: gzip.- Parameters:
response- HTTP response whose body should be consumed- Returns:
- Original or decompressed InputStream for the response body
- Throws:
IOException- if the response body cannot be accessed or wrapping fails
-