Class SentOkHttpClient.Builder
-
- All Implemented Interfaces:
public final class SentOkHttpClient.BuilderA builder for SentOkHttpClient.
-
-
Method Summary
Modifier and Type Method Description final SentOkHttpClient.BuilderdispatcherExecutorService(ExecutorService dispatcherExecutorService)The executor service to use for running HTTP requests. final SentOkHttpClient.BuilderdispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)Alias for calling Builder.dispatcherExecutorService with dispatcherExecutorService.orElse(null).final SentOkHttpClient.Builderproxy(Proxy proxy)final SentOkHttpClient.Builderproxy(Optional<Proxy> proxy)Alias for calling Builder.proxy with proxy.orElse(null).final SentOkHttpClient.BuildermaxIdleConnections(Integer maxIdleConnections)The maximum number of idle connections kept by the underlying OkHttp connection pool. final SentOkHttpClient.BuildermaxIdleConnections(Integer maxIdleConnections)Alias for Builder.maxIdleConnections. final SentOkHttpClient.BuildermaxIdleConnections(Optional<Integer> maxIdleConnections)Alias for calling Builder.maxIdleConnections with maxIdleConnections.orElse(null).final SentOkHttpClient.BuilderkeepAliveDuration(Duration keepAliveDuration)The keep-alive duration for idle connections in the underlying OkHttp connection pool. final SentOkHttpClient.BuilderkeepAliveDuration(Optional<Duration> keepAliveDuration)Alias for calling Builder.keepAliveDuration with keepAliveDuration.orElse(null).final SentOkHttpClient.BuildersslSocketFactory(SSLSocketFactory sslSocketFactory)The socket factory used to secure HTTPS connections. final SentOkHttpClient.BuildersslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)Alias for calling Builder.sslSocketFactory with sslSocketFactory.orElse(null).final SentOkHttpClient.BuildertrustManager(X509TrustManager trustManager)The trust manager used to secure HTTPS connections. final SentOkHttpClient.BuildertrustManager(Optional<X509TrustManager> trustManager)Alias for calling Builder.trustManager with trustManager.orElse(null).final SentOkHttpClient.BuilderhostnameVerifier(HostnameVerifier hostnameVerifier)The verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections. final SentOkHttpClient.BuilderhostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)Alias for calling Builder.hostnameVerifier with hostnameVerifier.orElse(null).final SentOkHttpClient.BuildercheckJacksonVersionCompatibility(Boolean checkJacksonVersionCompatibility)Whether to throw an exception if any of the Jackson versions detected at runtime are incompatible with the SDK's minimum supported Jackson version (2.13.4). final SentOkHttpClient.BuilderjsonMapper(JsonMapper jsonMapper)The Jackson JSON mapper to use for serializing and deserializing JSON. final SentOkHttpClient.Buildersleeper(Sleeper sleeper)The interface to use for delaying execution, like during retries. final SentOkHttpClient.Builderclock(Clock clock)The clock to use for operations that require timing, like retries. final SentOkHttpClient.BuilderbaseUrl(String baseUrl)The base URL to use for every request. final SentOkHttpClient.BuilderbaseUrl(Optional<String> baseUrl)Alias for calling Builder.baseUrl with baseUrl.orElse(null).final SentOkHttpClient.BuilderresponseValidation(Boolean responseValidation)Whether to call validateon every response before returning it.final SentOkHttpClient.Buildertimeout(Timeout timeout)Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries. final SentOkHttpClient.Buildertimeout(Duration timeout)Sets the maximum time allowed for a complete HTTP call, not including retries. final SentOkHttpClient.BuildermaxRetries(Integer maxRetries)The maximum number of times to retry failed requests, with a short exponential backoff between requests. final SentOkHttpClient.BuilderapiKey(String apiKey)Customer API key for authentication. final SentOkHttpClient.Builderheaders(Headers headers)final SentOkHttpClient.Builderheaders(Map<String, Iterable<String>> headers)final SentOkHttpClient.BuilderputHeader(String name, String value)final SentOkHttpClient.BuilderputHeaders(String name, Iterable<String> values)final SentOkHttpClient.BuilderputAllHeaders(Headers headers)final SentOkHttpClient.BuilderputAllHeaders(Map<String, Iterable<String>> headers)final SentOkHttpClient.BuilderreplaceHeaders(String name, String value)final SentOkHttpClient.BuilderreplaceHeaders(String name, Iterable<String> values)final SentOkHttpClient.BuilderreplaceAllHeaders(Headers headers)final SentOkHttpClient.BuilderreplaceAllHeaders(Map<String, Iterable<String>> headers)final SentOkHttpClient.BuilderremoveHeaders(String name)final SentOkHttpClient.BuilderremoveAllHeaders(Set<String> names)final SentOkHttpClient.BuilderqueryParams(QueryParams queryParams)final SentOkHttpClient.BuilderqueryParams(Map<String, Iterable<String>> queryParams)final SentOkHttpClient.BuilderputQueryParam(String key, String value)final SentOkHttpClient.BuilderputQueryParams(String key, Iterable<String> values)final SentOkHttpClient.BuilderputAllQueryParams(QueryParams queryParams)final SentOkHttpClient.BuilderputAllQueryParams(Map<String, Iterable<String>> queryParams)final SentOkHttpClient.BuilderreplaceQueryParams(String key, String value)final SentOkHttpClient.BuilderreplaceQueryParams(String key, Iterable<String> values)final SentOkHttpClient.BuilderreplaceAllQueryParams(QueryParams queryParams)final SentOkHttpClient.BuilderreplaceAllQueryParams(Map<String, Iterable<String>> queryParams)final SentOkHttpClient.BuilderremoveQueryParams(String key)final SentOkHttpClient.BuilderremoveAllQueryParams(Set<String> keys)final SentOkHttpClient.BuilderfromEnv()Updates configuration using system properties and environment variables. final SentClientbuild()Returns an immutable instance of SentClient. -
-
Method Detail
-
dispatcherExecutorService
final SentOkHttpClient.Builder dispatcherExecutorService(ExecutorService dispatcherExecutorService)
The executor service to use for running HTTP requests.
Defaults to OkHttp's default executor service.
This class takes ownership of the executor service and shuts it down when closed.
-
dispatcherExecutorService
final SentOkHttpClient.Builder dispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)
Alias for calling Builder.dispatcherExecutorService with
dispatcherExecutorService.orElse(null).
-
proxy
final SentOkHttpClient.Builder proxy(Proxy proxy)
-
proxy
final SentOkHttpClient.Builder proxy(Optional<Proxy> proxy)
Alias for calling Builder.proxy with
proxy.orElse(null).
-
maxIdleConnections
final SentOkHttpClient.Builder maxIdleConnections(Integer maxIdleConnections)
The maximum number of idle connections kept by the underlying OkHttp connection pool.
If this is set, then keepAliveDuration must also be set.
If unset, then OkHttp's default is used.
-
maxIdleConnections
final SentOkHttpClient.Builder maxIdleConnections(Integer maxIdleConnections)
Alias for Builder.maxIdleConnections.
This unboxed primitive overload exists for backwards compatibility.
-
maxIdleConnections
final SentOkHttpClient.Builder maxIdleConnections(Optional<Integer> maxIdleConnections)
Alias for calling Builder.maxIdleConnections with
maxIdleConnections.orElse(null).
-
keepAliveDuration
final SentOkHttpClient.Builder keepAliveDuration(Duration keepAliveDuration)
The keep-alive duration for idle connections in the underlying OkHttp connection pool.
If this is set, then maxIdleConnections must also be set.
If unset, then OkHttp's default is used.
-
keepAliveDuration
final SentOkHttpClient.Builder keepAliveDuration(Optional<Duration> keepAliveDuration)
Alias for calling Builder.keepAliveDuration with
keepAliveDuration.orElse(null).
-
sslSocketFactory
final SentOkHttpClient.Builder sslSocketFactory(SSLSocketFactory sslSocketFactory)
The socket factory used to secure HTTPS connections.
If this is set, then trustManager must also be set.
If unset, then the system default is used. Most applications should not call this method, and instead use the system default. The default include special optimizations that can be lost if the implementation is modified.
-
sslSocketFactory
final SentOkHttpClient.Builder sslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)
Alias for calling Builder.sslSocketFactory with
sslSocketFactory.orElse(null).
-
trustManager
final SentOkHttpClient.Builder trustManager(X509TrustManager trustManager)
The trust manager used to secure HTTPS connections.
If this is set, then sslSocketFactory must also be set.
If unset, then the system default is used. Most applications should not call this method, and instead use the system default. The default include special optimizations that can be lost if the implementation is modified.
-
trustManager
final SentOkHttpClient.Builder trustManager(Optional<X509TrustManager> trustManager)
Alias for calling Builder.trustManager with
trustManager.orElse(null).
-
hostnameVerifier
final SentOkHttpClient.Builder hostnameVerifier(HostnameVerifier hostnameVerifier)
The verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections.
If unset, then a default hostname verifier is used.
-
hostnameVerifier
final SentOkHttpClient.Builder hostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)
Alias for calling Builder.hostnameVerifier with
hostnameVerifier.orElse(null).
-
checkJacksonVersionCompatibility
final SentOkHttpClient.Builder checkJacksonVersionCompatibility(Boolean checkJacksonVersionCompatibility)
Whether to throw an exception if any of the Jackson versions detected at runtime are incompatible with the SDK's minimum supported Jackson version (2.13.4).
Defaults to true. Use extreme caution when disabling this option. There is no guarantee that the SDK will work correctly when using an incompatible Jackson version.
-
jsonMapper
final SentOkHttpClient.Builder jsonMapper(JsonMapper jsonMapper)
The Jackson JSON mapper to use for serializing and deserializing JSON.
Defaults to dm.sent.core.jsonMapper. The default is usually sufficient and rarely needs to be overridden.
-
sleeper
final SentOkHttpClient.Builder sleeper(Sleeper sleeper)
The interface to use for delaying execution, like during retries.
This is primarily useful for using fake delays in tests.
Defaults to real execution delays.
This class takes ownership of the sleeper and closes it when closed.
-
clock
final SentOkHttpClient.Builder clock(Clock clock)
The clock to use for operations that require timing, like retries.
This is primarily useful for using a fake clock in tests.
Defaults to Clock.systemUTC.
-
baseUrl
final SentOkHttpClient.Builder baseUrl(String baseUrl)
The base URL to use for every request.
Defaults to the production environment:
https://api.sent.dm.
-
baseUrl
final SentOkHttpClient.Builder baseUrl(Optional<String> baseUrl)
Alias for calling Builder.baseUrl with
baseUrl.orElse(null).
-
responseValidation
final SentOkHttpClient.Builder responseValidation(Boolean responseValidation)
Whether to call
validateon every response before returning it.Defaults to false, which means the shape of the response will not be validated upfront. Instead, validation will only occur for the parts of the response that are accessed.
-
timeout
final SentOkHttpClient.Builder timeout(Timeout timeout)
Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries.
Defaults to Timeout.default.
-
timeout
final SentOkHttpClient.Builder timeout(Duration timeout)
Sets the maximum time allowed for a complete HTTP call, not including retries.
See Timeout.request for more details.
For fine-grained control, pass a Timeout object.
-
maxRetries
final SentOkHttpClient.Builder maxRetries(Integer maxRetries)
The maximum number of times to retry failed requests, with a short exponential backoff between requests.
Only the following error types are retried:
Connection errors (for example, due to a network connectivity problem)
408 Request Timeout
409 Conflict
429 Rate Limit
5xx Internal
The API may also explicitly instruct the SDK to retry or not retry a request.
Defaults to 2.
-
apiKey
final SentOkHttpClient.Builder apiKey(String apiKey)
Customer API key for authentication. Use
sk_live_*keys for production andsk_test_*keys for sandbox/testing. Pass via thex-api-keyheader.
-
headers
final SentOkHttpClient.Builder headers(Headers headers)
-
putHeader
final SentOkHttpClient.Builder putHeader(String name, String value)
-
putHeaders
final SentOkHttpClient.Builder putHeaders(String name, Iterable<String> values)
-
putAllHeaders
final SentOkHttpClient.Builder putAllHeaders(Headers headers)
-
putAllHeaders
final SentOkHttpClient.Builder putAllHeaders(Map<String, Iterable<String>> headers)
-
replaceHeaders
final SentOkHttpClient.Builder replaceHeaders(String name, String value)
-
replaceHeaders
final SentOkHttpClient.Builder replaceHeaders(String name, Iterable<String> values)
-
replaceAllHeaders
final SentOkHttpClient.Builder replaceAllHeaders(Headers headers)
-
replaceAllHeaders
final SentOkHttpClient.Builder replaceAllHeaders(Map<String, Iterable<String>> headers)
-
removeHeaders
final SentOkHttpClient.Builder removeHeaders(String name)
-
removeAllHeaders
final SentOkHttpClient.Builder removeAllHeaders(Set<String> names)
-
queryParams
final SentOkHttpClient.Builder queryParams(QueryParams queryParams)
-
queryParams
final SentOkHttpClient.Builder queryParams(Map<String, Iterable<String>> queryParams)
-
putQueryParam
final SentOkHttpClient.Builder putQueryParam(String key, String value)
-
putQueryParams
final SentOkHttpClient.Builder putQueryParams(String key, Iterable<String> values)
-
putAllQueryParams
final SentOkHttpClient.Builder putAllQueryParams(QueryParams queryParams)
-
putAllQueryParams
final SentOkHttpClient.Builder putAllQueryParams(Map<String, Iterable<String>> queryParams)
-
replaceQueryParams
final SentOkHttpClient.Builder replaceQueryParams(String key, String value)
-
replaceQueryParams
final SentOkHttpClient.Builder replaceQueryParams(String key, Iterable<String> values)
-
replaceAllQueryParams
final SentOkHttpClient.Builder replaceAllQueryParams(QueryParams queryParams)
-
replaceAllQueryParams
final SentOkHttpClient.Builder replaceAllQueryParams(Map<String, Iterable<String>> queryParams)
-
removeQueryParams
final SentOkHttpClient.Builder removeQueryParams(String key)
-
removeAllQueryParams
final SentOkHttpClient.Builder removeAllQueryParams(Set<String> keys)
-
fromEnv
final SentOkHttpClient.Builder fromEnv()
Updates configuration using system properties and environment variables.
-
build
final SentClient build()
Returns an immutable instance of SentClient.
Further updates to this Builder will not mutate the returned instance.
-
-
-
-