RestClient.Builder Class
- java.
lang. Object - com.
microsoft. bot. restclient. RestClient. Builder
- com.
public static class RestClient.Builder
The builder class for building a REST client.
Constructor Summary
| Constructor | Description |
|---|---|
| Builder() |
Creates an instance of the builder with a base URL to the service. |
| Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder) |
Creates an instance of the builder with a base URL and 2 custom builders. |
Method Summary
Methods inherited from java.lang.Object
Constructor Details
Builder
public Builder()
Creates an instance of the builder with a base URL to the service.
Builder
public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder)
Creates an instance of the builder with a base URL and 2 custom builders.
Parameters:
Method Details
build
public RestClient build()
Build a RestClient with all the current configurations.
Returns:
useHttpClientThreadPool
public RestClient.Builder useHttpClientThreadPool(boolean useHttpClientThreadPool)
Sets whether to use the thread pool in OkHttp client or RxJava schedulers. If set to true, the thread pool in OkHttp client will be used. Default is false.
Parameters:
Returns:
withBaseUrl
public RestClient.Builder withBaseUrl(Environment environment, Environment.Endpoint endpoint)
Sets the base URL with the default from the Environment.
Parameters:
Returns:
withBaseUrl
public RestClient.Builder withBaseUrl(String baseUrl)
Sets the dynamic base URL.
Parameters:
Returns:
withCallbackExecutor
public RestClient.Builder withCallbackExecutor(Executor executor)
Sets the executor for async callbacks to run on.
Parameters:
Returns:
withConnectionPool
public RestClient.Builder withConnectionPool(ConnectionPool connectionPool)
Sets the connection pool for the Http client.
Parameters:
Returns:
withConnectionTimeout
public RestClient.Builder withConnectionTimeout(long timeout, TimeUnit unit)
Set the connection timeout on the HTTP client. Default is 10 seconds.
Parameters:
Returns:
withCredentials
public RestClient.Builder withCredentials(ServiceClientCredentials credentials)
Sets the credentials.
Parameters:
Returns:
withDispatcher
public RestClient.Builder withDispatcher(Dispatcher dispatcher)
Sets the dispatcher used in OkHttp client. This is also where to set the thread pool for executing HTTP requests.
Parameters:
Returns:
withInterceptor
public RestClient.Builder withInterceptor(Interceptor interceptor)
Add an interceptor the Http client pipeline.
Parameters:
Returns:
withLogLevel
public RestClient.Builder withLogLevel(LogLevel logLevel)
Sets the HTTP log level.
Parameters:
Returns:
withMaxIdleConnections
public RestClient.Builder withMaxIdleConnections(int maxIdleConnections)
Deprecated
Set the maximum idle connections for the HTTP client. Default is 5.
Parameters:
Returns:
withNetworkInterceptor
public RestClient.Builder withNetworkInterceptor(Interceptor networkInterceptor)
Add an interceptor the network layer of Http client pipeline.
Parameters:
Returns:
withProxy
public RestClient.Builder withProxy(Proxy proxy)
Sets the proxy for the HTTP client.
Parameters:
Returns:
withProxyAuthenticator
public RestClient.Builder withProxyAuthenticator(Authenticator proxyAuthenticator)
Sets the proxy authenticator for the HTTP client.
Parameters:
Returns:
withReadTimeout
public RestClient.Builder withReadTimeout(long timeout, TimeUnit unit)
Set the read timeout on the HTTP client. Default is 10 seconds.
Parameters:
Returns:
withResponseBuilderFactory
public RestClient.Builder withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)
Sets the response builder factory.
Parameters:
Returns:
withRetryStrategy
public RestClient.Builder withRetryStrategy(RetryStrategy strategy)
Adds a retry strategy to the client.
Parameters:
Returns:
withSerializerAdapter
public RestClient.Builder withSerializerAdapter(SerializerAdapter serializerAdapter)
Sets the serialization adapter.
Parameters:
Returns:
withUserAgent
public RestClient.Builder withUserAgent(String userAgent)
Sets the user agent header.
Parameters:
Returns: