List keyspaces
Lists all keyspaces in a database.
|
You need an application token with permission to interact with the target database, such as the Database Administrator role. For more information, see Get endpoint and token. |
Result
-
Python
-
TypeScript
-
Java
-
curl
Returns the keyspace names as an unordered list of strings.
Returns a promise that resolves to the keyspace names as a list of strings, with the default keyspace first and the remaining keyspaces in any order.
Returns the keyspace names as a Set of strings.
Returns the keyspace names as an unordered list of strings in the status.keyspaces field of the response.
Example response:
{
"status": {
"keyspaces":[
"default_keyspace",
"another_keyspace"
]
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Use the list_keyspaces method, which belongs to the astrapy.DataAPIDatabaseAdmin class.
Method signature
list_keyspaces(
*,
keyspace_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> None
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the This parameter is aliased as |
Use the listKeyspaces method, which belongs to the DataAPIDbAdmin class.
Method signature
async listKeyspaces(
options?: {
timeout?: number | TimeoutDescriptor,
}
): void
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
The options for this operation. See Properties of |
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The timeout(s) to apply to this method.
You can specify Details about the
|
Use the listKeyspaceNames method, which belongs to the com.datastax.astra.client.admin.DatabaseAdmin class.
Method signature
Set<String> listKeyspaceNames()
This method does not accept any parameters.
Use the findKeyspaces command.
Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"findKeyspaces": {}
}'
This command does not accept any options.
Examples
The following examples demonstrate how to list keyspaces.
List keyspaces
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
# Get an admin object
admin = database.get_database_admin()
# List keyspaces
keyspaces = admin.list_keyspaces()
print(keyspaces)
import { DataAPIClient } from "@datastax/astra-db-ts";
// Get a database
const client = new DataAPIClient();
const database = client.db("API_ENDPOINT", {
token: "APPLICATION_TOKEN",
});
// Get an admin object
const admin = database.admin();
// List keyspaces
(async function () {
const keyspaces = await admin.listKeyspaces();
console.log(keyspaces);
})();
import com.datastax.astra.client.DataAPIClient;
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
Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");
// Get an admin object
DatabaseAdmin admin = database.getDatabaseAdmin();
// List keyspaces
admin.listKeyspaceNames();
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"findKeyspaces": {}
}'
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.