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.localClient();
// Get you the database for a local deployment of Data API
DataAPIClient devClient = DataAPIClients.localDatabase();
// 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
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DataAPIClientCreates aDataAPIClientconfigured for interaction with Astra, DataStax's cloud-native database as a service.static DatabaseCreates and configures aDatabaseclient specifically designed for interaction with a local instance of Stargate.static DataAPIClientcreateForAstraDev(String token) Creates aDataAPIClientconfigured for interacting with Astra in a development environment.static DataAPIClientcreateForAstraTest(String token) Creates aDataAPIClientspecifically configured for interacting with Astra in a test environment.static DataAPIClientCreates and configures aDataAPIClientfor interaction with a local instance of Stargate, a data gateway for working with Apache Cassandra®.
-
Field Details
-
DEFAULT_ENDPOINT_LOCAL
Default Http endpoint for local deployment.- See Also:
-
-
Method Details
-
createForLocal
Creates and configures aDataAPIClientfor interaction with a local instance of Stargate, a data gateway for working with Apache Cassandra®. This method is specifically designed for scenarios where the application is intended to communicate with a Stargate instance running locally, facilitating development and testing workflows by providing easy access to local database resources.- Returns:
- A fully configured
DataAPIClientready for interacting with the local Stargate instance, equipped with the necessary authentication token and targeting options for Cassandra. This client abstracts away the complexities of direct database communication, providing a simplified interface for data operations.
-
createDefaultLocalDatabase
Creates and configures aDatabaseclient specifically designed for interaction with a local instance of Stargate. This method streamlines the process of setting up a client for local database interactions, encapsulating both the creation of aDataAPIClientand its integration within aDatabaseabstraction. This setup is ideal for local development and testing, providing a straightforward path to interact with Cassandra through Stargate with minimal setup.- Returns:
- A
Databaseclient ready for use with a local Stargate instance, fully configured for immediate interaction with the database. This client enables developers to focus on their application logic rather than the intricacies of database connectivity and command execution.
-
create
Creates aDataAPIClientconfigured for interaction with Astra, DataStax's cloud-native database as a service. This method streamlines the client setup by requiring only an authentication token, handling the other configuration details internally to ensure compatibility with Astra's API and endpoints.By specifying the destination as Astra in the
DataAPIOptions, this method ensures that the client is properly configured to communicate with Astra's infrastructure, leveraging the provided token for authentication. This approach enables developers to quickly establish a connection to Astra for database operations without manually setting up connection parameters and authentication details.- Parameters:
token- The authentication token required for accessing Astra. This token should be treated securely and not exposed in public code repositories or unsecured locations.- Returns:
- A
DataAPIClientinstance ready for use with Astra, fully configured with the provided authentication token and set to target Astra as its destination.Example usage:
DataAPIClient astraClient = DataAPIClients.astra("my_astra_auth_token"); // Use astraClient for database operations
-
createForAstraDev
Creates aDataAPIClientconfigured 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
DataAPIClientinstance 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
-
createForAstraTest
Creates aDataAPIClientspecifically configured for interacting with Astra in a test environment. This setup is ideal for testing scenarios, where isolation from development and production environments is critical to ensure the integrity and stability of test results. By directing the client to Astra's test environment, it facilitates safe, isolated testing of database interactions without risking the alteration of development or production data.- Parameters:
token- The authentication token required for accessing Astra's test environment. Ensure that this token is designated for testing purposes to prevent unintended access to or effects on non-test data and resources.- Returns:
- A
DataAPIClientinstance specifically for use in testing scenarios with Astra, equipped with the necessary authentication token and configured to target the test environment.Example usage:
DataAPIClient testClient = DataAPIClients.astraTest("your_astra_test_token"); // Execute test database operations with testClient
-