List keyspaces (C#)
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
Returns the keyspace names as an unordered list of strings.
Parameters
Use the ListKeyspacesAsync method, which belongs to the IDatabaseAdmin class.
You can also use ListKeyspaces, which is the synchronous version of the method.
Method signature
Task<IEnumerable<string>> ListKeyspacesAsync(
ListKeyspacesOptions options = null
);
Parameters:
| Name | Type | Summary |
|---|---|---|
|
General API options for this operation, including the timeout. For more information and examples, see Customize API interaction. |
Examples
The following examples demonstrate how to list keyspaces.
List keyspaces
using DataStax.AstraDB.DataApi;
namespace Examples;
public class Program
{
static async Task Main()
{
// Get an existing database
var client = new DataAPIClient();
var database = client.GetDatabase(
"API_ENDPOINT",
"APPLICATION_TOKEN"
);
var databaseAdmin = database.GetAdmin();
await databaseAdmin.ListKeyspacesAsync();
}
}
Client reference
For more information, see the client reference.