RestClient Class

  • java.lang.Object
    • com.microsoft.bot.restclient.RestClient

public final class RestClient

An instance of this class stores the client information for making REST calls.

Method Summary

Modifier and Type Method and Description
void close()

Closes the HTTP client and recycles the resources associated.

void closeAndWait()

Closes the HTTP client, recycles the resources associated, and waits for 60 seconds for all the threads to be recycled.

ServiceClientCredentials credentials()
CustomHeadersInterceptor headers()
okhttp3.OkHttpClient httpClient()
LogLevel logLevel()
Builder newBuilder()

Create a new builder for a new Rest Client with the same configurations on this one.

Factory responseBuilderFactory()
retrofit2.Retrofit retrofit()
SerializerAdapter<?> serializerAdapter()
RestClient withLogLevel(LogLevel logLevel)

Set the current HTTP traffic logging level.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

close

public void close()

Closes the HTTP client and recycles the resources associated. The threads will be recycled after 60 seconds of inactivity.

closeAndWait

public void closeAndWait()

Closes the HTTP client, recycles the resources associated, and waits for 60 seconds for all the threads to be recycled.

Throws:

java.lang.InterruptedException - thrown when the 60-sec wait is interrupted

credentials

public ServiceClientCredentials credentials()

Returns:

the credentials attached to this REST client

headers

public CustomHeadersInterceptor headers()

Returns:

the headers interceptor.

httpClient

public OkHttpClient httpClient()

Returns:

the OkHttpClient instance

logLevel

public LogLevel logLevel()

Returns:

the current HTTP traffic logging level

newBuilder

public RestClient.Builder newBuilder()

Create a new builder for a new Rest Client with the same configurations on this one.

Returns:

a RestClient builder

responseBuilderFactory

public ResponseBuilder.Factory responseBuilderFactory()

Returns:

the current respnose builder factory.

retrofit

public Retrofit retrofit()

Returns:

the Retrofit instance

serializerAdapter

public SerializerAdapter serializerAdapter()

Returns:

the current serializer adapter.

withLogLevel

public RestClient withLogLevel(LogLevel logLevel)

Set the current HTTP traffic logging level.

Parameters:

logLevel - the logging level enum

Returns:

the RestClient itself

Applies to