Package com.dtsx.astra.sdk
Class AstraDBAdmin
java.lang.Object
com.dtsx.astra.sdk.AstraDBAdmin
Client for AstraDB at organization level (crud for databases).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault timeout for initiating connection.static final StringDefault keyspace name if not provided by user.static final CloudProviderTypeDefault cloud provider if not provided by user.static final StringDefault region if not provided by user.static final StringHeader name used to hold the Astra Token.static final String -
Constructor Summary
ConstructorsConstructorDescriptionDefault initialization, the token is retrieved from environment variableASTRA_DB_APPLICATION_TOKENor from file~/.astrarc, sectiondefault, keyASTRA_DB_APPLICATION_TOKEN.AstraDBAdmin(String token) Initialization with an authentification token, defaulting to production environment.AstraDBAdmin(String token, AstraEnvironment env) Initialization with an authentification token and target environment, Use this constructor for testing purpose. -
Method Summary
Modifier and TypeMethodDescriptioncreateDatabase(@NonNull String name) Create new database with a name on free tier.createDatabase(@NonNull String name, @NonNull CloudProviderType cloud, @NonNull String cloudRegion) Create new database with a name on the specified cloud provider and region.voidcreateKeyspace(String databaseName, String keyspaceName) Create a keyspace.voidcreateKeyspace(UUID databaseId, String keyspaceName) Create a keyspace.voiddeleteKeyspace(String databaseName, String keyspaceName) Delete a keyspace.voiddeleteKeyspace(UUID databaseId, String keyspaceName) Delete a keyspace.booleandropDatabase(@NonNull String name) Delete a Database if exists from its namebooleandropDatabase(@NonNull UUID databaseId) Delete a Database if exists from its nameio.stargate.sdk.data.DataApiClientgetDataApiClient(@NonNull String databaseName) Access database functions.io.stargate.sdk.data.DataApiClientgetDataApiClient(@NonNull UUID databaseId) Access database functions.getDatabase(@NonNull String databaseName) Access the database functions.getDatabase(UUID databaseId) Access the database functions.Retrieve list of all Databases of the account and filter on namegetDatabaseInformations(@NonNull UUID id) Find a database from its id.Access the devops client.booleanisDatabaseExists(String name) Check if a database exists.List available database names.List active databases with vector enabled in current organization.static voidsetCallerName(String callerName, String callerVersion) Allow user to set the client namevoidwatch()
-
Field Details
-
USER_AGENT
- See Also:
-
CONNECT_TIMEOUT_SECONDS
public static final int CONNECT_TIMEOUT_SECONDSDefault timeout for initiating connection.- See Also:
-
FREE_TIER_CLOUD
Default cloud provider if not provided by user. (free-tier) -
FREE_TIER_CLOUD_REGION
Default region if not provided by user. (free-tier)- See Also:
-
TOKEN_HEADER_PARAM
Header name used to hold the Astra Token.- See Also:
-
DEFAULT_KEYSPACE
Default keyspace name if not provided by user.- See Also:
-
-
Constructor Details
-
AstraDBAdmin
public AstraDBAdmin()Default initialization, the token is retrieved from environment variableASTRA_DB_APPLICATION_TOKENor from file~/.astrarc, sectiondefault, keyASTRA_DB_APPLICATION_TOKEN. -
AstraDBAdmin
Initialization with an authentification token, defaulting to production environment.- Parameters:
token- authentication token
-
AstraDBAdmin
Initialization with an authentification token and target environment, Use this constructor for testing purpose.- Parameters:
token- authentication tokenenv- target Astra environment
-
-
Method Details
-
setCallerName
Allow user to set the client name- Parameters:
callerName- client namecallerVersion- client version
-
watch
public void watch() -
createKeyspace
Create a keyspace.- Parameters:
databaseName- database namekeyspaceName- keyspace name
-
createKeyspace
Create a keyspace.- Parameters:
databaseId- database unique identifierkeyspaceName- keyspace name
-
deleteKeyspace
Delete a keyspace.- Parameters:
databaseName- database namekeyspaceName- keyspace name
-
deleteKeyspace
Delete a keyspace.- Parameters:
databaseId- database unique identifierkeyspaceName- keyspace name
-
listDatabaseNames
List available database names.- Returns:
- list of database names
-
listDatabases
List active databases with vector enabled in current organization.- Returns:
- active databases list
-
createDatabase
Create new database with a name on free tier. The database name should not exist in the tenant.- Parameters:
name- database name- Returns:
- database identifier
-
createDatabase
public UUID createDatabase(@NonNull @NonNull String name, @NonNull @NonNull CloudProviderType cloud, @NonNull @NonNull String cloudRegion) Create new database with a name on the specified cloud provider and region. If the database with same name already exists it will be resumed if not active. The method will wait for the database to be active.- Parameters:
name- database namecloud- cloud providercloudRegion- cloud region- Returns:
- database identifier
-
dropDatabase
Delete a Database if exists from its name- Parameters:
name- database name- Returns:
- if the db has been deleted
-
dropDatabase
Delete a Database if exists from its name- Parameters:
databaseId- database identifier- Returns:
- if the db has been deleted
-
getDatabaseInformations
Retrieve list of all Databases of the account and filter on name- Parameters:
name- a database name- Returns:
- list of db matching the criteria
-
isDatabaseExists
Check if a database exists.- Parameters:
name- a database name- Returns:
- if the database exists
-
getDatabaseInformations
Find a database from its id.- Parameters:
id- a database name- Returns:
- list of db matching the criteria
-
getDatabase
Access the database functions.- Parameters:
databaseName- database name- Returns:
- database client
-
getDatabase
Access the database functions.- Parameters:
databaseId- database identifier- Returns:
- database client
-
getDataApiClient
Access database functions.- Parameters:
databaseName- database name- Returns:
- database client
-
getDataApiClient
Access database functions.- Parameters:
databaseId- database identifier- Returns:
- database client
-
getDevopsApiClient
Access the devops client.- Returns:
- devops client.
-