Package com.datastax.astra.sdk.config
Class AstraClientConfig
java.lang.Object
com.datastax.astra.sdk.config.AstraClientConfig
- All Implemented Interfaces:
Serializable
Helper and configure for Astra.
- Author:
- Cedrick LUNVEN (@clunven)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ENV VAR to get part of the token: client id.static final String
ENV VAR to get part of the token: client Secret.static final String
Initialize parameters from Environment variables.static final String
ENV VAR to get the keyspace to be selected.static final String
ENV VAR to get current or default region (local datacenter).static final String
SECURE BUNDLE FOR EACH REGIONS.static final String
Where to download cloud secure bundles.static final String
User home folder.static final int
Port for grpc in Astra. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddHttpObserver
(String name, io.stargate.sdk.audit.ServiceCallObserver observer) Api Invocations trigger some events processed in observer.build()
Final build.static String
buildScbFileName
(String dId, String dbRegion) Helper to build the path (use multiple times).Disable crossRegionFailOverDisable SCB downloads.Enable CqlSessionEnable crossRegionFailOverEnable SCB downloads.Enable gRPCGetter accessor for attribute 'clientId'.Getter accessor for attribute 'clientSecret'.Getter accessor for attribute 'databaseId'.Getter accessor for attribute 'databaseRegion'.Getter accessor for attribute 'secureConnectBundleFolder'.io.stargate.sdk.StargateClientBuilder
Getter accessor for attribute 'stargateConfig'.getToken()
Getter accessor for attribute 'token'.boolean
Getter for crossRegionFailOver.boolean
Getter for downloadSecureConnectBundle.Some settings can be loaded from ~/.astrarc in you machine.Provide path of the SCB.withClientId
(String clientId) Provide clientId.withClientSecret
(String clientSecret) Provide clientSecret.withCqlCloudSecureConnectBundle
(String scbFile) Populate Secure connect bundlewithCqlConsistencyLevel
(com.datastax.oss.driver.api.core.ConsistencyLevel cl) Populate Consistency levelwithCqlDriverConfig
(com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder conf) Populate config.withCqlDriverConfigurationFile
(File configFile) Populate configuration filewithCqlKeyspace
(String keyspace) Fill Keyspaces.Provide a metrics registry.withCqlOptionBoolean
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Boolean> option, Boolean du) Add a property to the Cql Context.withCqlOptionBooleanDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Boolean> option, Boolean du) Add a property to the Cql Context.withCqlOptionBooleanList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Boolean>> option, List<Boolean> du) Add a property to the Cql Context.withCqlOptionBooleanListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Boolean>> option, List<Boolean> du) Add a property to the Cql Context.withCqlOptionClass
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Class<?>> option, Class<?> du) Add a property to the Cql Context.withCqlOptionClassDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Class<?>> option, Class<?> du) Add a property to the Cql Context.withCqlOptionClassList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Class<?>>> option, List<Class<?>> du) Add a property to the Cql Context.withCqlOptionClassListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Class<?>>> option, List<Class<?>> du) Add a property to the Cql Context.withCqlOptionDouble
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Double> option, Double du) Add a property to the Cql Context.withCqlOptionDoubleDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Double> option, Double du) Add a property to the Cql Context.withCqlOptionDoubleList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Double>> option, List<Double> du) Add a property to the Cql Context.withCqlOptionDoubleListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Double>> option, List<Double> du) Add a property to the Cql Context.withCqlOptionDuration
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Duration> option, Duration du) Add a property to the Cql Context.withCqlOptionDurationDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Duration> option, Duration du) Add a property to the Cql Context.withCqlOptionDurationList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Duration>> option, List<Duration> du) Add a property to the Cql Context.withCqlOptionDurationListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Duration>> option, List<Duration> du) Add a property to the Cql Context.withCqlOptionInteger
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Integer> option, Integer du) Add a property to the Cql Context.withCqlOptionIntegerDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Integer> option, Integer du) Add a property to the Cql Context.withCqlOptionIntegerList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Integer>> option, List<Integer> du) Add a property to the Cql Context.withCqlOptionIntegerListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Integer>> option, List<Integer> du) Add a property to the Cql Context.withCqlOptionLong
(com.datastax.oss.driver.api.core.config.TypedDriverOption<Long> option, Long du) Add a property to the Cql Context.withCqlOptionLongDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Long> option, Long du) Add a property to the Cql Context.withCqlOptionLongList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Long>> option, List<Long> du) Add a property to the Cql Context.withCqlOptionLongListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Long>> option, List<Long> du) Add a property to the Cql Context.withCqlOptionString
(com.datastax.oss.driver.api.core.config.TypedDriverOption<String> option, String du) Add a property to the Cql Context.withCqlOptionStringDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<String> option, String du) Add a property to the Cql Context.withCqlOptionStringList
(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<String>> option, List<String> du) Add a property to the Cql Context.withCqlOptionStringListDC
(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<String>> option, List<String> du) Add a property to the Cql Context.withCqlRequestTracker
(com.datastax.oss.driver.api.core.tracker.RequestTracker rt) Provide a request tracker.withCqlSecureConnectBundleFolder
(String scbPath) Provide clientSecret.withDatabaseId
(String databaseId) Provider database identifierwithDatabaseRegion
(String databaseRegion) Provider database identifierwithHttpObservers
(Map<String, io.stargate.sdk.audit.ServiceCallObserver> observers) Api Invocations trigger some events processed in observer.withHttpRequestConfig
(org.apache.hc.client5.http.config.RequestConfig reqConfig) Enable fine Grained configuration of the HTTP Client.withHttpRetryConfig
(com.evanlennick.retry4j.config.RetryConfig retryConfig) Enable fine Grained configuration of the HTTP Retries.Provide token.
-
Field Details
-
ENV_USER_HOME
User home folder.- See Also:
-
DEFAULT_SCB_FOLDER
Where to download cloud secure bundles. -
ASTRA_DB_ID
Initialize parameters from Environment variables.- See Also:
-
ASTRA_DB_REGION
ENV VAR to get current or default region (local datacenter).- See Also:
-
ASTRA_DB_CLIENT_ID
ENV VAR to get part of the token: client id.- See Also:
-
ASTRA_DB_CLIENT_SECRET
ENV VAR to get part of the token: client Secret.- See Also:
-
ASTRA_DB_KEYSPACE
ENV VAR to get the keyspace to be selected.- See Also:
-
ASTRA_DB_SCB_FOLDER
SECURE BUNDLE FOR EACH REGIONS.- See Also:
-
GRPC_PORT
public static final int GRPC_PORTPort for grpc in Astra.- See Also:
-
-
Constructor Details
-
AstraClientConfig
public AstraClientConfig()Reading environment variables
-
-
Method Details
-
withToken
Provide token.- Parameters:
applicationToken
- token- Returns:
- self reference
-
withClientId
Provide clientId.- Parameters:
clientId
- clientId- Returns:
- self reference
-
withClientSecret
Provide clientSecret.- Parameters:
clientSecret
- clientSecret- Returns:
- self reference
-
getToken
Getter accessor for attribute 'token'.- Returns:
- current value of 'token'
-
getClientId
Getter accessor for attribute 'clientId'.- Returns:
- current value of 'clientId'
-
getClientSecret
Getter accessor for attribute 'clientSecret'.- Returns:
- current value of 'clientSecret'
-
withDatabaseId
Provider database identifier- Parameters:
databaseId
- databaseId- Returns:
- self reference
-
withDatabaseRegion
Provider database identifier- Parameters:
databaseRegion
- databaseRegion- Returns:
- self reference
-
getDatabaseId
Getter accessor for attribute 'databaseId'.- Returns:
- current value of 'databaseId'
-
getDatabaseRegion
Getter accessor for attribute 'databaseRegion'.- Returns:
- current value of 'databaseRegion'
-
getStargateConfig
public io.stargate.sdk.StargateClientBuilder getStargateConfig()Getter accessor for attribute 'stargateConfig'.- Returns:
- current value of 'stargateConfig'
-
withHttpRequestConfig
public AstraClientConfig withHttpRequestConfig(org.apache.hc.client5.http.config.RequestConfig reqConfig) Enable fine Grained configuration of the HTTP Client.- Parameters:
reqConfig
- request configuration- Returns:
- self reference
-
withHttpRetryConfig
public AstraClientConfig withHttpRetryConfig(com.evanlennick.retry4j.config.RetryConfig retryConfig) Enable fine Grained configuration of the HTTP Retries.- Parameters:
retryConfig
- retry configuration- Returns:
- self reference
-
addHttpObserver
public AstraClientConfig addHttpObserver(String name, io.stargate.sdk.audit.ServiceCallObserver observer) Api Invocations trigger some events processed in observer.- Parameters:
name
- unique identifierobserver
- instance of your Observer- Returns:
- self reference
-
withHttpObservers
public AstraClientConfig withHttpObservers(Map<String, io.stargate.sdk.audit.ServiceCallObserver> observers) Api Invocations trigger some events processed in observer.- Parameters:
observers
- observers lists- Returns:
- self reference
-
enableGrpc
Enable gRPC- Returns:
- reference enforcing cqlSession disabled
-
getSecureConnectBundleFolder
Getter accessor for attribute 'secureConnectBundleFolder'.- Returns:
- current value of 'secureConnectBundleFolder'
-
secureConnectBundleFolder
Provide path of the SCB.- Parameters:
path
- target scb- Returns:
- reference to current scb
-
isEnabledDownloadSecureConnectBundle
public boolean isEnabledDownloadSecureConnectBundle()Getter for downloadSecureConnectBundle.- Returns:
- downloadSecureConnectBundle value
-
isEnabledCrossRegionFailOver
public boolean isEnabledCrossRegionFailOver()Getter for crossRegionFailOver.- Returns:
- crossRegionFailOver value
-
enableDownloadSecureConnectBundle
Enable SCB downloads.- Returns:
- current reference.
-
enableCrossRegionFailOver
Enable crossRegionFailOver- Returns:
- current reference.
-
disableDownloadSecureConnectBundle
Disable SCB downloads.- Returns:
- current reference.
-
disableCrossRegionFailOver
Disable crossRegionFailOver- Returns:
- current reference.
-
withCqlCloudSecureConnectBundle
Populate Secure connect bundle- Parameters:
scbFile
- path of cloud secure bundle- Returns:
- current reference
-
enableCql
Enable CqlSession- Returns:
- reference enforcing cqlSession disabled
-
withCqlDriverConfig
public AstraClientConfig withCqlDriverConfig(com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder conf) Populate config.- Parameters:
conf
- configuration- Returns:
- current reference
-
withCqlConsistencyLevel
public AstraClientConfig withCqlConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel cl) Populate Consistency level- Parameters:
cl
- consistency level- Returns:
- current reference
-
withCqlDriverConfigurationFile
Populate configuration file- Parameters:
configFile
- configuration file- Returns:
- current reference
-
withCqlKeyspace
Fill Keyspaces.- Parameters:
keyspace
- keyspace name- Returns:
- current reference
-
withCqlOptionBoolean
public AstraClientConfig withCqlOptionBoolean(com.datastax.oss.driver.api.core.config.TypedDriverOption<Boolean> option, Boolean du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionBooleanDC
public AstraClientConfig withCqlOptionBooleanDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Boolean> option, Boolean du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionBooleanList
public AstraClientConfig withCqlOptionBooleanList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Boolean>> option, List<Boolean> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionBooleanListDC
public AstraClientConfig withCqlOptionBooleanListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Boolean>> option, List<Boolean> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionClass
public AstraClientConfig withCqlOptionClass(com.datastax.oss.driver.api.core.config.TypedDriverOption<Class<?>> option, Class<?> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionClassDC
public AstraClientConfig withCqlOptionClassDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Class<?>> option, Class<?> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionClassList
public AstraClientConfig withCqlOptionClassList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Class<?>>> option, List<Class<?>> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionClassListDC
public AstraClientConfig withCqlOptionClassListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Class<?>>> option, List<Class<?>> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDouble
public AstraClientConfig withCqlOptionDouble(com.datastax.oss.driver.api.core.config.TypedDriverOption<Double> option, Double du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDoubleDC
public AstraClientConfig withCqlOptionDoubleDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Double> option, Double du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDoubleList
public AstraClientConfig withCqlOptionDoubleList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Double>> option, List<Double> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDoubleListDC
public AstraClientConfig withCqlOptionDoubleListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Double>> option, List<Double> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDuration
public AstraClientConfig withCqlOptionDuration(com.datastax.oss.driver.api.core.config.TypedDriverOption<Duration> option, Duration du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDurationDC
public AstraClientConfig withCqlOptionDurationDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Duration> option, Duration du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDurationList
public AstraClientConfig withCqlOptionDurationList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Duration>> option, List<Duration> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionDurationListDC
public AstraClientConfig withCqlOptionDurationListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Duration>> option, List<Duration> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionInteger
public AstraClientConfig withCqlOptionInteger(com.datastax.oss.driver.api.core.config.TypedDriverOption<Integer> option, Integer du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionIntegerDC
public AstraClientConfig withCqlOptionIntegerDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Integer> option, Integer du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionIntegerList
public AstraClientConfig withCqlOptionIntegerList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Integer>> option, List<Integer> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionIntegerListDC
public AstraClientConfig withCqlOptionIntegerListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Integer>> option, List<Integer> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionLong
public AstraClientConfig withCqlOptionLong(com.datastax.oss.driver.api.core.config.TypedDriverOption<Long> option, Long du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionLongDC
public AstraClientConfig withCqlOptionLongDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<Long> option, Long du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionLongList
public AstraClientConfig withCqlOptionLongList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Long>> option, List<Long> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionLongListDC
public AstraClientConfig withCqlOptionLongListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<Long>> option, List<Long> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionString
public AstraClientConfig withCqlOptionString(com.datastax.oss.driver.api.core.config.TypedDriverOption<String> option, String du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionStringDC
public AstraClientConfig withCqlOptionStringDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<String> option, String du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionStringList
public AstraClientConfig withCqlOptionStringList(com.datastax.oss.driver.api.core.config.TypedDriverOption<List<String>> option, List<String> du) Add a property to the Cql Context.- Parameters:
option
- current optiondu
- option value- Returns:
- current reference
-
withCqlOptionStringListDC
public AstraClientConfig withCqlOptionStringListDC(String dc, com.datastax.oss.driver.api.core.config.TypedDriverOption<List<String>> option, List<String> du) Add a property to the Cql Context.- Parameters:
dc
- stargate datacenteroption
- current optiondu
- option value- Returns:
- current reference
-
withCqlMetricsRegistry
Provide a metrics registry.- Parameters:
mr
- metrics registry- Returns:
- self reference
-
withCqlRequestTracker
public AstraClientConfig withCqlRequestTracker(com.datastax.oss.driver.api.core.tracker.RequestTracker rt) Provide a request tracker.- Parameters:
rt
- request tracker- Returns:
- self reference
-
withCqlSecureConnectBundleFolder
Provide clientSecret.- Parameters:
scbPath
- secure bundle- Returns:
- self reference
-
buildScbFileName
Helper to build the path (use multiple times).- Parameters:
dId
- database iddbRegion
- database region- Returns:
- filename
-
loadFromAstraRc
Some settings can be loaded from ~/.astrarc in you machine.- Returns:
- AstraClientBuilder configuration
-
build
Final build.- Returns:
- return the target object
-