Class DataAPIClients
Depending on the application's requirements and the operational environment, DataAPIClients
can
tailor the Data API client with appropriate configuration options such as authentication credentials, connection
timeouts, proxy settings, and more. This enables developers to quickly and easily set up their Data API clients
without delving into the intricate details of each configuration option.
Example Usage:
// Get you the client for a local deployment of Data API
DataAPIClient devClient = DataAPIClients.local();
// Get you the database for a local deployment of Data API
DataAPIClient devClient = DataAPIClients.astraDev("token");
// Default target environment Astra Production
DataAPIClient devClient = DataAPIClients.astra("token");
Note: This class should be used as a starting point for initializing Data API clients. It is advisable to review the specific configuration options relevant to your use case and adjust them accordingly.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataAPIClient
Creates aDataAPIClient
configured for interacting with Astra in a production environment.static DataAPIClient
Creates aDataAPIClient
configured for interacting with Astra in a development environment.static DataAPIClient
Creates aDataAPIClient
specifically configured for interacting with Astra in a test environment.static DataAPIClient
Creates and configures aDataAPIClient
for interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®.static DataAPIClient
clientCassandra
(String username, String password) Creates and configures aDataAPIClient
for interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®.static DataAPIClient
Creates and configures aDataAPIClient
specifically designed for interaction with a local instance of the Data API and Cassandra.static DataAPIClient
Creates and configures aDataAPIClient
specifically designed for interaction with a local instance of the Data API and Cassandra.static Database
Creates and configures aDatabase
client specifically designed for interaction with a local instance of the Data API and Cassandra.
-
Field Details
-
DEFAULT_ENDPOINT_LOCAL
Default Http endpoint for local deployment.- See Also:
-
-
Method Details
-
clientCassandra
Creates and configures aDataAPIClient
for interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®. This method is tailored for development and testing workflows, enabling simplified and efficient access to local database resources without the need for extensive configuration.The returned
DataAPIClient
is preconfigured with:- An authentication token from
UsernamePasswordTokenProvider
. - A destination set to
DataAPIDestination.CASSANDRA
. - Feature flags for tables enabled.
- Request logging enabled.
- Returns:
- A fully configured
DataAPIClient
ready for interacting with the local DataAPI instance. This client provides a streamlined interface for executing data operations, abstracting away the complexity of direct database interactions.Example usage:
DataAPIClient client = DataAPIClients.local();
- An authentication token from
-
clientCassandra
Creates and configures aDataAPIClient
for interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®. This method is tailored for development and testing workflows, enabling simplified and efficient access to local database resources without the need for extensive configuration.The returned
DataAPIClient
is preconfigured with:- An authentication token from
UsernamePasswordTokenProvider
. - A destination set to
DataAPIDestination.CASSANDRA
. - Feature flags for tables enabled.
- Request logging enabled.
- Parameters:
username
- The username for authenticating with the Data API. This username should have the necessary permissions to access the local Data API instance.password
- The password for authenticating with the Data API. This password should be kept secure and protected from unauthorized access.- Returns:
- A fully configured
DataAPIClient
ready for interacting with the local DataAPI instance. This client provides a streamlined interface for executing data operations, abstracting away the complexity of direct database interactions.Example usage:
DataAPIClient client = DataAPIClients.local("username", "password");
- An authentication token from
-
clientHCD
Creates and configures aDataAPIClient
specifically designed for interaction with a local instance of the Data API and Cassandra. This method simplifies the setup process by combining the creation of aDataAPIClient
with the integration of aDatabase
abstraction. It is tailored for local development and testing, enabling seamless interaction with Apache Cassandra® through Stargate with minimal configuration.Upon creation, this method ensures that a default keyspace is available in the local Stargate instance by automatically invoking
DatabaseAdmin.createKeyspace(String)
. This guarantees that developers have a ready-to-use environment for executing database operations during their development or testing workflows.The returned
Database
client is preconfigured with:- A connection to the default local Stargate endpoint.
- An automatically created keyspace, identified by
DEFAULT_KEYSPACE
.
- Returns:
- A
Database
client configured for use with a local Stargate instance, including a default keyspace for immediate interaction. This client abstracts database connectivity and administrative tasks, streamlining development workflows.Example usage:
Database db = localDbWithDefaultKeyspace();
-
clientHCD
Creates and configures aDataAPIClient
specifically designed for interaction with a local instance of the Data API and Cassandra. This method simplifies the setup process by combining the creation of aDataAPIClient
with the integration of aDatabase
abstraction. It is tailored for local development and testing, enabling seamless interaction with Apache Cassandra® through Stargate with minimal configuration.Upon creation, this method ensures that a default keyspace is available in the local Stargate instance by automatically invoking
DatabaseAdmin.createKeyspace(String)
. This guarantees that developers have a ready-to-use environment for executing database operations during their development or testing workflows.The returned
Database
client is preconfigured with:- A connection to the default local Stargate endpoint.
- An automatically created keyspace, identified by
DEFAULT_KEYSPACE
.
- Parameters:
username
- The username for authenticating with the Data API. This username should have the necessarypassword
- The password for authenticating with the Data API. This password should be kept secure and- Returns:
- A
Database
client configured for use with a local Stargate instance, including a default keyspace for immediate interaction. This client abstracts database connectivity and administrative tasks, streamlining development workflows.Example usage:
Database db = localDbWithDefaultKeyspace();
-
localDbWithDefaultKeyspace
Creates and configures aDatabase
client specifically designed for interaction with a local instance of the Data API and Cassandra. This method simplifies the setup process by combining the creation of aDataAPIClient
with the integration of aDatabase
abstraction. It is tailored for local development and testing, enabling seamless interaction with Apache Cassandra® through Stargate with minimal configuration.Upon creation, this method ensures that a default keyspace is available in the local Stargate instance by automatically invoking
DatabaseAdmin.createKeyspace(String)
. This guarantees that developers have a ready-to-use environment for executing database operations during their development or testing workflows.The returned
Database
client is preconfigured with:- A connection to the default local Stargate endpoint.
- An automatically created keyspace, identified by
DEFAULT_KEYSPACE
.
- Returns:
- A
Database
client configured for use with a local Stargate instance, including a default keyspace for immediate interaction. This client abstracts database connectivity and administrative tasks, streamlining development workflows.Example usage:
Database db = localDbWithDefaultKeyspace();
-
astraDev
Creates aDataAPIClient
configured for interacting with Astra in a development environment. This method simplifies the setup of a client specifically tailored for development purposes, where you might need different configurations or less stringent security measures compared to a production environment. The client is configured to target Astra's development environment, ensuring that operations do not affect production data.- Parameters:
token
- The authentication token required for accessing Astra's development environment. This token should have the necessary permissions for development activities and be protected accordingly.- Returns:
- A
DataAPIClient
instance ready for development activities with Astra, configured with the provided authentication token and targeting Astra's development environment.Example usage:
DataAPIClient devClient = DataAPIClients.astraDev("your_astra_dev_token"); // Utilize devClient for development database operations
-
astra
Creates aDataAPIClient
configured for interacting with Astra in a production environment. This method simplifies the setup of a client specifically tailored for development purposes, where you might need different configurations or less stringent security measures compared to a production environment. The client is configured to target Astra's development environment, ensuring that operations do not affect production data.- Parameters:
token
- The authentication token required for accessing Astra's development environment. This token should have the necessary permissions for development activities and be protected accordingly.- Returns:
- A
DataAPIClient
instance ready for development activities with Astra, configured with the provided authentication token and targeting Astra's development environment.Example usage:
DataAPIClient devClient = DataAPIClients.astra("your_astra_dev_token"); // Utilize devClient for development database operations
-
astraTest
Creates aDataAPIClient
specifically configured for interacting with Astra in a test environment. This method is designed for testing scenarios, providing an isolated environment to safely execute database operations without impacting development or production data.The returned
DataAPIClient
is preconfigured to:- Authenticate using the provided test-specific token.
- Target the
DataAPIDestination.ASTRA_TEST
environment. - Enable request logging for better visibility during test operations.
- Parameters:
token
- The authentication token required for accessing Astra's test environment. It is important to use a token that is explicitly designated for testing purposes to avoid unintended access to production or development resources.- Returns:
- A
DataAPIClient
instance configured for testing with Astra, equipped with the provided authentication token and targeting the test environment.Example usage:
DataAPIClient testClient = DataAPIClients.astraTest("your_astra_test_token"); testClient.execute(query -> query.cql("SELECT * FROM test_table").execute());
-