Table of Contents

Class DatabaseAdminAstra

Namespace
DataStax.AstraDB.DataApi.Admin
Assembly
DataStax.AstraDB.DataApi.dll

Provides administrative operations for an Astra database, including keyspace management and embedding provider discovery. This class is used internally by the Astra client library to execute privileged actions against a specific database.

public class DatabaseAdminAstra : IDatabaseAdmin
Inheritance
DatabaseAdminAstra
Implements
Inherited Members

Remarks

This implementation of IDatabaseAdmin supports synchronous and asynchronous methods for listing, creating, and dropping keyspaces, as well as querying embedding providers.

Properties

Id

The database Guid (as a string).

public string Id { get; }

Property Value

string

Methods

CreateKeyspace(string, CreateKeyspaceOptions)

public void CreateKeyspace(string keyspace, CreateKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to create.

options CreateKeyspaceOptions

Optional settings that influence request execution.

Examples

await admin.CreateKeyspaceAsync("myKeyspace");

Remarks

This method, by default, will wait for the operation to complete on the server side. Use the options' waitForCompletion attribute to control this behaviour.

CreateKeyspaceAsync(string, CreateKeyspaceOptions)

Creates a new keyspace with the specified name.

public Task CreateKeyspaceAsync(string keyspace, CreateKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to create.

options CreateKeyspaceOptions

Optional settings that influence request execution.

Returns

Task

Examples

await admin.CreateKeyspaceAsync("myKeyspace");

Remarks

This method, by default, will wait for the operation to complete on the server side. Use the options' waitForCompletion attribute to control this behaviour.

DoesKeyspaceExist(string, DoesKeyspaceExistOptions)

public bool DoesKeyspaceExist(string keyspace, DoesKeyspaceExistOptions options = null)

Parameters

keyspace string

The name of the keyspace to check.

options DoesKeyspaceExistOptions

Optional settings that influence request execution.

Returns

bool

A task that resolves to true if the keyspace exists; otherwise, false.

Examples

bool exists = await admin.DoesKeyspaceExistAsync("myKeyspace");
bool exists = admin.DoesKeyspaceExist("myKeyspace");

DoesKeyspaceExistAsync(string, DoesKeyspaceExistOptions)

Checks whether a keyspace with the specified name exists.

public Task<bool> DoesKeyspaceExistAsync(string keyspace, DoesKeyspaceExistOptions options = null)

Parameters

keyspace string

The name of the keyspace to check.

options DoesKeyspaceExistOptions

Optional settings that influence request execution.

Returns

Task<bool>

A task that resolves to true if the keyspace exists; otherwise, false.

Examples

bool exists = await admin.DoesKeyspaceExistAsync("myKeyspace");

DropKeyspace(string, DropKeyspaceOptions)

public void DropKeyspace(string keyspace, DropKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to drop.

options DropKeyspaceOptions

Optional settings that influence request execution.

Examples

await admin.DropKeyspaceAsync("myKeyspace", options);

DropKeyspaceAsync(string, DropKeyspaceOptions)

Drops the keyspace with the specified name.

public Task DropKeyspaceAsync(string keyspace, DropKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to drop.

options DropKeyspaceOptions

Optional settings that influence request execution.

Returns

Task

Examples

await admin.DropKeyspaceAsync("myKeyspace", options);

FindEmbeddingProviders(FindEmbeddingProvidersOptions)

public FindEmbeddingProvidersResult FindEmbeddingProviders(FindEmbeddingProvidersOptions options = null)

Parameters

options FindEmbeddingProvidersOptions

Optional settings that influence request execution.

Returns

FindEmbeddingProvidersResult

A FindEmbeddingProvidersResult containing the discovered providers.

Examples

var providers = await admin.FindEmbeddingProvidersAsync();
var providers = admin.FindEmbeddingProviders();

FindEmbeddingProvidersAsync(FindEmbeddingProvidersOptions)

Finds and returns available embedding providers for the current database.

public Task<FindEmbeddingProvidersResult> FindEmbeddingProvidersAsync(FindEmbeddingProvidersOptions options = null)

Parameters

options FindEmbeddingProvidersOptions

Optional settings that influence request execution.

Returns

Task<FindEmbeddingProvidersResult>

A FindEmbeddingProvidersResult containing the discovered providers.

Examples

var providers = await admin.FindEmbeddingProvidersAsync();

FindRerankingProviders(FindRerankingProvidersOptions)

public FindRerankingProvidersResult FindRerankingProviders(FindRerankingProvidersOptions options = null)

Parameters

options FindRerankingProvidersOptions

Optional settings that influence request execution.

Returns

FindRerankingProvidersResult

A FindRerankingProvidersResult containing the discovered providers.

Examples

var providers = await admin.FindRerankingProvidersAsync();
var providers = admin.FindRerankingProviders();

FindRerankingProvidersAsync(FindRerankingProvidersOptions)

Finds and returns available reranking providers for the current database.

public Task<FindRerankingProvidersResult> FindRerankingProvidersAsync(FindRerankingProvidersOptions options = null)

Parameters

options FindRerankingProvidersOptions

Optional settings that influence request execution.

Returns

Task<FindRerankingProvidersResult>

A FindRerankingProvidersResult containing the discovered providers.

Examples

var providers = await admin.FindRerankingProvidersAsync();

GetAPIEndpoint()

Gets the API endpoint URL for the associated database.

public string GetAPIEndpoint()

Returns

string

The API endpoint as a string.

Examples

string endpoint = admin.GetAPIEndpoint();

GetDatabase(GetDatabaseOptions)

Returns a Database instance for non-admin usage.

public Database GetDatabase(GetDatabaseOptions options = null)

Parameters

options GetDatabaseOptions

options for the returned database: useful to override timeouts and other behavior.

Returns

Database

A Database instance representing the current database.

Examples

var database = admin.GetDatabase("myToken");

GetDatabase(string, GetDatabaseOptions)

Returns a Database instance for non-admin usage.

public Database GetDatabase(string token, GetDatabaseOptions options = null)

Parameters

token string

The token that will be used by the database. Omit to keep using the current token.

options GetDatabaseOptions

options for the returned database: useful to override timeouts and other behavior.

Returns

Database

A Database instance representing the current database.

Examples

var database = admin.GetDatabase("myToken");

ListKeyspaces(ListKeyspacesOptions)

public IEnumerable<string> ListKeyspaces(ListKeyspacesOptions options = null)

Parameters

options ListKeyspacesOptions

Optional settings that influence request execution.

Returns

IEnumerable<string>

A collection of keyspace names.

Examples

var keyspaces = await admin.ListKeyspacesAsync();
IEnumerable<string> keyspaces = admin.ListKeyspaces();

ListKeyspacesAsync(ListKeyspacesOptions)

Lists the names of all keyspaces in the database.

public Task<IEnumerable<string>> ListKeyspacesAsync(ListKeyspacesOptions options = null)

Parameters

options ListKeyspacesOptions

Optional settings that influence request execution.

Returns

Task<IEnumerable<string>>

A collection of keyspace names.

Examples

var keyspaces = await admin.ListKeyspacesAsync();