Get a database admin
The Data API clients use the Database Admin class to perform administrative operations, like managing keyspaces, within a specific database.
The Database Admin class name varies by client:
-
Python:
DatabaseAdmin -
TypeScript:
DataAPIDbAdmin -
Java:
DatabaseAdmin
Result
-
Python
-
TypeScript
-
Java
-
curl
Returns an DatabaseAdmin object that can perform administrative actions on the specified database.
Returns a DataAPIDbAdmin object that can perform administrative actions on the specified database.
Returns a DatabaseAdmin object that can perform administrative actions on the specified database.
This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Use the get_database_admin method from the Database class.
Method signature
get_database_admin(
*,
token: str | TokenProvider,
spawn_api_options: APIOptions,
) -> DatabaseAdmin
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The token used by the resulting admin object. The token should have sufficient permissions to perform the desired downstream operations. Default: The token used by the object that called this method. |
|
Optional. A complete or partial specification of ttimeouts. If |
Use the admin method, which belongs to the Db class.
Method signature
admin(
options?: AdminOptions & {
environment?: string
}
): DataAPIDbAdmin
| Name | Type | Summary |
|---|---|---|
|
|
Only for the The database’s environment. Can be one of: "dse", "hcd", "cassandra", "other". |
|
Optional. A specification of options to override the inherited defaults. Use this to customize the interaction of the client with the database admin. For example, you can change the default timeouts or token. |
Use the getDatabaseAdmin method from the com.datastax.astra.client.Database class.
Method signature
DatabaseAdmin getDatabaseAdmin()
DatabaseAdmin getDatabaseAdmin(String superUserToken)
DatabaseAdmin getDatabaseAdmin(AdminOptions adminOptions)
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The token used by the resulting admin object. The token should have sufficient permissions to perform the desired downstream operations. If not specified, the resulting object will use the token used by the object that called this method. |
|
Optional. A specification of options to override the inherited defaults. Use this to customize the interaction of the client with the database admin. For example, you can change the default timeouts. |
This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.
Examples
The following examples demonstrate how to get a database admin object.
Get a database admin from a database
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
from astrapy.constants import Environment
from astrapy.authentication import UsernamePasswordTokenProvider
# Get a database object
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
"API_ENDPOINT",
token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
# Get a database admin object
database_admin = database.get_database_admin()
import {
DataAPIClient,
UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";
// Get a database object
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
// Get a database admin object
const databaseAdmin = database.admin();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.admin.DatabaseAdmin;
import com.datastax.astra.client.databases.Database;
public class Example {
public static void main(String[] args) {
// Get a database object
Database database =
DataAPIClients.clientHCD("USERNAME", "PASSWORD")
.getDatabase("API_ENDPOINT", "KEYSPACE_NAME");
// Get a database admin object
DatabaseAdmin databaseAdmin = database.getDatabaseAdmin();
}
}
This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.
Client reference
-
Python
-
TypeScript
-
Java
-
curl
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.