Class CasedevOkHttpClient.Builder
-
- All Implemented Interfaces:
public final class CasedevOkHttpClient.BuilderA builder for CasedevOkHttpClient.
-
-
Method Summary
Modifier and Type Method Description final CasedevOkHttpClient.BuilderdispatcherExecutorService(ExecutorService dispatcherExecutorService)The executor service to use for running HTTP requests. final CasedevOkHttpClient.BuilderdispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)Alias for calling Builder.dispatcherExecutorService with dispatcherExecutorService.orElse(null).final CasedevOkHttpClient.Builderproxy(Proxy proxy)final CasedevOkHttpClient.Builderproxy(Optional<Proxy> proxy)Alias for calling Builder.proxy with proxy.orElse(null).final CasedevOkHttpClient.BuilderproxyAuthenticator(ProxyAuthenticator proxyAuthenticator)Provides credentials when an HTTP proxy responds with 407 Proxy Authentication Required.final CasedevOkHttpClient.BuilderproxyAuthenticator(Optional<ProxyAuthenticator> proxyAuthenticator)Alias for calling Builder.proxyAuthenticator with proxyAuthenticator.orElse(null).final CasedevOkHttpClient.BuildermaxIdleConnections(Integer maxIdleConnections)The maximum number of idle connections kept by the underlying OkHttp connection pool. final CasedevOkHttpClient.BuildermaxIdleConnections(Integer maxIdleConnections)Alias for Builder.maxIdleConnections. final CasedevOkHttpClient.BuildermaxIdleConnections(Optional<Integer> maxIdleConnections)Alias for calling Builder.maxIdleConnections with maxIdleConnections.orElse(null).final CasedevOkHttpClient.BuilderkeepAliveDuration(Duration keepAliveDuration)The keep-alive duration for idle connections in the underlying OkHttp connection pool. final CasedevOkHttpClient.BuilderkeepAliveDuration(Optional<Duration> keepAliveDuration)Alias for calling Builder.keepAliveDuration with keepAliveDuration.orElse(null).final CasedevOkHttpClient.BuildersslSocketFactory(SSLSocketFactory sslSocketFactory)The socket factory used to secure HTTPS connections. final CasedevOkHttpClient.BuildersslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)Alias for calling Builder.sslSocketFactory with sslSocketFactory.orElse(null).final CasedevOkHttpClient.BuildertrustManager(X509TrustManager trustManager)The trust manager used to secure HTTPS connections. final CasedevOkHttpClient.BuildertrustManager(Optional<X509TrustManager> trustManager)Alias for calling Builder.trustManager with trustManager.orElse(null).final CasedevOkHttpClient.BuilderhostnameVerifier(HostnameVerifier hostnameVerifier)The verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections. final CasedevOkHttpClient.BuilderhostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)Alias for calling Builder.hostnameVerifier with hostnameVerifier.orElse(null).final CasedevOkHttpClient.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 CasedevOkHttpClient.BuilderjsonMapper(JsonMapper jsonMapper)The Jackson JSON mapper to use for serializing and deserializing JSON. final CasedevOkHttpClient.BuilderstreamHandlerExecutor(Executor streamHandlerExecutor)The executor to use for running AsyncStreamResponse.Handler callbacks. final CasedevOkHttpClient.Buildersleeper(Sleeper sleeper)The interface to use for delaying execution, like during retries. final CasedevOkHttpClient.Builderclock(Clock clock)The clock to use for operations that require timing, like retries. final CasedevOkHttpClient.BuilderbaseUrl(String baseUrl)The base URL to use for every request. final CasedevOkHttpClient.BuilderbaseUrl(Optional<String> baseUrl)Alias for calling Builder.baseUrl with baseUrl.orElse(null).final CasedevOkHttpClient.Builderlocal()Sets baseUrl to http://localhost:2728.final CasedevOkHttpClient.BuilderresponseValidation(Boolean responseValidation)Whether to call validateon every response before returning it.final CasedevOkHttpClient.Buildertimeout(Timeout timeout)Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries. final CasedevOkHttpClient.Buildertimeout(Duration timeout)Sets the maximum time allowed for a complete HTTP call, not including retries. final CasedevOkHttpClient.BuildermaxRetries(Integer maxRetries)The maximum number of times to retry failed requests, with a short exponential backoff between requests. final CasedevOkHttpClient.BuilderlogLevel(LogLevel logLevel)The level at which to log request and response information. final CasedevOkHttpClient.BuilderapiKey(String apiKey)API key authentication. final CasedevOkHttpClient.Builderheaders(Headers headers)final CasedevOkHttpClient.Builderheaders(Map<String, Iterable<String>> headers)final CasedevOkHttpClient.BuilderputHeader(String name, String value)final CasedevOkHttpClient.BuilderputHeaders(String name, Iterable<String> values)final CasedevOkHttpClient.BuilderputAllHeaders(Headers headers)final CasedevOkHttpClient.BuilderputAllHeaders(Map<String, Iterable<String>> headers)final CasedevOkHttpClient.BuilderreplaceHeaders(String name, String value)final CasedevOkHttpClient.BuilderreplaceHeaders(String name, Iterable<String> values)final CasedevOkHttpClient.BuilderreplaceAllHeaders(Headers headers)final CasedevOkHttpClient.BuilderreplaceAllHeaders(Map<String, Iterable<String>> headers)final CasedevOkHttpClient.BuilderremoveHeaders(String name)final CasedevOkHttpClient.BuilderremoveAllHeaders(Set<String> names)final CasedevOkHttpClient.BuilderqueryParams(QueryParams queryParams)final CasedevOkHttpClient.BuilderqueryParams(Map<String, Iterable<String>> queryParams)final CasedevOkHttpClient.BuilderputQueryParam(String key, String value)final CasedevOkHttpClient.BuilderputQueryParams(String key, Iterable<String> values)final CasedevOkHttpClient.BuilderputAllQueryParams(QueryParams queryParams)final CasedevOkHttpClient.BuilderputAllQueryParams(Map<String, Iterable<String>> queryParams)final CasedevOkHttpClient.BuilderreplaceQueryParams(String key, String value)final CasedevOkHttpClient.BuilderreplaceQueryParams(String key, Iterable<String> values)final CasedevOkHttpClient.BuilderreplaceAllQueryParams(QueryParams queryParams)final CasedevOkHttpClient.BuilderreplaceAllQueryParams(Map<String, Iterable<String>> queryParams)final CasedevOkHttpClient.BuilderremoveQueryParams(String key)final CasedevOkHttpClient.BuilderremoveAllQueryParams(Set<String> keys)final CasedevOkHttpClient.BuilderfromEnv()Updates configuration using system properties and environment variables. final CasedevClientbuild()Returns an immutable instance of CasedevClient. -
-
Method Detail
-
dispatcherExecutorService
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder dispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)
Alias for calling Builder.dispatcherExecutorService with
dispatcherExecutorService.orElse(null).
-
proxy
final CasedevOkHttpClient.Builder proxy(Proxy proxy)
-
proxy
final CasedevOkHttpClient.Builder proxy(Optional<Proxy> proxy)
Alias for calling Builder.proxy with
proxy.orElse(null).
-
proxyAuthenticator
final CasedevOkHttpClient.Builder proxyAuthenticator(ProxyAuthenticator proxyAuthenticator)
Provides credentials when an HTTP proxy responds with
407 Proxy Authentication Required.
-
proxyAuthenticator
final CasedevOkHttpClient.Builder proxyAuthenticator(Optional<ProxyAuthenticator> proxyAuthenticator)
Alias for calling Builder.proxyAuthenticator with
proxyAuthenticator.orElse(null).
-
maxIdleConnections
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder maxIdleConnections(Integer maxIdleConnections)
Alias for Builder.maxIdleConnections.
This unboxed primitive overload exists for backwards compatibility.
-
maxIdleConnections
final CasedevOkHttpClient.Builder maxIdleConnections(Optional<Integer> maxIdleConnections)
Alias for calling Builder.maxIdleConnections with
maxIdleConnections.orElse(null).
-
keepAliveDuration
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder keepAliveDuration(Optional<Duration> keepAliveDuration)
Alias for calling Builder.keepAliveDuration with
keepAliveDuration.orElse(null).
-
sslSocketFactory
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder sslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)
Alias for calling Builder.sslSocketFactory with
sslSocketFactory.orElse(null).
-
trustManager
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder trustManager(Optional<X509TrustManager> trustManager)
Alias for calling Builder.trustManager with
trustManager.orElse(null).
-
hostnameVerifier
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder hostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)
Alias for calling Builder.hostnameVerifier with
hostnameVerifier.orElse(null).
-
checkJacksonVersionCompatibility
final CasedevOkHttpClient.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 CasedevOkHttpClient.Builder jsonMapper(JsonMapper jsonMapper)
The Jackson JSON mapper to use for serializing and deserializing JSON.
Defaults to dev.case.api.core.jsonMapper. The default is usually sufficient and rarely needs to be overridden.
-
streamHandlerExecutor
final CasedevOkHttpClient.Builder streamHandlerExecutor(Executor streamHandlerExecutor)
The executor to use for running AsyncStreamResponse.Handler callbacks.
Defaults to a dedicated cached thread pool.
This class takes ownership of the executor and shuts it down, if possible, when closed.
-
sleeper
final CasedevOkHttpClient.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 CasedevOkHttpClient.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 CasedevOkHttpClient.Builder baseUrl(String baseUrl)
The base URL to use for every request.
Defaults to the production environment:
https://api.case.dev.The following other environments, with dedicated builder methods, are available:
local:
http://localhost:2728
-
baseUrl
final CasedevOkHttpClient.Builder baseUrl(Optional<String> baseUrl)
Alias for calling Builder.baseUrl with
baseUrl.orElse(null).
-
local
final CasedevOkHttpClient.Builder local()
Sets baseUrl to
http://localhost:2728.
-
responseValidation
final CasedevOkHttpClient.Builder responseValidation(Boolean responseValidation)
Whether to call
validateon every response before returning it.Setting this to
trueis not forwards compatible with new types from the API for existing fields.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 CasedevOkHttpClient.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 CasedevOkHttpClient.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 CasedevOkHttpClient.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.
-
logLevel
final CasedevOkHttpClient.Builder logLevel(LogLevel logLevel)
The level at which to log request and response information.
fromEnv will set the level from environment variables. See LogLevel.fromEnv.
Defaults to LogLevel.fromEnv.
-
apiKey
final CasedevOkHttpClient.Builder apiKey(String apiKey)
API key authentication. Use your case.dev API key (e.g., sk_case_your_api_key_here)
-
headers
final CasedevOkHttpClient.Builder headers(Headers headers)
-
putHeader
final CasedevOkHttpClient.Builder putHeader(String name, String value)
-
putHeaders
final CasedevOkHttpClient.Builder putHeaders(String name, Iterable<String> values)
-
putAllHeaders
final CasedevOkHttpClient.Builder putAllHeaders(Headers headers)
-
putAllHeaders
final CasedevOkHttpClient.Builder putAllHeaders(Map<String, Iterable<String>> headers)
-
replaceHeaders
final CasedevOkHttpClient.Builder replaceHeaders(String name, String value)
-
replaceHeaders
final CasedevOkHttpClient.Builder replaceHeaders(String name, Iterable<String> values)
-
replaceAllHeaders
final CasedevOkHttpClient.Builder replaceAllHeaders(Headers headers)
-
replaceAllHeaders
final CasedevOkHttpClient.Builder replaceAllHeaders(Map<String, Iterable<String>> headers)
-
removeHeaders
final CasedevOkHttpClient.Builder removeHeaders(String name)
-
removeAllHeaders
final CasedevOkHttpClient.Builder removeAllHeaders(Set<String> names)
-
queryParams
final CasedevOkHttpClient.Builder queryParams(QueryParams queryParams)
-
queryParams
final CasedevOkHttpClient.Builder queryParams(Map<String, Iterable<String>> queryParams)
-
putQueryParam
final CasedevOkHttpClient.Builder putQueryParam(String key, String value)
-
putQueryParams
final CasedevOkHttpClient.Builder putQueryParams(String key, Iterable<String> values)
-
putAllQueryParams
final CasedevOkHttpClient.Builder putAllQueryParams(QueryParams queryParams)
-
putAllQueryParams
final CasedevOkHttpClient.Builder putAllQueryParams(Map<String, Iterable<String>> queryParams)
-
replaceQueryParams
final CasedevOkHttpClient.Builder replaceQueryParams(String key, String value)
-
replaceQueryParams
final CasedevOkHttpClient.Builder replaceQueryParams(String key, Iterable<String> values)
-
replaceAllQueryParams
final CasedevOkHttpClient.Builder replaceAllQueryParams(QueryParams queryParams)
-
replaceAllQueryParams
final CasedevOkHttpClient.Builder replaceAllQueryParams(Map<String, Iterable<String>> queryParams)
-
removeQueryParams
final CasedevOkHttpClient.Builder removeQueryParams(String key)
-
removeAllQueryParams
final CasedevOkHttpClient.Builder removeAllQueryParams(Set<String> keys)
-
fromEnv
final CasedevOkHttpClient.Builder fromEnv()
Updates configuration using system properties and environment variables.
-
build
final CasedevClient build()
Returns an immutable instance of CasedevClient.
Further updates to this Builder will not mutate the returned instance.
-
-
-
-