public static class RestClient.Builder extends Object
Constructor and Description |
---|
Builder()
Creates an instance of the builder with a base URL to the service.
|
Builder(okhttp3.OkHttpClient.Builder httpClientBuilder,
retrofit2.Retrofit.Builder retrofitBuilder)
Creates an instance of the builder with a base URL and 2 custom builders.
|
Modifier and Type | Method and Description |
---|---|
RestClient |
build()
Build a RestClient with all the current configurations.
|
RestClient.Builder |
useHttpClientThreadPool(boolean useHttpClientThreadPool)
Sets whether to use the thread pool in OkHttp client or RxJava schedulers.
|
RestClient.Builder |
withBaseUrl(Environment environment,
Environment.Endpoint endpoint)
Sets the base URL with the default from the Environment.
|
RestClient.Builder |
withBaseUrl(String baseUrl)
Sets the dynamic base URL.
|
RestClient.Builder |
withCallbackExecutor(Executor executor)
Sets the executor for async callbacks to run on.
|
RestClient.Builder |
withCipherSuites(okhttp3.CipherSuite... cipherSuites)
Sets cipher suites for OkHttp client.
|
RestClient.Builder |
withConnectionPool(okhttp3.ConnectionPool connectionPool)
Sets the connection pool for the Http client.
|
RestClient.Builder |
withConnectionTimeout(long timeout,
TimeUnit unit)
Set the connection timeout on the HTTP client.
|
RestClient.Builder |
withCredentials(ServiceClientCredentials credentials)
Sets the credentials.
|
RestClient.Builder |
withDispatcher(okhttp3.Dispatcher dispatcher)
Sets the dispatcher used in OkHttp client.
|
RestClient.Builder |
withInterceptor(okhttp3.Interceptor interceptor)
Add an interceptor the Http client pipeline.
|
RestClient.Builder |
withLogLevel(LogLevel logLevel)
Sets the HTTP log level.
|
RestClient.Builder |
withMaxIdleConnections(int maxIdleConnections)
Deprecated.
use
withConnectionPool(ConnectionPool) instead |
RestClient.Builder |
withNetworkInterceptor(okhttp3.Interceptor networkInterceptor)
Add an interceptor the network layer of Http client pipeline.
|
RestClient.Builder |
withProtocols(List<okhttp3.Protocol> protocols)
Sets protocols for OkHttp client.
|
RestClient.Builder |
withProxy(Proxy proxy)
Sets the proxy for the HTTP client.
|
RestClient.Builder |
withProxyAuthenticator(okhttp3.Authenticator proxyAuthenticator)
Sets the proxy authenticator for the HTTP client.
|
RestClient.Builder |
withReadTimeout(long timeout,
TimeUnit unit)
Set the read timeout on the HTTP client.
|
RestClient.Builder |
withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)
Sets the response builder factory.
|
RestClient.Builder |
withRetryStrategy(RetryStrategy strategy)
Adds a retry strategy to the client.
|
RestClient.Builder |
withSerializerAdapter(SerializerAdapter<?> serializerAdapter)
Sets the serialization adapter.
|
RestClient.Builder |
withTlsVersions(okhttp3.TlsVersion... tlsVersions)
Sets tls versions for OkHttp client.
|
RestClient.Builder |
withUserAgent(String userAgent)
Sets the user agent header.
|
public Builder()
public Builder(okhttp3.OkHttpClient.Builder httpClientBuilder, retrofit2.Retrofit.Builder retrofitBuilder)
httpClientBuilder
- the builder to build an OkHttpClient
.retrofitBuilder
- the builder to build a Retrofit
.public RestClient.Builder withBaseUrl(String baseUrl)
baseUrl
- the base URL to use.public RestClient.Builder withBaseUrl(Environment environment, Environment.Endpoint endpoint)
environment
- the environment to useendpoint
- the environment endpoint the application is accessingpublic RestClient.Builder withSerializerAdapter(SerializerAdapter<?> serializerAdapter)
serializerAdapter
- the adapter to a serializerpublic RestClient.Builder withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)
responseBuilderFactory
- the response builder factorypublic RestClient.Builder withCredentials(ServiceClientCredentials credentials)
credentials
- the credentials object.public RestClient.Builder withUserAgent(String userAgent)
userAgent
- the user agent header.public RestClient.Builder withLogLevel(LogLevel logLevel)
logLevel
- the LogLevel
enum.public RestClient.Builder withInterceptor(okhttp3.Interceptor interceptor)
interceptor
- the interceptor to add.public RestClient.Builder withNetworkInterceptor(okhttp3.Interceptor networkInterceptor)
networkInterceptor
- the interceptor to add.public RestClient.Builder withReadTimeout(long timeout, TimeUnit unit)
timeout
- the timeout numeric valueunit
- the time unit for the numeric valuepublic RestClient.Builder withConnectionTimeout(long timeout, TimeUnit unit)
timeout
- the timeout numeric valueunit
- the time unit for the numeric value@Deprecated public RestClient.Builder withMaxIdleConnections(int maxIdleConnections)
withConnectionPool(ConnectionPool)
insteadmaxIdleConnections
- the maximum idle connectionspublic RestClient.Builder withConnectionPool(okhttp3.ConnectionPool connectionPool)
connectionPool
- the OkHttp 3 connection pool to usepublic RestClient.Builder useHttpClientThreadPool(boolean useHttpClientThreadPool)
useHttpClientThreadPool
- whether to use the thread pool in Okhttp client. Default is false.public RestClient.Builder withDispatcher(okhttp3.Dispatcher dispatcher)
dispatcher
- the dispatcher to usepublic RestClient.Builder withCallbackExecutor(Executor executor)
executor
- the executor to execute the callbacks.public RestClient.Builder withProxy(Proxy proxy)
proxy
- the proxy to usepublic RestClient.Builder withProxyAuthenticator(okhttp3.Authenticator proxyAuthenticator)
proxyAuthenticator
- the proxy authenticator to usepublic RestClient.Builder withRetryStrategy(RetryStrategy strategy)
strategy
- the retry strategy to addpublic RestClient.Builder withTlsVersions(okhttp3.TlsVersion... tlsVersions)
tlsVersions
- the tls versions to usepublic RestClient.Builder withCipherSuites(okhttp3.CipherSuite... cipherSuites)
cipherSuites
- the cipher suites to usepublic RestClient.Builder withProtocols(List<okhttp3.Protocol> protocols)
protocols
- the protocols used by OkHttp client to communicate with remote serverspublic RestClient build()
RestClient
./**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/