Table of Contents

Class DatabaseAdminDataAPI

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

Provides administrative operations for a non-Astra (DSE/HCD) database, including keyspace management and embedding/reranking provider discovery. All keyspace operations are executed via the Data API command protocol rather than the Astra DevOps API.

public class DatabaseAdminDataAPI : IDatabaseAdmin
Inheritance
DatabaseAdminDataAPI
Implements
Inherited Members

Remarks

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

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.

CreateKeyspace(string, IDictionary<string, object>, CreateKeyspaceOptions)

public void CreateKeyspace(string keyspace, IDictionary<string, object> replicationOptions, CreateKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to create.

replicationOptions IDictionary<string, object>

Optional replication settings for the keyspace, e.g. {"class": "SimpleStrategy", "replication_factor": 3}.

options CreateKeyspaceOptions

Optional settings that influence request execution.

Examples

await admin.CreateKeyspaceAsync("myKeyspace");
var replicationOptions = new Dictionary<string, object> { ["class"] = "SimpleStrategy", ["replication_factor"] = 3 };
await admin.CreateKeyspaceAsync("myKeyspace", replicationOptions, options);

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.

CreateKeyspaceAsync(string, IDictionary<string, object>, CreateKeyspaceOptions)

Creates a new keyspace with the specified name.

public Task CreateKeyspaceAsync(string keyspace, IDictionary<string, object> replicationOptions, CreateKeyspaceOptions options = null)

Parameters

keyspace string

The name of the keyspace to create.

replicationOptions IDictionary<string, object>

Optional replication settings for the keyspace, e.g. {"class": "SimpleStrategy", "replication_factor": 3}.

options CreateKeyspaceOptions

Optional settings that influence request execution.

Returns

Task

Examples

await admin.CreateKeyspaceAsync("myKeyspace");
var replicationOptions = new Dictionary<string, object> { ["class"] = "SimpleStrategy", ["replication_factor"] = 3 };
await admin.CreateKeyspaceAsync("myKeyspace", replicationOptions, options);

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();

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();