Package com.datastax.astra.client
Class DataAPIOptions.DataAPIClientOptionsBuilder
java.lang.Object
com.datastax.astra.client.DataAPIOptions.DataAPIClientOptionsBuilder
- Enclosing class:
DataAPIOptions
Builder for the DataAPIClientOptions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the options.Help to enable loggin requests.withApiVersion
(String apiVersion) Builder pattern, update api version.withCaller
(String callerName, String callerVersion) Builder pattern, update caller information.withDestination
(DataAPIOptions.DataAPIDestination destination) Builder pattern, update http connection TimeoutwithEmbeddingAPIKey
(String embeddingAPIKey) Builder pattern, update http connection TimeoutwithEmbeddingAuthProvider
(EmbeddingHeadersProvider embeddingAuthProvider) Builder pattern, update authentication provider for vectorize.withHtpVersion
(HttpClient.Version version) Builder pattern, update http versionwithHttpConnectTimeout
(int requestTimeout) Builder pattern, update http connection TimeoutwithHttpProxy
(DataAPIOptions.HttpProxy httpProxy) Builder pattern, update http httpProxywithHttpRedirect
(HttpClient.Redirect redirect) Builder pattern, update http redirectwithHttpRetryCount
(int retryCount) Builder pattern, update http retry countwithHttpRetryDelayMillis
(int retryDelay) Sets the delay between retry attempts when the number of retries is greater than 1.withMaxDocumentCount
(int maxDocumentCount) Sets the maximum number of documents that can be returned by the count function.withMaxDocumentsInInsert
(int maxDocumentsInInsert) Sets the maximum number of documents that can be inserted in a single operation.withMaxPageSize
(int maxPageSize) Sets the maximum number of documents that can be returned in a single page.withMaxTimeMS
(long connectTimeout) Builder pattern, update http request Timeout in milliswithObserver
(CommandObserver observer) Register an observer with its className.withObserver
(String name, CommandObserver observer) Allow to register a listener for the command.
-
Constructor Details
-
DataAPIClientOptionsBuilder
public DataAPIClientOptionsBuilder()Default constructor.
-
-
Method Details
-
withCaller
public DataAPIOptions.DataAPIClientOptionsBuilder withCaller(String callerName, String callerVersion) Builder pattern, update caller information. o- Parameters:
callerName
- caller name in the user agentcallerVersion
- caller version in the user agent- Returns:
- self reference
-
withApiVersion
Builder pattern, update api version.- Parameters:
apiVersion
- api version- Returns:
- self reference
-
withHttpRedirect
Builder pattern, update http redirect- Parameters:
redirect
- http redirect- Returns:
- self reference
-
withHtpVersion
Builder pattern, update http version- Parameters:
version
- http version- Returns:
- self reference
-
withHttpProxy
Builder pattern, update http httpProxy- Parameters:
httpProxy
- http proxy- Returns:
- self reference
-
withHttpRetryCount
Builder pattern, update http retry count- Parameters:
retryCount
- http retry count- Returns:
- self reference
-
withMaxTimeMS
Builder pattern, update http request Timeout in millis- Parameters:
connectTimeout
- http request timeout in millis- Returns:
- self reference
-
withEmbeddingAPIKey
Builder pattern, update http connection Timeout- Parameters:
embeddingAPIKey
- embedding API Key- Returns:
- self reference
-
withEmbeddingAuthProvider
public DataAPIOptions.DataAPIClientOptionsBuilder withEmbeddingAuthProvider(EmbeddingHeadersProvider embeddingAuthProvider) Builder pattern, update authentication provider for vectorize.- Parameters:
embeddingAuthProvider
- embedding authentication provider- Returns:
- self reference
-
withHttpConnectTimeout
Builder pattern, update http connection Timeout- Parameters:
requestTimeout
- http request timeout- Returns:
- self reference
-
withDestination
public DataAPIOptions.DataAPIClientOptionsBuilder withDestination(DataAPIOptions.DataAPIDestination destination) Builder pattern, update http connection Timeout- Parameters:
destination
- data api destination- Returns:
- self reference
-
withHttpRetryDelayMillis
Sets the delay between retry attempts when the number of retries is greater than 1. This allows configuring the interval to wait before initiating a subsequent retry after a failed attempt. The delay is specified in milliseconds.If not explicitly set, the default delay is defined by
DEFAULT_RETRY_DELAY_MILLIS
, which is 100 milliseconds.Usage of this method is crucial in scenarios where repeated requests are made and a gentle back-off strategy is desired to reduce the load on the server or to handle temporary network issues gracefully.
- Parameters:
retryDelay
- the delay between two retry attempts, expressed in milliseconds. Must be a non-negative number.- Returns:
- a reference to this builder, allowing for method chaining.
Example usage:
DataAPIClientOptions .builder() .withHttpRetryDelayMillis(200); // Sets a 200ms delay between retries.
-
withMaxDocumentCount
Sets the maximum number of documents that can be returned by the count function.If not explicitly set, the default value is defined by
MAX_DOCUMENTS_COUNT
, which is 1000 documents.- Parameters:
maxDocumentCount
- the maximum number of documents that can be returned by the count function. Must be a positive number.- Returns:
- a reference to this builder, allowing for method chaining.
Example usage:
DataAPIClientOptions .builder() .withMaxDocumentCount(2000); // Sets the maximum number of documents to 2000.
-
withMaxPageSize
Sets the maximum number of documents that can be returned in a single page.If not explicitly set, the default value is defined by
MAX_PAGE_SIZE
, which is 20 documents.- Parameters:
maxPageSize
- the maximum number of documents that can be returned in a single page. Must be a positive number.- Returns:
- a reference to this builder, allowing for method chaining.
Example usage:
DataAPIClientOptions .builder() .withMaxPageSize(50); // Sets the maximum page size to 50 documents.
-
withMaxDocumentsInInsert
public DataAPIOptions.DataAPIClientOptionsBuilder withMaxDocumentsInInsert(int maxDocumentsInInsert) Sets the maximum number of documents that can be inserted in a single operation.If not explicitly set, the default value is defined by
MAX_DOCUMENTS_IN_INSERT
, which is 20 documents.- Parameters:
maxDocumentsInInsert
- the maximum number of documents that can be inserted in a single operation. Must be a positive number.- Returns:
- a reference to this builder, allowing for method chaining.
Example usage:
DataAPIClientOptions .builder() .withMaxDocumentsInInsert(50); // Sets the maximum number of documents to insert to 50.
-
withObserver
public DataAPIOptions.DataAPIClientOptionsBuilder withObserver(String name, CommandObserver observer) Allow to register a listener for the command.- Parameters:
name
- name of the observerobserver
- observer to register- Returns:
- instance of the command options
-
withObserver
Register an observer with its className.- Parameters:
observer
- command observer- Returns:
- instance of the command options
-
logRequests
Help to enable loggin requests.- Returns:
- current reference
-
build
Build the options.- Returns:
- options
-