public class ClientBuilder extends Object implements Builder<ApiHttpClient>
The ClientBuilder is used to configure and create an ApiHttpClient. As the ApiHttpClient uses a stack
of middlewares the Builder comes with methods to configure and attach new middlewares. Also it ensures that some default
used middlewares are instantiated at the correct location in the middleware stack.
The default middlewares and services are added as Supplier to be able to override the ones provided by e.g.: defaultClient(URI)
| Modifier and Type | Field and Description |
|---|---|
static String |
COMMERCETOOLS |
| Modifier and Type | Method and Description |
|---|---|
ClientBuilder |
addAcceptGZipMiddleware()
add middleware to inject an Accept: gzip header
|
ClientBuilder |
addCorrelationIdProvider(CorrelationIdProvider correlationIdProvider) |
ClientBuilder |
addCorrelationIdProvider(CorrelationIdProvider correlationIdProvider,
boolean replace) |
ClientBuilder |
addMiddleware(Middleware middleware,
Middleware... middlewares)
adds the middlewares to be configured for the client.
|
ClientBuilder |
addMiddlewares(List<Middleware> middlewares)
adds the middlewares to be configured for the client.
|
ClientBuilder |
addNotFoundExceptionMiddleware()
add Middleware to convert a
NotFoundException to a response with a null body value |
ClientBuilder |
addNotFoundExceptionMiddleware(NotFoundExceptionMiddleware exceptionMiddleware)
add Middleware to convert a
NotFoundException to a response with a null body value |
ClientBuilder |
addNotFoundExceptionMiddleware(Predicate<ApiHttpRequest> requestPredicate)
add Middleware to convert a
NotFoundException to a response with a null body value |
ClientBuilder |
addNotFoundExceptionMiddleware(Set<ApiHttpMethod> methods)
add Middleware to convert a
NotFoundException to a response with a null body value |
ApiHttpClient |
build()
build the
ApiHttpClient with the configured values |
static String |
buildDefaultUserAgent()
default user agent provider
|
ClientBuilder |
defaultClient(ClientCredentials credentials,
ServiceRegionConfig serviceRegionConfig)
Configures a client with the default middlewares and the given baseUrl
|
ClientBuilder |
defaultClient(String apiBaseUrl)
Configures a client with the default middlewares and the given baseUrl
|
ClientBuilder |
defaultClient(String apiBaseUrl,
ClientCredentials credentials,
String tokenEndpoint)
Configures a client with the default middlewares and the given baseUrl
|
ClientBuilder |
defaultClient(URI apiBaseUrl)
Configures a client with the default middlewares and the given baseUrl
|
static ClientBuilder |
of()
Creates a default client builder
|
static ClientBuilder |
of(ApiHttpClient httpClient)
Creates a client builder with a specific or preconfigured
ApiHttpClient instance. |
static ClientBuilder |
of(ExecutorService httpClientExecutorService) |
static ClientBuilder |
of(HandlerStack stack)
Creates a client builder with a specifig
HandlerStack |
static ClientBuilder |
of(VrapHttpClient httpClient)
Creates a client builder with a specific or preconfigured
VrapHttpClient instance. |
ClientBuilder |
withAnonymousRefreshFlow(ClientCredentials credentials,
String anonTokenEndpoint,
String refreshTokenEndpoint,
TokenStorage storage)
configure the client to use anonymous & refresh token flow
|
ClientBuilder |
withAnonymousRefreshFlow(ClientCredentials credentials,
String anonTokenEndpoint,
String refreshTokenEndpoint,
TokenStorage storage,
Supplier<HandlerStack> httpClientSupplier)
configure the client to use anonymous & refresh token flow
|
ClientBuilder |
withAnonymousRefreshFlow(ClientCredentials credentials,
String anonTokenEndpoint,
String refreshTokenEndpoint,
TokenStorage storage,
VrapHttpClient httpClient)
configure the client to use anonymous & refresh token flow
|
ClientBuilder |
withAnonymousSessionFlow(ClientCredentials credentials,
String tokenEndpoint)
configure the client to use anonymous session flow
|
ClientBuilder |
withAnonymousSessionFlow(ClientCredentials credentials,
String tokenEndpoint,
Supplier<HandlerStack> httpClientSupplier)
configure the client to use anonymous session flow
|
ClientBuilder |
withAnonymousSessionFlow(ClientCredentials credentials,
String tokenEndpoint,
VrapHttpClient httpClient)
configure the client to use anonymous session flow
|
ClientBuilder |
withApiBaseUrl(String apiBaseUrl) |
ClientBuilder |
withApiBaseUrl(URI apiBaseUrl) |
ClientBuilder |
withAuthCircuitBreaker()
activates the circuit breaker for authentication.
|
ClientBuilder |
withAuthRetries(int authRetries) |
ClientBuilder |
withClientCredentials(ClientCredentials credentials,
String tokenEndpoint)
Deprecated.
|
ClientBuilder |
withClientCredentials(ClientCredentials credentials,
String tokenEndpoint,
VrapHttpClient httpClient)
Deprecated.
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
String tokenEndpoint)
configure the client to use client credentials flow
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
String tokenEndpoint,
Supplier<HandlerStack> httpClientSupplier)
configure the client to use client credentials flow
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
String tokenEndpoint,
VrapHttpClient httpClient)
configure the client to use client credentials flow
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
URI tokenEndpoint)
configure the client to use client credentials flow
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
URI tokenEndpoint,
Supplier<HandlerStack> httpClientSupplier)
configure the client to use client credentials flow
|
ClientBuilder |
withClientCredentialsFlow(ClientCredentials credentials,
URI tokenEndpoint,
VrapHttpClient httpClient)
configure the client to use client credentials flow
|
ClientBuilder |
withErrorMiddleware()
add middleware to create Exceptions for responses with error status code
|
ClientBuilder |
withErrorMiddleware(ErrorMiddleware.ExceptionMode exceptionMode)
add middleware to create Exceptions for responses with error status code
|
ClientBuilder |
withErrorMiddleware(ErrorMiddleware errorMiddleware)
add middleware to create Exceptions for responses with error status code
|
ClientBuilder |
withErrorMiddleware(Supplier<ErrorMiddleware> errorMiddleware)
add middleware to create Exceptions for responses with error status code
|
ClientBuilder |
withGlobalCustomerPasswordFlow(ClientCredentials credentials,
String email,
String password,
String tokenEndpoint)
configure the client to use password flow
|
ClientBuilder |
withGlobalCustomerPasswordFlow(ClientCredentials credentials,
String email,
String password,
String tokenEndpoint,
Supplier<HandlerStack> httpClientSupplier)
configure the client to use password flow
|
ClientBuilder |
withGlobalCustomerPasswordFlow(ClientCredentials credentials,
String email,
String password,
String tokenEndpoint,
VrapHttpClient httpClient)
configure the client to use password flow
|
ClientBuilder |
withHandlerStack(HandlerStack stack) |
ClientBuilder |
withHttpClient(VrapHttpClient httpClient) |
ClientBuilder |
withHttpExceptionFactory(Function<ResponseSerializer,HttpExceptionFactory> factory) |
ClientBuilder |
withHttpExceptionFactory(HttpExceptionFactory factory) |
ClientBuilder |
withHttpExceptionFactory(Supplier<HttpExceptionFactory> factory)
configures the Factory for HTTP exception in case.
|
ClientBuilder |
withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory) |
ClientBuilder |
withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory,
org.slf4j.event.Level responseLogEvent,
org.slf4j.event.Level deprecationLogEvent) |
ClientBuilder |
withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory,
org.slf4j.event.Level responseLogEvent,
org.slf4j.event.Level deprecationLogEvent,
org.slf4j.event.Level defaultExceptionLogEvent,
Map<Class<? extends Throwable>,org.slf4j.event.Level> exceptionLogEvents) |
ClientBuilder |
withInternalLoggerMiddleware(InternalLoggerMiddleware internalLoggerMiddleware) |
ClientBuilder |
withMiddleware(Middleware middleware,
Middleware... middlewares)
sets the middlewares to be configured for the client.
|
ClientBuilder |
withMiddlewares(List<Middleware> middlewares)
sets the middlewares to be configured for the client.
|
ClientBuilder |
withOAuthExecutorService(ExecutorService executorService)
configures an ExecutorService to be used for the Middlewares
|
ClientBuilder |
withOAuthExecutorService(Supplier<ExecutorService> executorService)
configures an ExecutorService to be used for the Middlewares
|
ClientBuilder |
withOAuthHttpClient(VrapHttpClient httpClient) |
ClientBuilder |
withOAuthMiddleware(OAuthMiddleware oAuthMiddleware)
add authenticator middleware
|
ClientBuilder |
withOAuthMiddleware(Supplier<OAuthMiddleware> oAuthMiddleware)
add authenticator middleware
|
ClientBuilder |
withoutAuthCircuitBreaker()
deactivates the circuit breaker for authentication
|
ClientBuilder |
withQueueMiddleware(ExecutorService executorService,
int maxRequests,
Duration maxWaitTime)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withQueueMiddleware(int maxRequests,
Duration maxWaitTime)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withQueueMiddleware(QueueRequestMiddleware queueMiddleware)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withQueueMiddleware(ScheduledExecutorService executorService,
int maxRequests,
Duration maxWaitTime)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withQueueMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRequests,
Duration maxWaitTime)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withQueueMiddleware(Supplier<QueueRequestMiddleware> queueMiddleware)
add middleware to limit the concurrent requests to be executed
|
ClientBuilder |
withRetryMiddleware(ExecutorService executorService,
int maxRetries)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ExecutorService executorService,
int maxRetries,
List<Integer> statusCodes)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ExecutorService executorService,
int maxRetries,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ExecutorService executorService,
int maxRetries,
long delay,
long maxDelay,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ExecutorService executorService,
int maxRetries,
long delay,
long maxDelay,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(int maxRetries)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(int maxRetries,
List<Integer> statusCodes)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(int maxRetries,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(int maxRetries,
long delay,
long maxDelay,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(int maxRetries,
long delay,
long maxDelay,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(RetryRequestMiddleware retryMiddleware)
add middleware to retry failed requests
|
ClientBuilder |
withRetryMiddleware(ScheduledExecutorService executorService,
int maxRetries)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ScheduledExecutorService executorService,
int maxRetries,
List<Integer> statusCodes)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ScheduledExecutorService executorService,
int maxRetries,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ScheduledExecutorService executorService,
int maxRetries,
long delay,
long maxDelay,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(ScheduledExecutorService executorService,
int maxRetries,
long delay,
long maxDelay,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRetries)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRetries,
List<Integer> statusCodes)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRetries,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRetries,
long delay,
long maxDelay,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler,
int maxRetries,
long delay,
long maxDelay,
List<Integer> statusCodes,
List<Class<? extends Throwable>> failures,
FailsafeRetryPolicyBuilderOptions fn)
add middleware to retry failed requests.
|
ClientBuilder |
withRetryMiddleware(Supplier<RetryRequestMiddleware> retryMiddleware)
add middleware to retry failed requests
|
ClientBuilder |
withSerializer(ResponseSerializer serializer) |
ClientBuilder |
withSerializer(Supplier<ResponseSerializer> serializer) |
ClientBuilder |
withStaticTokenFlow(AuthenticationToken token)
configure the client to use client credentials flow
|
ClientBuilder |
withTelemetryMiddleware(Supplier<TelemetryMiddleware> telemetryMiddleware)
add middleware to collect and report telemetry data
|
ClientBuilder |
withTelemetryMiddleware(TelemetryMiddleware telemetryMiddleware)
add middleware to collect and report telemetry data
|
ClientBuilder |
withTokenSupplier(Supplier<TokenSupplier> tokenSupplier)
use supplier for authentication tokens
|
ClientBuilder |
withTokenSupplier(TokenSupplier tokenSupplier)
use supplier for authentication tokens
|
ClientBuilder |
withUserAgentSupplier(Supplier<String> userAgentSupplier) |
public static final String COMMERCETOOLS
public static ClientBuilder of()
Creates a default client builder
public static ClientBuilder of(ExecutorService httpClientExecutorService)
public static ClientBuilder of(VrapHttpClient httpClient)
Creates a client builder with a specific or preconfigured VrapHttpClient instance. Uses defaults for
the HandlerStack
httpClient - the HTTP client to be usedpublic static ClientBuilder of(ApiHttpClient httpClient)
Creates a client builder with a specific or preconfigured ApiHttpClient instance. Uses defaults for
the HandlerStack
httpClient - the HTTP client to be usedpublic static ClientBuilder of(HandlerStack stack)
Creates a client builder with a specifig HandlerStack
stack - the HandlerStack to be usedpublic ClientBuilder withoutAuthCircuitBreaker()
public ClientBuilder withAuthCircuitBreaker()
public ClientBuilder withAuthRetries(int authRetries)
authRetries - number of retries for authentication before giving up.public ClientBuilder withHandlerStack(HandlerStack stack)
stack - HandlerStack to be used for the HTTP requestspublic ClientBuilder withHttpClient(VrapHttpClient httpClient)
httpClient - VrapHttpClient to be used for the HTTP requestspublic ClientBuilder withOAuthHttpClient(VrapHttpClient httpClient)
httpClient - VrapHttpClient to be used for the OAuth requestspublic ClientBuilder withSerializer(ResponseSerializer serializer)
serializer - ResponseSerializer to be used for de-/serializationpublic ClientBuilder withSerializer(Supplier<ResponseSerializer> serializer)
serializer - ResponseSerializer to be used for de-/serializationpublic ClientBuilder withHttpExceptionFactory(HttpExceptionFactory factory)
factory - HttpExceptionFactory to be used for creating Exceptions based on response status codepublic ClientBuilder withHttpExceptionFactory(Function<ResponseSerializer,HttpExceptionFactory> factory)
factory - function to create HttpExceptionFactory to be used for creating Exceptions based on response
status code with the configured ResponseSerializerpublic ClientBuilder withHttpExceptionFactory(Supplier<HttpExceptionFactory> factory)
factory - HttpExceptionFactory to be used for creating Exceptions based on response status codepublic ClientBuilder withOAuthExecutorService(Supplier<ExecutorService> executorService)
executorService - supplier of the executor service to be usedpublic ClientBuilder withOAuthExecutorService(ExecutorService executorService)
executorService - executor service to be usedpublic ClientBuilder defaultClient(URI apiBaseUrl)
Configures a client with the default middlewares and the given baseUrl
The following middlewares and services are configured:
apiBaseUrl - base URI for the APIpublic ClientBuilder defaultClient(String apiBaseUrl)
Configures a client with the default middlewares and the given baseUrl
The following middlewares and services are configured:
apiBaseUrl - base URI for the APIpublic ClientBuilder defaultClient(String apiBaseUrl, ClientCredentials credentials, String tokenEndpoint)
Configures a client with the default middlewares and the given baseUrl
The following middlewares and services are configured:
apiBaseUrl - base URI for the APIcredentials - ClientCredentials to be usedtokenEndpoint - token endpoint URI to be used for authenticationpublic ClientBuilder defaultClient(ClientCredentials credentials, ServiceRegionConfig serviceRegionConfig)
Configures a client with the default middlewares and the given baseUrl
The following middlewares and services are configured:
credentials - ClientCredentials to be usedserviceRegionConfig - ServiceRegionConfig to be used@Deprecated public ClientBuilder withClientCredentials(ClientCredentials credentials, String tokenEndpoint)
withClientCredentialsFlow(ClientCredentials, String) insteadcredentials - OAuth credentialstokenEndpoint - OAuth endpoint@Deprecated public ClientBuilder withClientCredentials(ClientCredentials credentials, String tokenEndpoint, VrapHttpClient httpClient)
withClientCredentialsFlow(ClientCredentials, String, VrapHttpClient) insteadcredentials - OAuth credentialstokenEndpoint - OAuth endpointhttpClient - HTTP client to be usedpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, URI tokenEndpoint)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, URI tokenEndpoint, Supplier<HandlerStack> httpClientSupplier)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClientSupplier - HandlerStack to use for authenticationpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, URI tokenEndpoint, VrapHttpClient httpClient)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClient - VrapHttpClient to use for authenticationpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, String tokenEndpoint)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, String tokenEndpoint, Supplier<HandlerStack> httpClientSupplier)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClientSupplier - VrapHttpClient to use for authenticationpublic ClientBuilder withClientCredentialsFlow(ClientCredentials credentials, String tokenEndpoint, VrapHttpClient httpClient)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClient - VrapHttpClient to use for authenticationpublic ClientBuilder withStaticTokenFlow(AuthenticationToken token)
token - AuthenticationToken to be used requestspublic ClientBuilder withAnonymousSessionFlow(ClientCredentials credentials, String tokenEndpoint)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationpublic ClientBuilder withAnonymousSessionFlow(ClientCredentials credentials, String tokenEndpoint, Supplier<HandlerStack> httpClientSupplier)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClientSupplier - HandlerStack to use for authenticationpublic ClientBuilder withAnonymousSessionFlow(ClientCredentials credentials, String tokenEndpoint, VrapHttpClient httpClient)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for authenticationhttpClient - VrapHttpClient to use for authenticationpublic ClientBuilder withAnonymousRefreshFlow(ClientCredentials credentials, String anonTokenEndpoint, String refreshTokenEndpoint, TokenStorage storage)
credentials - ClientCredentials to be used for authenticationanonTokenEndpoint - URI to be used for anonymous token authenticationrefreshTokenEndpoint - URI to be used for refresh token authenticationstorage - TokenStorage for the authentication tokenspublic ClientBuilder withAnonymousRefreshFlow(ClientCredentials credentials, String anonTokenEndpoint, String refreshTokenEndpoint, TokenStorage storage, Supplier<HandlerStack> httpClientSupplier)
credentials - ClientCredentials to be used for authenticationanonTokenEndpoint - URI to be used for anonymous token authenticationrefreshTokenEndpoint - URI to be used for refresh token authenticationstorage - TokenStorage for the authentication tokenshttpClientSupplier - HandlerStack to be used for authenticationpublic ClientBuilder withAnonymousRefreshFlow(ClientCredentials credentials, String anonTokenEndpoint, String refreshTokenEndpoint, TokenStorage storage, VrapHttpClient httpClient)
credentials - ClientCredentials to be used for authenticationanonTokenEndpoint - URI to be used for anonymous token authenticationrefreshTokenEndpoint - URI to be used for refresh token authenticationstorage - TokenStorage for the authentication tokenshttpClient - VrapHttpClient to be used for authenticationpublic ClientBuilder withGlobalCustomerPasswordFlow(ClientCredentials credentials, String email, String password, String tokenEndpoint)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for password flow authenticationemail - customer emailpassword - customer passwordpublic ClientBuilder withGlobalCustomerPasswordFlow(ClientCredentials credentials, String email, String password, String tokenEndpoint, Supplier<HandlerStack> httpClientSupplier)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for password flow authenticationemail - customer emailpassword - customer passwordhttpClientSupplier - HandlerStack to use for authenticationpublic ClientBuilder withGlobalCustomerPasswordFlow(ClientCredentials credentials, String email, String password, String tokenEndpoint, VrapHttpClient httpClient)
credentials - ClientCredentials to be used for authenticationtokenEndpoint - URI to be used for password flow authenticationemail - customer emailpassword - customer passwordhttpClient - VrapHttpClient to use for authenticationpublic ClientBuilder addAcceptGZipMiddleware()
public ClientBuilder withErrorMiddleware(Supplier<ErrorMiddleware> errorMiddleware)
errorMiddleware - ErrorMiddleware to be usedpublic ClientBuilder withErrorMiddleware()
public ClientBuilder withErrorMiddleware(ErrorMiddleware errorMiddleware)
errorMiddleware - ErrorMiddleware to be usedpublic ClientBuilder withErrorMiddleware(ErrorMiddleware.ExceptionMode exceptionMode)
exceptionMode - either use CompletionExceptions or unwrap the Exception. See ErrorMiddleware.ExceptionModepublic ClientBuilder withTelemetryMiddleware(Supplier<TelemetryMiddleware> telemetryMiddleware)
telemetryMiddleware - TelemetryMiddleware to be usedpublic ClientBuilder withTelemetryMiddleware(TelemetryMiddleware telemetryMiddleware)
telemetryMiddleware - TelemetryMiddleware to be usedpublic ClientBuilder addNotFoundExceptionMiddleware()
NotFoundException to a response with a null body valuepublic ClientBuilder addNotFoundExceptionMiddleware(Set<ApiHttpMethod> methods)
NotFoundException to a response with a null body valuemethods - HTTP methods to convert on NotFoundExceptionpublic ClientBuilder addNotFoundExceptionMiddleware(Predicate<ApiHttpRequest> requestPredicate)
NotFoundException to a response with a null body valuerequestPredicate - predicate to match for converting NotFoundExceptionpublic ClientBuilder addNotFoundExceptionMiddleware(NotFoundExceptionMiddleware exceptionMiddleware)
NotFoundException to a response with a null body valueexceptionMiddleware - middleware to be usedpublic ClientBuilder withRetryMiddleware(Supplier<RetryRequestMiddleware> retryMiddleware)
retryMiddleware - RetryMiddleware to be usedpublic ClientBuilder withRetryMiddleware(RetryRequestMiddleware retryMiddleware)
retryMiddleware - RetryMiddleware to be usedpublic ClientBuilder withRetryMiddleware(int maxRetries)
maxRetries - number of retries before giving uopublic ClientBuilder withRetryMiddleware(int maxRetries, List<Integer> statusCodes)
maxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503public ClientBuilder withRetryMiddleware(int maxRetries, List<Integer> statusCodes, List<Class<? extends Throwable>> failures)
maxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedpublic ClientBuilder withRetryMiddleware(int maxRetries, long delay, long maxDelay, List<Integer> statusCodes, List<Class<? extends Throwable>> failures, FailsafeRetryPolicyBuilderOptions fn)
maxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retrystatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(int maxRetries, long delay, long maxDelay, FailsafeRetryPolicyBuilderOptions fn)
maxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retryfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(ExecutorService executorService, int maxRetries)
executorService - ExecutorService to be used for the retry handlermaxRetries - number of retries before giving uopublic ClientBuilder withRetryMiddleware(ExecutorService executorService, int maxRetries, List<Integer> statusCodes)
executorService - ExecutorService to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503public ClientBuilder withRetryMiddleware(ExecutorService executorService, int maxRetries, List<Integer> statusCodes, List<Class<? extends Throwable>> failures)
executorService - ExecutorService to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedpublic ClientBuilder withRetryMiddleware(ExecutorService executorService, int maxRetries, long delay, long maxDelay, List<Integer> statusCodes, List<Class<? extends Throwable>> failures, FailsafeRetryPolicyBuilderOptions fn)
executorService - ExecutorService to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retrystatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(ExecutorService executorService, int maxRetries, long delay, long maxDelay, FailsafeRetryPolicyBuilderOptions fn)
executorService - ExecutorService to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retryfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(ScheduledExecutorService executorService, int maxRetries)
executorService - ScheduledExecutorService to be used for the retry handlermaxRetries - number of retries before giving uopublic ClientBuilder withRetryMiddleware(ScheduledExecutorService executorService, int maxRetries, List<Integer> statusCodes)
executorService - ScheduledExecutorService to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503public ClientBuilder withRetryMiddleware(ScheduledExecutorService executorService, int maxRetries, List<Integer> statusCodes, List<Class<? extends Throwable>> failures)
executorService - ScheduledExecutorService to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedpublic ClientBuilder withRetryMiddleware(ScheduledExecutorService executorService, int maxRetries, long delay, long maxDelay, List<Integer> statusCodes, List<Class<? extends Throwable>> failures, FailsafeRetryPolicyBuilderOptions fn)
executorService - ScheduledExecutorService to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retrystatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(ScheduledExecutorService executorService, int maxRetries, long delay, long maxDelay, FailsafeRetryPolicyBuilderOptions fn)
executorService - ScheduledExecutorService to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retryfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRetries)
scheduler - Scheduler to be used for the retry handlermaxRetries - number of retries before giving uopublic ClientBuilder withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRetries, List<Integer> statusCodes)
scheduler - Scheduler to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503public ClientBuilder withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRetries, List<Integer> statusCodes, List<Class<? extends Throwable>> failures)
scheduler - Scheduler to be used for the retry handlermaxRetries - number of retries before giving uostatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedpublic ClientBuilder withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRetries, long delay, long maxDelay, List<Integer> statusCodes, List<Class<? extends Throwable>> failures, FailsafeRetryPolicyBuilderOptions fn)
scheduler - Scheduler to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retrystatusCodes - HTTP status codes to retry a failed request e.g. 500 & 503failures - Throwables to be retriedfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withRetryMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRetries, long delay, long maxDelay, FailsafeRetryPolicyBuilderOptions fn)
scheduler - Scheduler to be used for the retry handlermaxRetries - number of retries before giving uodelay - the initial delay for a retrymaxDelay - the maximum delay between each retryfn - additional configuration for the RetryPolicy to be appliedpublic ClientBuilder withQueueMiddleware(Supplier<QueueRequestMiddleware> queueMiddleware)
queueMiddleware - QueueRequestMiddleware to be usedpublic ClientBuilder withQueueMiddleware(QueueRequestMiddleware queueMiddleware)
queueMiddleware - QueueRequestMiddleware to be usedpublic ClientBuilder withQueueMiddleware(int maxRequests, Duration maxWaitTime)
maxRequests - maximum number of concurrent requestsmaxWaitTime - maximum time to wait before giving uppublic ClientBuilder withQueueMiddleware(dev.failsafe.spi.Scheduler scheduler, int maxRequests, Duration maxWaitTime)
scheduler - Scheduler to be used for handling the queuemaxRequests - maximum number of concurrent requestsmaxWaitTime - maximum time to wait before giving uppublic ClientBuilder withQueueMiddleware(ScheduledExecutorService executorService, int maxRequests, Duration maxWaitTime)
executorService - ScheduledExecutorService to be used for handling the queuemaxRequests - maximum number of concurrent requestsmaxWaitTime - maximum time to wait before giving uppublic ClientBuilder withQueueMiddleware(ExecutorService executorService, int maxRequests, Duration maxWaitTime)
executorService - ExecutorService to be used for handling the queuemaxRequests - maximum number of concurrent requestsmaxWaitTime - maximum time to wait before giving uppublic ClientBuilder withOAuthMiddleware(Supplier<OAuthMiddleware> oAuthMiddleware)
oAuthMiddleware - OAuthMiddleware to be used for authenticationpublic ClientBuilder withOAuthMiddleware(OAuthMiddleware oAuthMiddleware)
oAuthMiddleware - OAuthMiddleware to be used for authenticationpublic ClientBuilder withTokenSupplier(Supplier<TokenSupplier> tokenSupplier)
tokenSupplier - TokenSupplier for retrieving authentication tokenspublic ClientBuilder withTokenSupplier(TokenSupplier tokenSupplier)
tokenSupplier - TokenSupplier for retrieving authentication tokenspublic ClientBuilder withInternalLoggerMiddleware(InternalLoggerMiddleware internalLoggerMiddleware)
internalLoggerMiddleware - InternalLoggerMiddleware used for logging requests and responsespublic ClientBuilder withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory)
internalLoggerFactory - InternalLoggerFactory creates the logger for request & responsespublic ClientBuilder withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory, org.slf4j.event.Level responseLogEvent, org.slf4j.event.Level deprecationLogEvent)
internalLoggerFactory - InternalLoggerFactory creates the logger for request & responsesresponseLogEvent - Level for logging responses.deprecationLogEvent - Level for logging ApiHttpHeaders.X_DEPRECATION_NOTICEpublic ClientBuilder withInternalLoggerFactory(InternalLoggerFactory internalLoggerFactory, org.slf4j.event.Level responseLogEvent, org.slf4j.event.Level deprecationLogEvent, org.slf4j.event.Level defaultExceptionLogEvent, Map<Class<? extends Throwable>,org.slf4j.event.Level> exceptionLogEvents)
internalLoggerFactory - InternalLoggerFactory creates the logger for request & responsesresponseLogEvent - Level for logging responses.deprecationLogEvent - Level for logging ApiHttpHeaders.X_DEPRECATION_NOTICEdefaultExceptionLogEvent - Level for logging errorsexceptionLogEvents - Level for logging by exception classpublic ClientBuilder withApiBaseUrl(String apiBaseUrl)
apiBaseUrl - base URI for calling the APIpublic ClientBuilder withApiBaseUrl(URI apiBaseUrl)
apiBaseUrl - base URI for calling the APIpublic ClientBuilder withUserAgentSupplier(Supplier<String> userAgentSupplier)
userAgentSupplier - user agent to be send with the requestspublic ClientBuilder addCorrelationIdProvider(@Nullable CorrelationIdProvider correlationIdProvider, boolean replace)
correlationIdProvider - provider to create correlation IDs for each requestreplace - replace any existing correlation id providerpublic ClientBuilder addCorrelationIdProvider(@Nullable CorrelationIdProvider correlationIdProvider)
correlationIdProvider - provider to create correlation IDs for each requestpublic ClientBuilder withMiddlewares(List<Middleware> middlewares)
middlewares - Middleware instancespublic ClientBuilder withMiddleware(Middleware middleware, Middleware... middlewares)
middleware - Middleware instancemiddlewares - Middleware instancespublic ClientBuilder addMiddlewares(List<Middleware> middlewares)
middlewares - Middleware instancespublic ClientBuilder addMiddleware(Middleware middleware, Middleware... middlewares)
middleware - Middleware instancemiddlewares - Middleware instancespublic ApiHttpClient build()
ApiHttpClient with the configured valuesbuild in interface Builder<ApiHttpClient>ApiHttpClientpublic static String buildDefaultUserAgent()