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 SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic DataAPIClientCreates aDataAPIClientconfigured for interacting with Astra in a production environment.static DataAPIClientCreates aDataAPIClientconfigured for interacting with Astra in a development environment.static DataAPIClientCreates aDataAPIClientspecifically configured for interacting with Astra in a test environment.static DataAPIClientCreates and configures aDataAPIClientfor interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®.static DataAPIClientclientCassandra(String username, String password) Creates and configures aDataAPIClientfor interaction with a local instance of DataAPI, a data gateway that facilitates working with Apache Cassandra®.static DataAPIClientCreates and configures aDataAPIClientspecifically designed for interaction with a local instance of the Data API and Cassandra.static DataAPIClientCreates and configures aDataAPIClientspecifically designed for interaction with a local instance of the Data API and Cassandra.static DatabaseCreates and configures aDatabaseclient specifically designed for interaction with a local instance of the Data API and Cassandra.
- 
Field Details- 
DEFAULT_ENDPOINT_LOCALDefault Http endpoint for local deployment.- See Also:
 
 
- 
- 
Method Details- 
clientCassandraCreates and configures aDataAPIClientfor 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 DataAPIClientis 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 DataAPIClientready 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 
- 
clientCassandraCreates and configures aDataAPIClientfor 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 DataAPIClientis 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 DataAPIClientready 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 
- 
clientHCDCreates and configures aDataAPIClientspecifically designed for interaction with a local instance of the Data API and Cassandra. This method simplifies the setup process by combining the creation of aDataAPIClientwith the integration of aDatabaseabstraction. 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 Databaseclient is preconfigured with:- A connection to the default local Stargate endpoint.
- An automatically created keyspace, identified by DEFAULT_KEYSPACE.
 - Returns:
- A Databaseclient 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();
 
- 
clientHCDCreates and configures aDataAPIClientspecifically designed for interaction with a local instance of the Data API and Cassandra. This method simplifies the setup process by combining the creation of aDataAPIClientwith the integration of aDatabaseabstraction. 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 Databaseclient 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 necessary
- password- The password for authenticating with the Data API. This password should be kept secure and
- Returns:
- A Databaseclient 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();
 
- 
localDbWithDefaultKeyspaceCreates and configures aDatabaseclient 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 aDataAPIClientwith the integration of aDatabaseabstraction. 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 Databaseclient is preconfigured with:- A connection to the default local Stargate endpoint.
- An automatically created keyspace, identified by DEFAULT_KEYSPACE.
 - Returns:
- A Databaseclient 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();
 
- 
astraDevCreates 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
 
- 
astraCreates aDataAPIClientconfigured 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 DataAPIClientinstance 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
 
- 
astraTestCreates aDataAPIClientspecifically 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 DataAPIClientis preconfigured to:- Authenticate using the provided test-specific token.
- Target the DataAPIDestination.ASTRA_TESTenvironment.
- 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 DataAPIClientinstance 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());
 
 
-