Class AstraDBAdmin

java.lang.Object
com.datastax.astra.client.admin.AstraDBAdmin

public class AstraDBAdmin extends Object
Main Client for AstraDB, it implements administration and Data Api Operations.
  • Field Details

    • FREE_TIER_CLOUD

      public static final com.dtsx.astra.sdk.db.domain.CloudProviderType FREE_TIER_CLOUD
      Default cloud provider. (free-tier)
    • FREE_TIER_CLOUD_REGION

      public static final String FREE_TIER_CLOUD_REGION
      Default region. (free-tier)
      See Also:
    • TOKEN_HEADER_PARAM

      public static final String TOKEN_HEADER_PARAM
      Header name used to hold the Astra Token.
      See Also:
    • DEFAULT_NAMESPACE

      public static final String DEFAULT_NAMESPACE
      Default keyspace (same created by the ui).
      See Also:
  • Constructor Details

    • AstraDBAdmin

      public AstraDBAdmin(String token, com.dtsx.astra.sdk.utils.AstraEnvironment env, DataAPIOptions options)
      Initialization with an authentication token and target environment, Use this constructor for testing purpose.
      Parameters:
      token - authentication token
      env - astra environment
      options - options for client
  • Method Details

    • listDatabaseNames

      public List<String> listDatabaseNames()
      List available database names.
      Returns:
      list of database names
    • listDatabases

      public List<DatabaseInfo> listDatabases()
      List active databases with vector enabled in current organization.
      Returns:
      active databases list
    • databaseExists

      public boolean databaseExists(String name)
      Return true if the database exists.
      Parameters:
      name - database identifiers
      Returns:
      if the database exits or not
    • databaseExists

      public boolean databaseExists(UUID id)
      Return true if the database exists.
      Parameters:
      id - database identifiers
      Returns:
      if the database exits or not
    • createDatabase

      public DatabaseAdmin createDatabase(String name)
      Create new database with a name on free tier. The database name should not exist in the tenant.
      Parameters:
      name - database name
      Returns:
      database admin object
    • createDatabase

      public DatabaseAdmin createDatabase(String name, com.dtsx.astra.sdk.db.domain.CloudProviderType cloud, String cloudRegion, boolean waitForDb)
      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 name
      cloud - cloud provider
      cloudRegion - cloud region
      waitForDb - if set to true, the method is blocking
      Returns:
      database admin object
    • createDatabase

      public DatabaseAdmin createDatabase(String name, com.dtsx.astra.sdk.db.domain.CloudProviderType cloud, 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 name
      cloud - cloud provider
      cloudRegion - cloud region
      Returns:
      database admin object
    • dropDatabase

      public boolean dropDatabase(@NonNull @NonNull UUID databaseId)
      Delete a Database if exists from its identifier.
      Parameters:
      databaseId - database identifier
      Returns:
      if the db has been deleted
    • dropDatabase

      public boolean dropDatabase(@NonNull @NonNull String databaseName)
      Delete a Database if exists from its name.
      Parameters:
      databaseName - database name
      Returns:
      if the database has been deleted
    • getDatabaseInfo

      public DatabaseInfo getDatabaseInfo(@NonNull @NonNull UUID id)
      Find database information from its id.
      Parameters:
      id - database identifier
      Returns:
      the bean representing an Astra database
    • getDatabase

      public Database getDatabase(UUID databaseId, String namespace)
      Access the database functions.
      Parameters:
      databaseId - database identifier
      namespace - target namespace name
      Returns:
      database client
    • getDatabase

      public Database getDatabase(UUID databaseId)
      Access the database functions.
      Parameters:
      databaseId - database identifier
      Returns:
      database client
    • getDatabaseAdmin

      public AstraDBDatabaseAdmin getDatabaseAdmin(UUID databaseId)
      Access the database functions.
      Parameters:
      databaseId - database identifier
      Returns:
      database client