Interface AdminOptions

The options available spawning a new AstraAdmin instance.

Note that this is only available when using Astra as the underlying database.

If any of these options are not provided, the client will use the default options provided by the DataAPIClient.

interface AdminOptions {
    additionalHeaders?: Record<string, string>;
    adminToken?: null | string | TokenProvider;
    astraEnv?: "dev" | "prod" | "test";
    endpointUrl?: string;
    logging?: DataAPILoggingConfig;
    timeoutDefaults?: Partial<TimeoutDescriptor>;
}

Properties

additionalHeaders?: Record<string, string>

Additional headers to include in the HTTP requests to the DevOps API.

Remarks

There are more than likely more official/structured ways to set any desired headers, such as through TokenProviders or EmbeddingHeadersProviders. This is more of a last-resort option, such as for enabling feature-flags or other non-standard headers.

adminToken?: null | string | TokenProvider

The access token for the DevOps API, typically of the format 'AstraCS:...'.

If never provided, this will default to the token provided when creating the DataAPIClient.

May be useful for if you want to use a stronger token for the DevOps API than the Data API.

Example

const client = new DataAPIClient('weak-token');

// Using 'weak-token' as the token
const db = client.db();

// Using 'strong-token' instead of 'weak-token'
const admin = client.admin({ adminToken: 'strong-token' });
astraEnv?: "dev" | "prod" | "test"

The Astra environment to use when interacting with the DevOps API.

In the case of AstraDbAdmin, if a database endpoint is provided, and its environment does NOT match this value (if it is set), it will throw an error.

In the case of DataAPIDbAdmin, it will simply ignore this value.

endpointUrl?: string

The base URL for the devops API, which is typically always going to be the following:

https://api.astra.datastax.com/v2

The configuration for logging events emitted by the DataAPIClient.

This can be set at any level of the major class hierarchy, and will be inherited by all child classes.

See DataAPILoggingConfig for much more information on configuration, outputs, and inheritance.

timeoutDefaults?: Partial<TimeoutDescriptor>
Overview

The default timeout options for any operation on this admin instance.

See TimeoutDescriptor for much more information about timeouts.

Example

// The request timeout for all operations is set to 1000ms.
const client = new DataAPIClient('...', {
  timeoutDefaults: { requestTimeoutMs: 1000 },
});

// The request timeout for all operations borne from this Db is set to 2000ms.
const db = client.db('...', {
  timeoutDefaults: { requestTimeoutMs: 2000 },
});
Inheritance

The timeout options are inherited by all child classes, and can be overridden at any level, including the individual method level.

Individual-method-level overrides can vary in behavior depending on the method; again, see TimeoutDescriptor.

Defaults

The default timeout options are as follows:

  • requestTimeoutMs: 10000
  • generalMethodTimeoutMs: 30000
  • collectionAdminTimeoutMs: 60000
  • tableAdminTimeoutMs: 30000
  • databaseAdminTimeoutMs: 600000
  • keyspaceAdminTimeoutMs: 30000

See

TimeoutDescriptor