Class AstraDBAdmin

java.lang.Object
com.dtsx.astra.sdk.AstraDBAdmin

public class AstraDBAdmin extends Object
Client for AstraDB at organization level (crud for databases).
  • Field Details

    • CONNECT_TIMEOUT_SECONDS

      public static final int CONNECT_TIMEOUT_SECONDS
      Default timeout for initiating connection.
      See Also:
    • FREE_TIER_CLOUD

      public static final CloudProviderType FREE_TIER_CLOUD
      Default cloud provider if not provided by user. (free-tier)
    • FREE_TIER_CLOUD_REGION

      public static final String FREE_TIER_CLOUD_REGION
      Default region if not provided by user. (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_KEYSPACE

      public static final String 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 variable ASTRA_DB_APPLICATION_TOKEN or from file ~/.astrarc, section default, key ASTRA_DB_APPLICATION_TOKEN.
    • AstraDBAdmin

      public AstraDBAdmin(String token)
      Initialization with an authentification token, defaulting to production environment.
      Parameters:
      token - authentication token
    • AstraDBAdmin

      public AstraDBAdmin(String token, AstraEnvironment env)
      Initialization with an authentification token and target environment, Use this constructor for testing purpose.
      Parameters:
      token - authentication token
      env - target Astra environment
  • Method Details

    • findAllDatabases

      public Stream<Database> findAllDatabases()
      List active databases with vector enabled in current organization.
      Returns:
      active databases list
    • createDatabase

      public UUID createDatabase(@NonNull @NonNull 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 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 name
      cloud - cloud provider
      cloudRegion - cloud region
      Returns:
      database identifier
    • deleteDatabaseByName

      public boolean deleteDatabaseByName(@NonNull @NonNull String name)
      Delete a Database if exists from its name
      Parameters:
      name - database name
      Returns:
      if the db has been deleted
    • deleteDatabaseById

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

      public Stream<Database> findDatabaseByName(String name)
      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

      public boolean isDatabaseExists(String name)
      Check if a database exists.
      Parameters:
      name - a database name
      Returns:
      if the database exists
    • findDatabaseById

      public Optional<Database> findDatabaseById(@NonNull @NonNull UUID id)
      Find a database from its id.
      Parameters:
      id - a database name
      Returns:
      list of db matching the criteria
    • database

      public AstraDB database(@NonNull @NonNull String databaseName)
      Access the database functions.
      Parameters:
      databaseName - database name
      Returns:
      database client
    • database

      public AstraDB database(UUID databaseId)
      Access the database functions.
      Parameters:
      databaseId - database identifier
      Returns:
      database client
    • getDataApiClient

      public io.stargate.sdk.data.DataApiClient getDataApiClient(@NonNull @NonNull String databaseName)
      Access database functions.
      Parameters:
      databaseName - database name
      Returns:
      database client
    • getDataApiClient

      public io.stargate.sdk.data.DataApiClient getDataApiClient(@NonNull @NonNull UUID databaseId)
      Access database functions.
      Parameters:
      databaseId - database identifier
      Returns:
      database client
    • getDevopsApiClient

      public AstraDBOpsClient getDevopsApiClient()
      Access the devops client.
      Returns:
      devops client.