diff --git a/astra-db-client/pom.xml b/astra-db-client/pom.xml index 21b6cb64..31abb960 100644 --- a/astra-db-client/pom.xml +++ b/astra-db-client/pom.xml @@ -2,7 +2,7 @@ 4.0.0 astra-db-client - Java Client for Astra DB + + astra-db-client com.datastax.astra @@ -11,37 +11,22 @@ - 0.18.2 - 0.27.0 - 4.12.0 - 3.7.0 + 11 + org.slf4j slf4j-api - - - com.squareup.okhttp3 - okhttp - ${okhttp.version} - - - - com.squareup.okio - okio-jvm - ${okio-jvm.version} - - org.projectlombok lombok - + com.datastax.stargate stargate-sdk-data @@ -53,7 +38,7 @@ java-driver-core - + com.datastax.astra astra-sdk-devops @@ -71,40 +56,37 @@ logback-classic test - - - dev.langchain4j - langchain4j - ${langchain4j.version} - test - - dev.langchain4j - langchain4j-open-ai - ${langchain4j.version} + org.assertj + assertj-core test - dev.langchain4j - langchain4j-document-parser-apache-pdfbox - ${langchain4j.version} + com.datastax.stargate + stargate-sdk-data + ${stargate-sdk.version} + tests + test-jar test + + org.apache.maven.plugins maven-compiler-plugin - 11 - 11 + ${java.version} + ${java.version} + Apache-2.0 diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBAdmin.java b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBClient.java similarity index 70% rename from astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBAdmin.java rename to astra-db-client/src/main/java/com/datastax/astra/db/AstraDBClient.java index 4ac26c5a..295a1d1e 100644 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBAdmin.java +++ b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBClient.java @@ -1,25 +1,24 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.DbOpsClient; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationRequest; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.AstraRc; -import io.stargate.sdk.data.DataApiClient; -import io.stargate.sdk.http.RetryHttpClient; +package com.datastax.astra.db; + + +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.db.DbOpsClient; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.db.exception.DatabaseNotFoundException; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.AstraRc; +import io.stargate.sdk.data.client.DataApiClient; import lombok.Getter; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import java.net.URI; import java.net.http.HttpClient; -import java.net.http.HttpClient.Version; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; @@ -34,42 +33,46 @@ import static io.stargate.sdk.utils.Utils.readEnvVariable; /** - * Client for AstraDB at organization level (crud for databases). + * Main Client for AstraDB, it implements administration and Data Api Operations. + * + * @see AstraDBDevopsClient Client specialized in the Devops API operations + * @see DataApiClient Client specialized for Data API operation */ @Slf4j -public class AstraDBAdmin { +public class AstraDBClient { - public static final String USER_AGENT = "astra-db-java"; - - /** Default timeout for initiating connection. */ - public static final int CONNECT_TIMEOUT_SECONDS = 20; - - /** Default cloud provider if not provided by user. (free-tier) */ + /** Default cloud provider. (free-tier) */ public static final CloudProviderType FREE_TIER_CLOUD = CloudProviderType.GCP; - /** Default region if not provided by user. (free-tier) */ + /** Default region. (free-tier) */ public static final String FREE_TIER_CLOUD_REGION = "us-east1"; /** Header name used to hold the Astra Token. */ public static final String TOKEN_HEADER_PARAM = "X-Token"; - /** Default keyspace name if not provided by user. */ + /** Default keyspace (same created by the ui). */ public static final String DEFAULT_KEYSPACE = "default_keyspace"; - /** Client for the Astra Devops Api. (crud on databases) */ - final AstraDBOpsClient devopsDbClient; + /** Default options. */ + public static final AstraDBOptions DEFAULT_OPTIONS = AstraDBOptions.builder().build(); + + /** Client for Astra Devops Api. */ + final AstraDBDevopsClient devopsDbClient; + + /** Options to personalized http client other client options. */ + final AstraDBOptions astraDbOptions; - /** Target Astra Environment, default is PROD. */ + /** Astra Environment. */ final AstraEnvironment env; - /** Astra Token used as credentials. */ + /** Astra Token (credentials). */ @Getter final String token; - /** JDK11 HttpClient to interact with apis. */ + /** Side Http Client (use only to resume a db). */ final HttpClient httpClient; - /** Token value read for environment variable. */ + /** Token read for environment variable ASTRA_DB_APPLICATION_TOKEN (if any). */ static String astraConfigToken; /* @@ -84,117 +87,56 @@ public class AstraDBAdmin { } /** - * Default initialization, the token is retrieved from environment variable ASTRA_DB_APPLICATION_TOKEN or from + * Default constructor. The token is read from environment variable ASTRA_DB_APPLICATION_TOKEN or * file ~/.astrarc, section default, key ASTRA_DB_APPLICATION_TOKEN. */ - public AstraDBAdmin() { + public AstraDBClient() { this(astraConfigToken); } /** - * Initialization with an authentification token, defaulting to production environment. + * Constructor with an authentification token, defaulting to production environment, and default http options. * * @param token * authentication token */ - public AstraDBAdmin(String token) { - this(token, AstraEnvironment.PROD); + public AstraDBClient(String token) { + this(token, DEFAULT_OPTIONS); } /** - * Initialization with an authentification token and target environment, Use this constructor for testing purpose. + * Constructor with an authentification token, defaulting to production environment, and default http options. * * @param token * authentication token - * @param env - * target Astra environment - */ - public AstraDBAdmin(String token, AstraEnvironment env) { - this.env = env; - this.token = token; - this.devopsDbClient = new AstraDBOpsClient(token, env); - this.httpClient = HttpClient.newBuilder() - .version(Version.HTTP_2) - .connectTimeout(Duration.ofSeconds(CONNECT_TIMEOUT_SECONDS)) - .build(); - String version = AstraDBAdmin.class.getPackage().getImplementationVersion(); - AstraDBAdmin.setCallerName(AstraDBAdmin.USER_AGENT, (null != version) ? version : "dev"); - } - - // -------------------------- - // --- User Agent ---- - // -------------------------- - - /** - * Allow user to set the client name - * - * @param callerName - * client name - * @param callerVersion - * client version - */ - public static void setCallerName(String callerName, String callerVersion) { - RetryHttpClient.getInstance().pushUserAgent(callerName, callerVersion); - } - - // -------------------- - // -- Watch --- - // -------------------- - - public void watch() { - throw new UnsupportedOperationException("As we connect to a HTTP apis without hooks, no watch is possible."); - } - - // -------------------- - // -- Keyspace --- - // -------------------- - - /** - * Create a keyspace. - * - * @param databaseName - * database name - * @param keyspaceName - * keyspace name - */ - public void createKeyspace(String databaseName, String keyspaceName) { - devopsDbClient.databaseByName(databaseName).keyspaces().create(keyspaceName); - } - - /** - * Create a keyspace. - * - * @param databaseId - * database unique identifier - * @param keyspaceName - * keyspace name - */ - public void createKeyspace(UUID databaseId, String keyspaceName) { - devopsDbClient.database(databaseId.toString()).keyspaces().create(keyspaceName); - } - - /** - * Delete a keyspace. - * - * @param databaseName - * database name - * @param keyspaceName - * keyspace name + * @param astraDbOptions + * options for AstraDb. */ - public void deleteKeyspace(String databaseName, String keyspaceName) { - devopsDbClient.databaseByName(databaseName).keyspaces().delete(keyspaceName); + public AstraDBClient(String token, AstraDBOptions astraDbOptions) { + this(token, astraDbOptions, AstraEnvironment.PROD); } /** - * Delete a keyspace. + * Initialization with an authentification token and target environment, Use this constructor for testing purpose. * - * @param databaseId - * database unique identifier - * @param keyspaceName - * keyspace name + * @param token + * authentication token + * @param env + * target Astra environment + * @param astraDbOptions + * options for AstraDb. */ - public void deleteKeyspace(UUID databaseId, String keyspaceName) { - devopsDbClient.database(databaseId.toString()).keyspaces().delete(keyspaceName); + public AstraDBClient(String token, AstraDBOptions astraDbOptions, AstraEnvironment env) { + this.env = env; + this.token = token; + this.devopsDbClient = new AstraDBDevopsClient(token, env); + this.astraDbOptions = astraDbOptions; + + // Local Agent for Resume + HttpClient.Builder httpClientBuilder = HttpClient.newBuilder(); + httpClientBuilder.version(astraDbOptions.asHttpClientOptions().getHttpVersion()); + httpClientBuilder.connectTimeout(Duration.ofSeconds(astraDbOptions.asHttpClientOptions().getConnectionRequestTimeoutInSeconds())); + this.httpClient = httpClientBuilder.build(); } // -------------------- @@ -337,7 +279,7 @@ public Stream getDatabaseInformations(String name) { * @return * if the database exists */ - public boolean isDatabaseExists(String name) { + public boolean databaseExists(String name) { return getDatabaseInformations(name).findFirst().isPresent(); } @@ -362,7 +304,7 @@ public Optional getDatabaseInformations(@NonNull UUID id) { * @return * database client */ - public AstraDB getDatabase(@NonNull String databaseName) { + public AstraDBDatabase getDatabase(@NonNull String databaseName) { List dbs = getDatabaseInformations(databaseName).collect(Collectors.toList()); if (dbs.isEmpty()) { throw new DatabaseNotFoundException(databaseName); @@ -385,8 +327,14 @@ public AstraDB getDatabase(@NonNull String databaseName) { * @return * database client */ - public AstraDB getDatabase(UUID databaseId) { - return new AstraDB(token, databaseId, null, env, AstraDBAdmin.DEFAULT_KEYSPACE); + public AstraDBDatabase getDatabase(UUID databaseId) { + String databaseRegion = devopsDbClient + .findById(databaseId.toString()) + .map(db -> db.getInfo().getRegion()) + .orElseThrow(() -> new DatabaseNotFoundException(databaseId.toString())); + return new AstraDBDatabase( + new AstraDBEndpoint(databaseId, databaseRegion, env), + token, AstraDBClient.DEFAULT_KEYSPACE, astraDbOptions); } /** @@ -462,7 +410,7 @@ private void resumeDb(Database db) { * database client */ public DataApiClient getDataApiClient(@NonNull String databaseName) { - return getDatabase(databaseName).getApiClient(); + return getDatabase(databaseName).getDataApiClient(); } /** @@ -474,7 +422,7 @@ public DataApiClient getDataApiClient(@NonNull String databaseName) { * database client */ public DataApiClient getDataApiClient(@NonNull UUID databaseId) { - return getDatabase(databaseId).getApiClient(); + return getDatabase(databaseId).getDataApiClient(); } /** @@ -483,9 +431,8 @@ public DataApiClient getDataApiClient(@NonNull UUID databaseId) { * @return * devops client. */ - public AstraDBOpsClient getDevopsApiClient() { + public AstraDBDevopsClient getDevopsApiClient() { return this.devopsDbClient; } - } diff --git a/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBCollection.java b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBCollection.java new file mode 100644 index 00000000..0325b5b5 --- /dev/null +++ b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBCollection.java @@ -0,0 +1,26 @@ +package com.datastax.astra.db; + +import io.stargate.sdk.data.internal.DataApiCollectionImpl; + +/** + * Implementation of a Collection within Astra. + * + * @param + * working document class + */ +public class AstraDBCollection extends DataApiCollectionImpl { + + /** + * Full constructor. + * + * @param db + * client namespace http + * @param collectionName + * collection identifier + * @param clazz + * working pojo with this collection. + */ + protected AstraDBCollection(AstraDBDatabase db, String collectionName, Class clazz) { + super(db, collectionName, clazz); + } +} diff --git a/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBDatabase.java b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBDatabase.java new file mode 100644 index 00000000..07bd5792 --- /dev/null +++ b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBDatabase.java @@ -0,0 +1,308 @@ +package com.datastax.astra.db; + +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import io.stargate.sdk.data.client.DataApiClient; +import io.stargate.sdk.data.client.DataApiClients; +import io.stargate.sdk.data.client.DataApiNamespace; +import io.stargate.sdk.data.client.model.Document; +import io.stargate.sdk.data.client.model.collections.CreateCollectionOptions; +import io.stargate.sdk.data.client.model.namespaces.CreateNamespaceOptions; +import io.stargate.sdk.data.internal.model.ApiResponse; +import io.stargate.sdk.data.internal.model.CollectionDefinition; +import io.stargate.sdk.data.internal.model.NamespaceInformation; +import io.stargate.sdk.http.LoadBalancedHttpClient; +import io.stargate.sdk.http.ServiceHttp; +import io.stargate.sdk.utils.Assert; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * Client for AstraDB at database level (crud for collections). + */ +@Slf4j @Getter +public class AstraDBDatabase implements DataApiNamespace, DataApiClient { + + /** + * Url to access the API + */ + private final AstraDBEndpoint astraDbEndpoint; + + /** + * Top level resource for json api. + */ + private final DataApiClient dataApiClient; + + /** + * Namespace client + */ + private final DataApiNamespace dataApiNamespace; + + /** + * Devops Api Client. + */ + private final AstraDBDevopsClient devopsApi; + + /** + * Token used for the credentials + */ + private final String token; + + /** + * Name of the namespace in use. + */ + private final String namespaceName; + + /** + * Configuration of the + */ + private final AstraDBOptions astraDbOptions; + + /** + * Initialization with endpoint and apikey. + * + * @param token + * api token + * @param apiEndpoint + * api endpoint + */ + public AstraDBDatabase(String apiEndpoint, String token) { + this(apiEndpoint, token, AstraDBClient.DEFAULT_KEYSPACE); + } + + /** + * Initialization with endpoint and apikey. + * + * @param token + * api token + * @param apiEndpoint + * api endpoint + * @param keyspace + * keyspace + */ + public AstraDBDatabase(String apiEndpoint, String token, String keyspace) { + this(apiEndpoint, token, keyspace, AstraDBClient.DEFAULT_OPTIONS); + } + + /** + * Initialization with endpoint and apikey. + * + * @param token + * api token + * @param apiEndpoint + * api endpoint + * @param astraDbOptions + * setup of the clients with options + */ + public AstraDBDatabase(String apiEndpoint, String token, AstraDBOptions astraDbOptions) { + this(apiEndpoint, token, AstraDBClient.DEFAULT_KEYSPACE, astraDbOptions); + } + + /** + * Initialization with endpoint and apikey. + * + * @param token + * api token + * @param apiEndpoint + * api endpoint + * @param keyspace + * keyspace + * @param astraDbOptions + * setup of the clients with options + */ + public AstraDBDatabase(String apiEndpoint, String token, String keyspace, AstraDBOptions astraDbOptions) { + this(AstraDBEndpoint.parse(apiEndpoint), token, keyspace, astraDbOptions); + } + + /** + * Initialization with endpoint and apikey. + * + * @param apiEndpoint + * api endpoint + * @param token + * api token + * @param namespaceName + * namespaceName + * @param astraDbOptions + * setup of the clients with options + */ + public AstraDBDatabase(AstraDBEndpoint apiEndpoint, String token, String namespaceName, AstraDBOptions astraDbOptions) { + Assert.notNull(apiEndpoint, "endpoint"); + Assert.hasLength(token, "token"); + Assert.hasLength(namespaceName, "namespaceName"); + this.token = token; + this.astraDbEndpoint = apiEndpoint; + this.astraDbOptions = astraDbOptions; + this.namespaceName = namespaceName; + this.dataApiClient = DataApiClients.create(astraDbEndpoint.getApiEndPoint(), token, astraDbOptions.asHttpClientOptions()); + this.dataApiNamespace = dataApiClient.getNamespace(namespaceName); + this.devopsApi = new AstraDBDevopsClient(token); + } + + // ------------------------------------------ + // ---- Crud on Namespaces (dataApi) ---- + // ------------------------------------------ + + /** {@inheritDoc} */ + @Override + public AstraDBDatabase getNamespace(String namespaceName) { + return new AstraDBDatabase(getAstraDbEndpoint().getApiEndPoint(), getToken(), namespaceName); + } + + /** {@inheritDoc} */ + @Override + public Stream listNamespaceNames() { + return dataApiClient.listNamespaceNames(); + } + + /** {@inheritDoc} */ + @Override + public Stream listNamespaces() { + return dataApiClient.listNamespaces(); + } + + /** {@inheritDoc} */ + @Override + public boolean isNamespaceExists(String namespace) { + return dataApiClient.isNamespaceExists(namespace); + } + + /** {@inheritDoc} */ + @Override + public AstraDBDatabase createNamespace(String namespace) { + // We will NOT use the Data API methods in the Astra context but some devops API + devopsApi.database(astraDbEndpoint.getDatabaseId().toString()).keyspaces().create(namespace); + return new AstraDBDatabase(astraDbEndpoint, token, namespace, astraDbOptions); + } + + @Override + public AstraDBDatabase createNamespace(String namespace, CreateNamespaceOptions options) { + throw new UnsupportedOperationException("Cannot provide replication factor with Astra"); + } + + /** + * Delete a namespace from current database. If the namespace does not exist not errors will be thrown. + * + *
{@code
+     *  // Initialize a db
+     *  AstraDBDatabase db = new AstraDBDatabase("API_ENDPOINT", "TOKEN");
+     *  // Drop a Namespace
+     *  db.dropNamespace("");
+     * }
+ * @param namespace + * current namespace + */ + @Override + public void dropNamespace(String namespace) { + devopsApi.database(astraDbEndpoint.getDatabaseId().toString()).keyspaces().delete(namespace); + } + + // -------------------------------------------- + // ---- Information on current Namespace ---- + // -------------------------------------------- + + /** {@inheritDoc} */ + @Override + public String getName() { + return this.namespaceName; + } + + /** {@inheritDoc} */ + @Override + public DataApiClient getClient() { + return dataApiClient; + } + + // -------------------------------------------- + // ---- Crud on Collection (namespace) ---- + // -------------------------------------------- + + /** {@inheritDoc} */ + @Override + public Stream listCollectionNames() { + return dataApiNamespace.listCollectionNames(); + } + + /** {@inheritDoc} */ + @Override + public Stream listCollections() { + return dataApiNamespace.listCollections(); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection getCollection(String collectionName) { + return getCollection(collectionName, Document.class); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection getCollection(String collectionName, Class documentClass) { + return new AstraDBCollection<>(this, collectionName, documentClass); + } + + /** {@inheritDoc} */ + @Override + public void drop() { + dataApiNamespace.drop(); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection createCollection(String collectionName) { + return createCollection(collectionName, null, Document.class); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection createCollection(String collectionName, Class documentClass) { + return createCollection(collectionName, null, documentClass); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection createCollection(String collectionName, CreateCollectionOptions createCollectionOptions) { + return createCollection(collectionName, createCollectionOptions, Document.class); + } + + /** {@inheritDoc} */ + @Override + public AstraDBCollection createCollection(String collectionName, CreateCollectionOptions createCollectionOptions, Class documentClass) { + dataApiNamespace.createCollection(collectionName, createCollectionOptions, documentClass); + return new AstraDBCollection<>(this, collectionName, documentClass); + } + + + /** {@inheritDoc} */ + @Override + public void dropCollection(String collectionName) { + dataApiNamespace.dropCollection(collectionName); + } + + /** {@inheritDoc} */ + @Override + public ApiResponse runCommand(String jsonCommand) { + return dataApiNamespace.runCommand(jsonCommand); + } + + /** {@inheritDoc} */ + @Override + public DOC runCommand(String jsonCommand, Class documentClass) { + return dataApiNamespace.runCommand(jsonCommand, documentClass); + } + + /** {@inheritDoc} */ + @Override + public Function lookup() { + return dataApiNamespace.lookup(); + } + + /** {@inheritDoc} */ + @Override + public LoadBalancedHttpClient getHttpClient() { + return dataApiNamespace.getHttpClient(); + } + +} diff --git a/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBEndpoint.java b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBEndpoint.java new file mode 100644 index 00000000..7cb367f5 --- /dev/null +++ b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBEndpoint.java @@ -0,0 +1,98 @@ +package com.datastax.astra.db; + +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import io.stargate.sdk.utils.Assert; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +/** + * Create an endpoint to connect to a database. + */ +@Data @NoArgsConstructor +public class AstraDBEndpoint { + + /** + * Current Environment + */ + AstraEnvironment env; + + /** + * Database Identifier + */ + UUID databaseId; + + /** + * Database Region + */ + String databaseRegion; + + /** + * Parse an endpoint URL to know information on the DB. + * + * @param endpointUrl + * endpoint URL copy from UI + * @return + * astra db endpoint parsed + */ + public static AstraDBEndpoint parse(String endpointUrl) { + Assert.notNull(endpointUrl, "endpoint"); + AstraDBEndpoint endpoint = new AstraDBEndpoint(); + String tmpUrl; + if (endpointUrl.contains(AstraEnvironment.PROD.getAppsSuffix())) { + endpoint.env = AstraEnvironment.PROD; + tmpUrl= endpointUrl.replaceAll(AstraEnvironment.PROD.getAppsSuffix(), ""); + } else if (endpointUrl.contains(AstraEnvironment.TEST.getAppsSuffix())) { + endpoint.env = AstraEnvironment.TEST; + tmpUrl= endpointUrl.replaceAll(AstraEnvironment.TEST.getAppsSuffix(), ""); + } else if (endpointUrl.contains(AstraEnvironment.DEV.getAppsSuffix())) { + endpoint.env = AstraEnvironment.DEV; + tmpUrl= endpointUrl.replaceAll(AstraEnvironment.DEV.getAppsSuffix(), ""); + } else { + throw new IllegalArgumentException("Unable to detect environment from endpoint"); + } + tmpUrl = tmpUrl.replaceAll("https://", ""); + endpoint.databaseId = UUID.fromString(tmpUrl.substring(0,36)); + endpoint.databaseRegion = tmpUrl.substring(37); + return endpoint; + } + + /** + * Constructor with chunk of the URL. + * + * @param databaseId + * database identifier + * @param databaseRegion + * database region + * @param env + * environment + */ + public AstraDBEndpoint(UUID databaseId, String databaseRegion, AstraEnvironment env) { + this.databaseId = databaseId; + this.databaseRegion = databaseRegion; + this.env = env; + } + + /** + * Return the endpoint URL based on the chunks. + * + * @return + * endpoint URL. + */ + public String getApiEndPoint() { + return ApiLocator.getApiJsonEndpoint(env, databaseId.toString(), databaseRegion); + } + + /** + * Return the endpoint URL based on the chunks. + * + * @return + * endpoint URL. + */ + public String getOriginalEndPoint() { + return getApiEndPoint().replaceAll("/api/json", ""); + } + +} diff --git a/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBOptions.java b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBOptions.java new file mode 100644 index 00000000..c6128eb4 --- /dev/null +++ b/astra-db-client/src/main/java/com/datastax/astra/db/AstraDBOptions.java @@ -0,0 +1,100 @@ +package com.datastax.astra.db; + + +import io.stargate.sdk.http.HttpClientOptions; +import lombok.Builder; +import lombok.Data; + +import java.net.http.HttpClient; + +/** + * Options to set up http Client. + */ +@Data @Builder +public class AstraDBOptions { + + /** Default user agent. */ + public static final String DEFAULT_CALLER_NAME = "astra-db-java"; + + /** Default user agent. */ + public static final String DEFAULT_CALLER_VERSION = + AstraDBOptions.class.getPackage().getImplementationVersion() != null ? + AstraDBOptions.class.getPackage().getImplementationVersion() : "dev"; + + /** Default timeout for initiating connection. */ + public static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 20; + + /** Default timeout for initiating connection. */ + public static final int DEFAULT_REQUEST_TIMEOUT_SECONDS = 20; + + /** Default retry count. */ + public static final int DEFAULT_RETRY_COUNT = 3; + + /** Default retry delay. */ + public static final int DEFAULT_RETRY_DELAY_MILLIS = 100; + + /** path for json api. */ + public static final String DEFAULT_VERSION = "v1"; + + /** Caller name in User agent. */ + @Builder.Default + String apiVersion = DEFAULT_VERSION; + + /** Caller name in User agent. */ + @Builder.Default + String userAgentCallerName = DEFAULT_CALLER_NAME; + + /** Caller version in User agent. */ + @Builder.Default + String userAgentCallerVersion = DEFAULT_CALLER_VERSION; + + /** Http Connection timeout. */ + @Builder.Default + long connectionRequestTimeoutInSeconds = DEFAULT_CONNECT_TIMEOUT_SECONDS; + + /** Http Connection timeout. */ + @Builder.Default + long responseTimeoutInSeconds = DEFAULT_REQUEST_TIMEOUT_SECONDS; + + /** Enable retry count. */ + @Builder.Default + int retryCount = DEFAULT_RETRY_COUNT; + + /** How much to wait in between 2 calls. */ + @Builder.Default + int retryDelay = DEFAULT_RETRY_DELAY_MILLIS; + + /** The http client could work through a proxy. */ + HttpClientOptions.HttpProxy proxy; + + /** Moving to HTTP/2. */ + @Builder.Default + HttpClient.Version httpVersion = HttpClient.Version.HTTP_2; + + /** Redirect */ + @Builder.Default + HttpClient.Redirect httpRedirect = HttpClient.Redirect.NORMAL; + + /** + * Map as a http client options. + * + * @return + * instance of HttpClientOptions + */ + public HttpClientOptions asHttpClientOptions() { + return HttpClientOptions.builder() + .apiVersion(apiVersion) + .userAgentCallerName(userAgentCallerName) + .userAgentCallerVersion(userAgentCallerVersion) + .connectionRequestTimeoutInSeconds(connectionRequestTimeoutInSeconds) + .connectionRequestTimeoutInSeconds(connectionRequestTimeoutInSeconds) + .responseTimeoutInSeconds(responseTimeoutInSeconds) + .retryCount(retryCount) + .retryDelay(retryDelay) + .proxy(proxy) + .httpVersion(httpVersion) + .httpRedirect(httpRedirect) + .build(); + } + +} \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/datastax/astra/db/package-info.java b/astra-db-client/src/main/java/com/datastax/astra/db/package-info.java new file mode 100644 index 00000000..e3be8c65 --- /dev/null +++ b/astra-db-client/src/main/java/com/datastax/astra/db/package-info.java @@ -0,0 +1,4 @@ +/** + * Data Api Client wrapper for AstraDB. + */ +package com.datastax.astra.db; \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDB.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDB.java deleted file mode 100644 index f35be13a..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDB.java +++ /dev/null @@ -1,454 +0,0 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import io.stargate.sdk.ServiceDeployment; -import io.stargate.sdk.api.SimpleTokenProvider; -import io.stargate.sdk.data.DataApiClient; -import io.stargate.sdk.data.NamespaceClient; -import io.stargate.sdk.data.domain.CollectionDefinition; -import io.stargate.sdk.data.domain.SimilarityMetric; -import io.stargate.sdk.http.ServiceHttp; -import lombok.Getter; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Stream; - -/** - * Client for AstraDB at database level (crud for collections). - */ -@Slf4j @Getter -public class AstraDB { - - /** - * Hold a reference to target Astra Environment. - */ - protected final AstraEnvironment env; - - /** - * Top level resource for json api. - */ - private final DataApiClient apiClient; - - /** - * Namespace client - */ - private NamespaceClient nsClient; - - /** - * Url to access the API - */ - private final String apiEndpoint; - - /** - * Initialization with endpoint and apikey. - * - * @param token - * api token - * @param apiEndpoint - * api endpoint - */ - public AstraDB(String token, String apiEndpoint) { - this(token, apiEndpoint, AstraDBAdmin.DEFAULT_KEYSPACE); - } - - /** - * Initialization with endpoint and apikey. - * - * @param token - * api token - * @param apiEndpoint - * api endpoint - * @param keyspace - * keyspace - */ - public AstraDB(@NonNull String token, @NonNull String apiEndpoint, @NonNull String keyspace) { - // Support for apiEndpoint with or without /api/json - if (apiEndpoint.endsWith("com")) { - apiEndpoint = apiEndpoint + "/api/json"; - } - this.apiEndpoint = apiEndpoint; - - // Finding Environment based on apiEndpoint (looping to devops) - if (apiEndpoint.contains(AstraEnvironment.PROD.getAppsSuffix())) { - this.env = AstraEnvironment.PROD; - } else if (apiEndpoint.contains(AstraEnvironment.TEST.getAppsSuffix())) { - this.env = AstraEnvironment.TEST; - } else if (apiEndpoint.contains(AstraEnvironment.DEV.getAppsSuffix())) { - this.env = AstraEnvironment.DEV; - } else { - throw new IllegalArgumentException("Unable to detect environment from endpoint"); - } - - // deploy on a single url with a static token (token provider) - ServiceDeployment jsonDeploy = new ServiceDeployment<>(); - jsonDeploy.addDatacenterTokenProvider("default", new SimpleTokenProvider(token)); - jsonDeploy.addDatacenterServices("default", new ServiceHttp("json", apiEndpoint, apiEndpoint)); - this.apiClient = new DataApiClient(jsonDeploy); - this.nsClient = apiClient.namespace(keyspace); - String version = AstraDB.class.getPackage().getImplementationVersion(); - AstraDBAdmin.setCallerName(AstraDBAdmin.USER_AGENT, (null != version) ? version : "dev"); - } - - /** - * Full constructor. - * - * @param token - * token - * @param databaseId - * database identifier - */ - public AstraDB(@NonNull String token, @NonNull UUID databaseId) { - this(token, databaseId, null, AstraEnvironment.PROD, AstraDBAdmin.DEFAULT_KEYSPACE); - } - - /** - * Full constructor. - * - * @param token - * token - * @param databaseId - * database identifier - * @param keyspace - * database keyspace - */ - public AstraDB(@NonNull String token, @NonNull UUID databaseId, @NonNull String keyspace) { - this(token, databaseId, null, AstraEnvironment.PROD, keyspace); - } - - /** - * Full constructor. - * - * @param token - * token - * @param databaseId - * database identifier - * @param region - * database region - * @param keyspace - * keyspace - */ - public AstraDB(@NonNull String token, @NonNull UUID databaseId, @NonNull String region, @NonNull String keyspace) { - this(token, databaseId, region, AstraEnvironment.PROD, keyspace); - } - - /** - * Accessing the database with id and region. - * - * @param token - * astra token - * @param databaseId - * database id - * @param region - * database region - * @param env - * environment - * @param keyspace - * destination keyspace - */ - public AstraDB(@NonNull String token, @NonNull UUID databaseId, String region, @NonNull AstraEnvironment env, String keyspace) { - this.env = env; - Database db = new AstraDBOpsClient(token, env) - .findById(databaseId.toString()) - .orElseThrow(() -> new DatabaseNotFoundException(databaseId.toString())); - - // If no region is provided, we use the default region of the DB - if (region == null) region = db.getInfo().getRegion(); - - ServiceDeployment jsonDeploy = new ServiceDeployment<>(); - jsonDeploy.addDatacenterTokenProvider("default", new SimpleTokenProvider(token)); - this.apiEndpoint = ApiLocator.getApiJsonEndpoint(env, databaseId.toString(), region); - jsonDeploy.addDatacenterServices("default", new ServiceHttp("json", apiEndpoint, apiEndpoint)); - - final String defaultRegion = region; - db.getInfo() - .getDatacenters().stream() - .filter(dc->!dc.getRegion().equals(defaultRegion)) - .forEach(dc -> { - String dcApiEndpoint = ApiLocator.getApiJsonEndpoint(env, databaseId.toString(), dc.getRegion()); - jsonDeploy.addDatacenterServices(dc.getName(), new ServiceHttp("json", dcApiEndpoint, dcApiEndpoint)); - }); - - this.apiClient = new DataApiClient(jsonDeploy); - if (keyspace == null) { - keyspace = db.getInfo().getKeyspace(); - } - this.nsClient = apiClient.namespace(keyspace); - } - - - - - // -------------------------- - // --- Find, FindAll ---- - // -------------------------- - - /** - * List all vector Stores for this environment. - * - * @return - * name of all vector store. - */ - public Stream findAllCollections() { - return nsClient.findCollections(); - } - - /** - * List all vector Stores for this environment. - * - * @return - * name of all vector store. - */ - public Stream findAllCollectionsNames() { - return nsClient.findCollections().map(CollectionDefinition::getName); - } - - /** - * Return the collection definition if its exists. - * - * @param name - * collection name - * @return - * collection definition - */ - public Optional findCollectionByName(String name) { - return nsClient.findCollectionByName(name); - } - - /** - * Check if a store exists. - * - * @param store - * collection name - * @return - * of the store already exist - */ - public boolean isCollectionExists(@NonNull String store) { - return nsClient.isCollectionExists(store); - } - - // -------------------------- - // --- Delete ---- - // -------------------------- - - /** - * Delete a store if it exists. - * - * @param name - * store name - */ - public void deleteCollection(String name) { - nsClient.deleteCollection(name); - } - - // -------------------------- - // --- Create ---- - // -------------------------- - - /** - * Create the minimal store. - * - * @param name - * store name - * @return - * json vector store - */ - public AstraDBCollection createCollection(String name) { - return new AstraDBCollection(nsClient.createCollection(name)); - } - - /** - * Create the minimal store. - * - * @param name - * store name - * @param clazz - * bean type - * @param - * type of document in used - * @return - * json vector store - */ - public AstraDBRepository createCollection(String name, Class clazz) { - return new AstraDBRepository<>(nsClient.createCollection(name, clazz)); - } - - /** - * Create the minimal store. - * - * @param name - * store name - * @param vectorDimension - * dimension - * @return - * json vector store - */ - public AstraDBCollection createCollection(String name, int vectorDimension) { - return new AstraDBCollection(nsClient.createCollection(name, vectorDimension)); - } - - /** - * Create the minimal store. - * - * @param name - * store name - * @param vectorDimension - * dimension - * @param metric - * similarity metric for the vector - * @return - * json vector store - */ - public AstraDBCollection createCollection(String name, int vectorDimension, SimilarityMetric metric) { - return new AstraDBCollection(nsClient.createCollection(CollectionDefinition - .builder() - .name(name) - .vector(vectorDimension, metric) - .build())); - } - - /** - * Create the minimal store. - * - * @param name - * store name - * @param vectorDimension - * dimension - * @param bean - * class of pojo - * @return - * vector store instance - * @param - * object type - */ - public AstraDBRepository createCollection(String name, int vectorDimension, Class bean) { - return new AstraDBRepository<>(nsClient.createCollection(CollectionDefinition.builder() - .name(name) - .vector(vectorDimension, SimilarityMetric.cosine) - .build(), bean)); - } - - - /** - * Create the minimal store. - * - * @param def - * collection definition - * @return - * json vector store - */ - public AstraDBCollection createCollection(CollectionDefinition def) { - return new AstraDBCollection(nsClient.createCollection(def)); - } - - /** - * Create the minimal store. - * - * @param def - * collection definition - * @param clazz - * bean type - * @param - * type of document in used - * @return - * json vector store - */ - public AstraDBRepository createCollection(CollectionDefinition def, Class clazz) { - return new AstraDBRepository<>(nsClient.createCollection(def, clazz)); - } - - // -------------------------- - // --- Keyspace ---- - // -------------------------- - - /** - * Validate a keyspace exists. - * - * @param keyspace - * current keyspace - * @return - * true if the keyspace exists - */ - public boolean isKeyspaceExists(String keyspace) { - return apiClient.isNamespaceExists(keyspace); - } - - /** - * List all keyspace for this environment. - * - * @return - * list of keyspace names - */ - public Stream findAllKeyspaceNames() { - return apiClient.findAllNamespaces(); - } - - /** - * get current keyspace name - * - * @return - * list of keyspace names - */ - public String getCurrentKeyspace() { - return this.nsClient.getNamespace(); - } - - /** - * Change the current keyspace. - * - * @param keyspace - * new keyspace - */ - public void changeKeyspace(String keyspace) { - this.nsClient = apiClient.namespace(keyspace); - } - - // -------------------- - // -- Sub resources -- - // -------------------- - - /** - * Access the database functions. - * - * @param storeName - * store identifier - * @return - * storeName client - */ - public AstraDBCollection getCollection(@NonNull String storeName) { - return new AstraDBCollection(nsClient.collection(storeName)); - } - - /** - * Access the database functions. - * - * @param storeName - * store identifier - * @param clazz - * type of object used - * @return - * storeName client - * @param - * type of the bean in use - */ - public AstraDBRepository getCollection(@NonNull String storeName, Class clazz) { - return new AstraDBRepository<>(nsClient.collectionRepository(storeName, clazz)); - } - - /** - * Access the low level Stargate Namespace resource operation. - * - * @return - * raw namespace client - */ - public NamespaceClient getNamespaceClient() { - return nsClient; - } - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBClients.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBClients.java deleted file mode 100644 index d7392020..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBClients.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.dtsx.astra.sdk; - -public class AstraDBClients { - - public static AstraDBAdmin create(String token) { - return new AstraDBAdmin(token); - } - - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBCollection.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBCollection.java deleted file mode 100644 index ba9f5f2b..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBCollection.java +++ /dev/null @@ -1,1347 +0,0 @@ -package com.dtsx.astra.sdk; - -import io.stargate.sdk.core.domain.Page; -import io.stargate.sdk.data.CollectionClient; -import io.stargate.sdk.data.domain.DocumentMutationResult; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.JsonResultUpdate; -import io.stargate.sdk.data.domain.UpdateStatus; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import io.stargate.sdk.data.domain.odm.DocumentResultMapper; -import io.stargate.sdk.data.domain.query.DeleteQuery; -import io.stargate.sdk.data.domain.query.DeleteResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import io.stargate.sdk.data.domain.query.SelectQueryBuilder; -import io.stargate.sdk.data.domain.query.UpdateQuery; -import lombok.Getter; -import lombok.NonNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; - -/** - * Client for AstraDB at collection level (crud for documents). - */ -@Getter -public class AstraDBCollection { - - /** - * Internal Stargate data api client. - */ - CollectionClient collectionClient; - - /** - * Constructor with the internal client - * - * @param collectionClient - * collection description - */ - AstraDBCollection(CollectionClient collectionClient) { - this.collectionClient = collectionClient; - } - - /** - * Access the name of the collection. - * - * @return - * collection name - */ - public String getName() { - return collectionClient.getCollection(); - } - - // -------------------------- - // --- Insert One ---- - // -------------------------- - - /** - * Insert a single document from a Json String. - * - * @param json - * json String - * @return - * mutation result with status and id - */ - public final JsonDocumentMutationResult insertOne(String json) { - return collectionClient.insertOne(json); - } - - /** - * Insert a single document from a Json String, asynchronously. - * - * @param json - * json Strings - * @return - * mutation result with status and id - */ - public final CompletableFuture insertOneAsync(String json) { - return collectionClient.insertOneAsync(json); - } - - /** - * Insert a single document from a Json Document (schemaless). - * - * @param document - * current bean - * @return - * mutation result with status and id - */ - public final JsonDocumentMutationResult insertOne(JsonDocument document) { - return collectionClient.insertOne(document); - } - - /** - * Insert a single document from a Json Document (schemaless), asynchronously. - * - * @param document - * current bean - * @return - * mutation result with status and id - */ - public final CompletableFuture insertOneASync(JsonDocument document) { - return collectionClient.insertOneAsync(document); - } - - /** - * Insert a single document from a Document<T> object (SchemaFull) - * - * @param document - * current bean - * @param - * payload of document - * @return - * mutation result with status and id - */ - public final DocumentMutationResult insertOne(Document document) { - return collectionClient.insertOne(document); - } - - /** - * Insert a single document from a Document<T> object (SchemaFull), asynchronously. - * - * @param document - * current bean - * @param - * payload of document - * @return - * mutation result with status and id - */ - public final CompletableFuture> insertOneASync(Document document) { - return collectionClient.insertOneASync(document); - } - - // -------------------------- - // --- Upsert One ---- - // -------------------------- - - /** - * Upsert a single document from a Json String. - * - * @param json - * json Strings - * @return - * mutation result with status and id - */ - public final JsonDocumentMutationResult upsertOne(String json) { - return collectionClient.upsertOne(json); - } - - /** - * Upsert a single document from a Json String, asynchronously. - * - * @param json - * json Strings - * @return - * mutation result with status and id - */ - public final CompletableFuture upsertOneASync(String json) { - return collectionClient.upsertOneAsync(json); - } - - /** - * Upsert a single document from a Json Document (schemaless). - * - * @param document - * current document - * @return - * document id - */ - public final JsonDocumentMutationResult upsertOne(JsonDocument document) { - return collectionClient.upsertOne(document); - } - - /** - * Upsert a single document from a Json Document (schemaless), asynchronously. - * - * @param document - * current document - * @return - * document id - */ - public final CompletableFuture upsertOneASync(JsonDocument document) { - return CompletableFuture.supplyAsync(() -> collectionClient.upsertOne(document)); - } - - /** - * Upsert a single document from a Document<T> object (SchemaFull) - * - * @param document - * current document - * @param - * payload of document - * @return - * document id - */ - public final DocumentMutationResult upsertOne(Document document) { - return collectionClient.upsertOne(document); - } - - /** - * Upsert a single document from a Document<T> object (SchemaFull), asynchronously - * - * @param document - * current document - * @param - * payload of document - * @return - * document id - */ - public final CompletableFuture> upsertOneASync(Document document) { - return collectionClient.upsertOneASync(document); - } - - // -------------------------- - // --- Insert Many ---- - // -------------------------- - - /** - * Insert multiple documents (up to 20) as a Json String , for more document check insertManyChunked. - * - * @param json - * json String - * @return - * for each document its id and insertion status - */ - public final List insertMany(String json) { - return collectionClient.insertMany(json); - } - - /** - * Insert multiple documents (up to 20) as a Json String , for more document check insertManyChunked, Asynchronously. - * - * @param json - * json String - * @return - * for each document its id and insertion status - */ - public final CompletableFuture> insertManyASync(String json) { - return collectionClient.insertManyASync(json); - } - - /** - * Insert multiple documents (up to 20) as JsonDocument List , for more document check insertManyChunked. - * - * @param documents - * list of documents - * @return - * for each document its id and insertion status - */ - public final List insertManyJsonDocuments(List documents) { - return collectionClient.insertManyJsonDocuments(documents); - } - - /** - * Insert multiple documents (up to 20) as JsonDocument List , for more document check insertManyChunked. - * - * @param documents - * list of documents - * @return - * for each document its id and insertion status - */ - public final List insertMany(JsonDocument... documents) { - return collectionClient.insertMany(documents); - } - - /** - * Insert multiple documents (up to 20) as JsonDocument List , for more document check insertManyChunked, asynchronously. - * - * @param documents - * list of documents - * @return - * for each document its id and insertion status - */ - public final CompletableFuture> insertManyJsonDocumentsASync(List documents) { - return collectionClient.insertManyJsonDocumentsASync(documents); - } - - /** - * Insert multiple documents (up to 20) as generic Document<T> List , for more document check insertManyChunked. - * - * @param documents - * list of documents - * @param - * payload of document - * @return - * list of ids - */ - public final List> insertMany(List> documents) { - return collectionClient.insertMany(documents); - } - - /** - * Insert multiple documents (up to 20) as generic Document<T> List , for more document check insertManyChunked, asynchronously. - * - * @param documents - * list of documents - * @param - * payload of document - * @return - * list of ids - */ - public final CompletableFuture>> insertManyASync(List> documents) { - return collectionClient.insertManyASync(documents); - } - - // ------------------------------- - // --- Insert Many Chunked ---- - // ------------------------------- - - /** - * Insert large number of documents as generic Document<T> List. Insertions a redistributed in chunks and chunk processing are parallelized. - * - * @param documents - * list of documents - * @param chunkSize - * number of documents in one chunk (up to 20) - * @param concurrency - * number of chunks processed in parallel (depends on document size) - * @param - * payload for the documents - * @return - * list of ids - */ - public final List> insertManyChunked(List> documents, int chunkSize, int concurrency) { - return collectionClient.insertManyChunked(documents, chunkSize, concurrency); - } - - /** - * Insert large number of documents as generic Document<T> List. Insertions a redistributed in chunks and chunk processing are parallelized., Asynchronously - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * number of blocks in parallel - * @param - * represent the pojo, payload of document - * @return - * list of ids - */ - public final CompletableFuture>> insertManyChunkedASync(List> documents, int chunkSize, int concurrency) { - return CompletableFuture.supplyAsync(() -> insertManyChunked(documents, chunkSize, concurrency)); - } - - /** - * Insert large number of documents as JsonDocument List. Insertions a redistributed in chunks and chunk processing are parallelized., - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * number of blocks in parallel - * @return - * list of mutation status - */ - public final List insertManyChunkedJsonDocuments(List documents, int chunkSize, int concurrency) { - return collectionClient.insertManyJsonDocumentsChunked(documents, chunkSize, concurrency); - } - - /** - * Insert large number of documents as JsonDocument List. Insertions a redistributed in chunks and chunk processing are parallelized., Asynchronously - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * number of blocks in parallel - * @return - * list of mutation status - */ - public final CompletableFuture> insertManyChunkedJsonDocumentsAsync(List documents, int chunkSize, int concurrency) { - return CompletableFuture.supplyAsync(() -> insertManyChunkedJsonDocuments(documents, chunkSize, concurrency)); - } - - // ------------------------------ - // --- Upsert Many ---- - // ------------------------------ - - /** - * Upsert any items in the collection. - * - * @param json - * json String - * @return - * list of statuses - */ - public final List upsertMany(String json) { - return collectionClient.upsertMany(json); - } - - /** - * Upsert any items in the collection. - * - * @param json - * json String - * @return - * list of statuses - */ - public final CompletableFuture> upsertManyASync(String json) { - return collectionClient.upsertManyASync(json); - } - - /** - * Upsert any items in the collection. - * - * @param documents - * current collection list - * @return - * list of statuses - */ - public final List upsertManyJsonDocuments(List documents) { - return collectionClient.upsertManyJsonDocuments(documents); - } - - /** - * Upsert any items in the collection. - * - * @param documents - * current collection list - * @return - * list of statuses - */ - public final CompletableFuture> upsertManyJsonDocumentsASync(List documents) { - return collectionClient.upsertManyJsonDocumentsASync(documents); - } - - /** - * Upsert any items in the collection. - * @param documents - * current collection list - * @return - * list of statuses - * @param - * represent the pojo, payload of document - */ - public final List> upsertMany(List> documents) { - return collectionClient.upsertMany(documents); - } - - /** - * Upsert any items in the collection asynchronously. - * - * @param documents - * current collection list - * @return - * list of statuses - * @param - * represent the pojo, payload of document - */ - public final CompletableFuture>> upsertManyASync(List> documents) { - return collectionClient.upsertManyASync(documents); - } - - // -------------------------------- - // --- Upsert Many Chunked ---- - // -------------------------------- - - /** - * Low level insertion of multiple records - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * concurrency - * @param - * represent the pojo, payload of document - * @return - * list of ids - */ - public final List> upsertManyChunked(List> documents, int chunkSize, int concurrency) { - return collectionClient.upsertManyChunked(documents, chunkSize, concurrency); - } - - /** - * Low level insertion of multiple records - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * concurrency - * @param - * represent the pojo, payload of document - * @return - * list of ids - */ - public final CompletableFuture>> upsertManyChunkedASync(List> documents, int chunkSize, int concurrency) { - return collectionClient.upsertManyChunkedASync(documents, chunkSize, concurrency); - } - - /** - * Low level insertion of multiple records - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * concurrency - * @return - * list of ids - */ - public final List upsertManyJsonDocumentsChunked(List documents, int chunkSize, int concurrency) { - return collectionClient.upsertManyJsonDocumentsChunked(documents, chunkSize, concurrency); - } - - /** - * Low level insertion of multiple records - * - * @param documents - * list of documents - * @param chunkSize - * size of the block - * @param concurrency - * concurrency - * @return - * list of ids - */ - public final CompletableFuture> upsertManyJsonDocumentsChunkedAsync(List documents, int chunkSize, int concurrency) { - return collectionClient.upsertManyJsonDocumentsChunkedASync(documents, chunkSize, concurrency); - } - - // -------------------------- - // --- Count ---- - // -------------------------- - - /** - * Count Document request. - * - * @return - * number of document. - */ - public Integer countDocuments() { - return collectionClient.countDocuments(); - } - - /** - * Count Document request. - * - * @param jsonFilter - * request to filter for count - * @return - * number of document. - */ - public Integer countDocuments(Filter jsonFilter) { - return collectionClient.countDocuments(jsonFilter); - } - - // -------------------------- - // --- Find One ---- - // -------------------------- - - /** - * Check existence of a document from its id. - * Projection to make it as light as possible. - * - * @param id - * document identifier - * @return - * existence status - */ - public boolean isDocumentExists(String id) { - return collectionClient.isDocumentExists(id); - } - - /** - * Find one document matching the query. - * - * @param rawJsonQuery - * query documents and vector - * @return - * result if exists - */ - public Optional findOne(String rawJsonQuery) { - return collectionClient.findOne(rawJsonQuery); - } - - /** - * Find one document matching the query. - * - * @param query - * query documents and vector - * @return - * result if exists - */ - public Optional findOne(SelectQuery query) { - return collectionClient.findOne(query); - } - - /** - * Find one document matching the query. - * - * @param query - * query documents and vector - * @param clazz - * class of the document - * @return - * result if exists - * @param - * class to be marshalled - */ - public Optional> findOne(SelectQuery query, Class clazz) { - return findOne(query).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Find one document matching the query. - * - * @param query - * query documents and vector - * @param clazz - * class of the document - * @return - * result if exists - * @param - * class to be marshalled - */ - public Optional> findOne(String query, Class clazz) { - return findOne(query).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Find one document matching the query. - * - * @param query - * query documents and vector - * @param mapper - * convert a json into expected pojo - * @return - * result if exists - * @param - * class to be marshalled - */ - public Optional> findOne(SelectQuery query, DocumentResultMapper mapper) { - return findOne(query).map(mapper::map); - } - - - /** - * Find one document matching the query. - * - * @param query - * query documents and vector - * @param mapper - * convert a json into expected pojo - * @return - * result if exists - * @param - * class to be marshalled - */ - public Optional> findOne(String query, DocumentResultMapper mapper) { - return findOne(query).map(mapper::map); - } - - // -------------------------- - // --- Find By Id ---- - // -------------------------- - - /** - * Find document from its id. - * - * @param id - * document identifier - * @return - * document - */ - public Optional findById(String id) { - return findOne(SelectQuery.findById(id)); - } - - /** - * Find document from its id. - * - * @param id - * document identifier - * @param clazz - * class for target pojo - * @return - * document - * @param - * class to be marshalled - */ - public Optional> findById(@NonNull String id, Class clazz) { - return findById(id).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Find document from its id. - * - * @param id - * document identifier - * @param mapper - * convert a json into expected pojo - * @return - * document - * @param - * class to be marshalled - */ - public Optional> findById(@NonNull String id, DocumentResultMapper mapper) { - return findById(id).map(mapper::map); - } - - // -------------------------- - // --- Find By Vector ---- - // -------------------------- - - /** - * Find document from its vector. - * - * @param vector - * document vector - * @return - * document - */ - public Optional findOneByVector(float[] vector) { - return findOne(SelectQuery.findByVector(vector)); - } - - /** - * Find document from its vector. - * - * @param vector - * document vector - * @param clazz - * class for target pojo - * @return - * document - * @param - * class to be marshalled - */ - public Optional> findOneByVector(float[] vector, Class clazz) { - return findOneByVector(vector).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Find document from its vector. - * - * @param vector - * document vector - * @param mapper - * convert a json into expected pojo - * @return - * document - * @param - * class to be marshalled - */ - public Optional> findOneByVector(float[] vector, DocumentResultMapper mapper) { - return findOneByVector(vector).map(mapper::map); - } - - // -------------------------- - // --- Find ---- - // -------------------------- - - /** - * Search records with a filter - * - * @param query - * filter - * @return - * all items - */ - public Stream find(SelectQuery query) { - return collectionClient.find(query); - } - - /** - * Find documents matching the pagedQuery. - * - * @param pagedQuery - * current pagedQuery - * @return - * page of results - */ - public Page findPage(SelectQuery pagedQuery) { - return collectionClient.findPage(pagedQuery); - } - - /** - * Find documents matching the pagedQuery. - * - * @param pagedQuery - * current pagedQuery - * @return - * page of results - */ - public Page findPage(String pagedQuery) { - return collectionClient.findPage(pagedQuery); - } - - /** - * Search records with a filter - * - * @param query - * filter - * @param clazz - * class for target pojo - * @return - * all items - * @param - * class to be marshalled - */ - public Stream> find(SelectQuery query, Class clazz) { - return collectionClient.find(query, clazz); - } - - /** - * Search records with a filter - * - * @param query - * filter - * @param mapper - * convert a json into expected pojo - * @return - * all items - * @param - * class to be marshalled - */ - public Stream> find(SelectQuery query, DocumentResultMapper mapper) { - return collectionClient.find(query, mapper); - } - - /** - * Get all items in a collection. - * - * @return - * all items - */ - public Stream findAll() { - return collectionClient.findAll(); - } - - /** - * Find All with Object Mapping. - * - * @param clazz - * class to be used - * @param - * class to be marshalled - * @return - * stream of results - */ - public Stream> findAll(Class clazz) { - return collectionClient.findAll(clazz); - } - - /** - * Find All with Object Mapping. - * - * @param mapper - * convert a json into expected pojo - * @param - * class to be marshalled - * @return - * stream of results - */ - public Stream> findAll(DocumentResultMapper mapper) { - return collectionClient.findAll(mapper); - } - - /** - * Find documents matching the query. - * - * @param query - * current query - * @param clazz - * class for target pojo - * @return - * page of results - * @param - * class to be marshalled - */ - public Page> findPage(SelectQuery query, Class clazz) { - return collectionClient.findPage(query, clazz); - } - - // -------------------------- - // --- Delete One ---- - // -------------------------- - - /** - * Delete single record from a request. - * - * @param deleteQuery - * delete query - * @return - * number of deleted records - */ - public DeleteResult deleteOne(DeleteQuery deleteQuery) { - return collectionClient.deleteOne(deleteQuery); - } - - /** - * Delete single record from its id. - * - * @param id - * id - * @return - * number of deleted records - */ - public DeleteResult deleteById(String id) { - return deleteOne(DeleteQuery.deleteById(id)); - } - - /** - * Delete single record from its vector. - * - * @param vector - * vector - * @return - * number of deleted records - */ - public DeleteResult deleteByVector(float[] vector) { - return deleteOne(DeleteQuery.deleteByVector(vector)); - } - - // -------------------------- - // --- Delete Many ---- - // -------------------------- - - /** - * Delete multiple records from a request. - * - * @param deleteQuery - * delete query - * @return - * number of deleted records - */ - public DeleteResult deleteMany(DeleteQuery deleteQuery) { - return collectionClient.deleteMany(deleteQuery); - } - - /** - * Delete multiple records from a request. - * - * @param deleteQuery - * delete query - * @return - * number of deleted records - */ - public DeleteResult deleteManyPaged(DeleteQuery deleteQuery) { - return collectionClient.deleteManyPaged(deleteQuery); - } - - /** - * Delete multiple records from a request. - * - * @param deleteQuery - * delete query - * @param concurrency - * how many threads in parallel - * @return - * number of deleted records - */ - public DeleteResult deleteManyChunked(DeleteQuery deleteQuery, int concurrency) { - return collectionClient.deleteManyChunked(deleteQuery, concurrency); - } - - /** - * Clear the collection. - * - * @return - * number of items deleted - */ - public DeleteResult deleteAll() { - return deleteMany(null); - } - - // -------------------------- - // --- Update ---- - // -------------------------- - - /** - * Find ana update a record based on a query, - * - * @param query - * query to find the record - * @return - * result of the update - */ - public JsonResultUpdate findOneAndUpdate(UpdateQuery query) { - return collectionClient.findOneAndDelete(query); - } - - /** - * Find ana replace a record based on a query, - * - * @param query - * query to find the record - * @return - * result of the update - */ - public JsonResultUpdate findOneAndReplace(UpdateQuery query) { - return collectionClient.findOneAndReplace(query); - } - - /** - * Find ana delete a record based on a query. - * - * @param query - * query to find the record - * @return - * result of the update - */ - public JsonResultUpdate findOneAndDelete(UpdateQuery query) { - return collectionClient.findOneAndDelete(query); - } - - // -------------------------- - // --- UpdateOne ---- - // -------------------------- - - /** - * Update a single record. - * - * @param query - * query to find the record - * @return - * update status - */ - public UpdateStatus updateOne(UpdateQuery query) { - return collectionClient.updateOne(query); - } - - // -------------------------- - // --- UpdateMany ---- - // -------------------------- - - /** - * Update many records. - * - * @param query - * query to find the record - * @return - * update status - */ - public UpdateStatus updateMany(UpdateQuery query) { - return collectionClient.updateMany(query); - } - - // ------------------------------ - // --- Semantic Search ---- - // ------------------------------ - - /** - * Query builder. - * - * @param vector - * vector embeddings - * @param limit - * limit for output - * @return - * result page - */ - public Stream findVector(float[] vector, Integer limit) { - return findVector(vector, null, limit); - } - - /** - * Query builder. - * - * @param vector - * vector embeddings - * @param filter - * metadata filter - * @param limit - * limit for output - * @return - * result page - */ - public Stream findVector(float[] vector, Filter filter, Integer limit) { - return find(SelectQuery.builder() - .filter(filter) - .orderByAnn(vector) - .withLimit(limit) - .includeSimilarity() - .build()); - } - - - /** - * find Page. - * - * @param query - * return query Page - * @return - * page of results - */ - public Page findVectorPage(SelectQuery query) { - return findPage(query); - } - - /** - * Query builder. - * - * @param vector - * vector embeddings - * @param filter - * metadata filter - * @param limit - * limit - * @param pagingState - * paging state - * @return - * result page - */ - public Page findVectorPage(float[] vector, Filter filter, Integer limit, String pagingState) { - return findVectorPage(SelectQuery.builder() - .filter(filter) - .orderByAnn(vector) - .withLimit(limit) - .withPagingState(pagingState) - .includeSimilarity() - .build()); - } - - /** - * Search similarity from the vector (page by 20) - * - * @param vector - * vector embeddings - * @param filter - * metadata filter - * @param limit - * limit - * @param pagingState - * paging state - * @param clazz - * current class. - * @param - * type of document - * @return - * page of results - */ - public Page> findVectorPage(float[] vector, Filter filter, Integer limit, String pagingState, Class clazz) { - return collectionClient.findVectorPage(vector, filter, limit, pagingState, clazz); - } - - /** - * Search similarity from the vector (page by 20) - * - * @param vector - * vector embeddings - * @param filter - * metadata filter - * @param limit - * limit - * @param pagingState - * paging state - * @param mapper - * result mapper - * @param - * type of document - * @return - * page of results - */ - public Page> findVectorPage(float[] vector, Filter filter, Integer limit, String pagingState, DocumentResultMapper mapper) { - return collectionClient.findVectorPage(vector, filter, limit, pagingState, mapper); - } - - /** - * Retrieve documents from a vector. - * - * @param vector - * vector list - * @return - * the list of results - */ - public Stream findVector(float[] vector) { - return find(SelectQuery.findByVector(vector)); - } - - /** - * Retrieve documents from a vector. - * - * @param vector - * vector list - * @param recordCount - * record count - * @param filter - * metadata filter - * @return - * the list of results - */ - public Stream findVector(float[] vector, Filter filter, int recordCount) { - return findVector(SelectQuery.builder() - .includeSimilarity() - .filter(filter) - .withLimit(recordCount) - .orderByAnn(vector) - .build()); - } - - /** - * Retrieve documents from a vector. - * - * @param vector - * vector list - * @param clazz - * expected output class - * @param - * expected type - * @return - * the list of results - */ - public Stream> findVector(float[] vector, Class clazz) { - return findVector(vector).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Retrieve documents from a vector. - * - * @param vector - * vector list - * @param mapper - * mapper for results - * @return - * the list of results - * @param - * expected type - */ - public Stream> findVector(float[] vector, DocumentResultMapper mapper) { - return findVector(vector).map(mapper::map); - } - - // Find Vector with a filter and conditions - - /** - * Full-fledged search with a filter and conditions. - * - * @param query - * vector query - * @return - * stream of results - */ - public Stream findVector(SelectQuery query) { - return find(query); - } - - /** - * Full-fledged search with a filter and conditions. - * - * @param query - * vector query - * @param clazz - * clazz for returned type - * @return - * stream of results - * @param - * expected type - */ - public Stream> findVector(SelectQuery query, Class clazz) { - return findVector(query).map(r -> new DocumentResult<>(r, clazz)); - } - - /** - * Full-fledged search with a filter and conditions. - * - * @param query - * vector query - * @param mapper - * mapper for results - * @return - * stream of results - * @param - * expected type - */ - public Stream> findVector(SelectQuery query, DocumentResultMapper mapper) { - return findVector(query).map(mapper::map); - } - - // Find Vector with a filter and conditions - - /** - * Query builder. - * - * @param vector - * vector embeddings - * @param filter - * metadata filter - * @param limit - * how many items to be retrieved at most - * @param includeSimilarity - * include similarity - * @return - * result page - */ - public Stream findVector(float[] vector, Filter filter, Integer limit, boolean includeSimilarity) { - SelectQueryBuilder builder = SelectQuery - .builder() - .filter(filter) - .withLimit(limit) - .orderByAnn(vector); - if (includeSimilarity) builder.includeSimilarity(); - return findVector(builder.build()); - } - - /** - * Query builder. - * - * @param query - * query - * @return - * result page - */ - public Page findPageVector(SelectQuery query) { - return findPage(query); - } - - /** - * Internal Client for a collection. - * - * @return - * collection client - */ - public CollectionClient getRawCollectionClient() { - return collectionClient; - } - - /** - * Set this options during insertMany: {"ordered": true}. - */ - public void enableOrderingWhenInsert() { - collectionClient.setInsertManyOrdered(true); - } - - /** - * Set this options during insertMany: {"ordered": false}. - */ - public void disableOrderingWhenInsert() { - collectionClient.setInsertManyOrdered(false); - } - - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBRepository.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBRepository.java deleted file mode 100644 index 55e0f250..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/AstraDBRepository.java +++ /dev/null @@ -1,464 +0,0 @@ -package com.dtsx.astra.sdk; - -import io.stargate.sdk.core.domain.Page; -import io.stargate.sdk.data.CollectionRepository; -import io.stargate.sdk.data.domain.DocumentMutationResult; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import io.stargate.sdk.data.domain.query.DeleteQuery; -import io.stargate.sdk.data.domain.query.DeleteResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import lombok.Getter; -import lombok.NonNull; - -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Client for AstraDB collection using repository pattern. - * - * @param - * working document - */ -@Getter -public class AstraDBRepository { - - CollectionRepository collectionRepository; - - /** - * Default Constructor. - * - * @param collectionRepository - * current collection - */ - AstraDBRepository(CollectionRepository collectionRepository) { - this.collectionRepository = collectionRepository; - } - - /** - * Check existence of a document from its id. - * Projection to make it as light as possible. - * - * @param id - * document identifier - * @return - * existence status - */ - public boolean exists(String id) { - return collectionRepository.exists(id); - } - - // -------------------------- - // --- Insert ---- - // -------------------------- - - /** - * Save a NEW RECORD with a defined id. - * @param bean - * current object - * @return - * generated identifier - */ - public DocumentMutationResult insert(Document bean) { - return collectionRepository.insert(bean); - } - - /** - * Save a NEW RECORD with a defined id asynchronously - * - * @param bean - * current object - * @return - * generated identifier - */ - public CompletableFuture> insertAsync(Document bean) { - return collectionRepository.insertASync(bean); - } - - // -------------------------- - // --- Insert All ---- - // -------------------------- - - /** - * Low level insertion of multiple records, they should not exist, or it will fail. - * - * @param documents - * list of documents - * @return - * list of ids - */ - public final List> insert(List> documents) { - return collectionRepository.insert(documents); - } - - /** - * Insert a List asynchronously. - * - * @param documents - * list of documents - * @return - * list of ids - */ - public final CompletableFuture>> insertASync(List> documents) { - return collectionRepository.insertASync(documents); - } - - /** - * Low level insertion of multiple records, they should not exist, or it will fail. - * - * @param documents - * list of documents - * @param chunkSize - * how many document per chunk - * @param concurrency - * how many thread in parallel - * @return - * list of ids - */ - public final List> insert(List> documents, int chunkSize, int concurrency) { - return collectionRepository.insert(documents, chunkSize, concurrency); - } - - /** - * Insert a List asynchronously. - * - * @param documents - * list of documents - * @param chunkSize - * split into chunks - * @param concurrency - * number of thread to process the chunks - * @return - * list of ids - */ - public final CompletableFuture>> insertASync(List> documents, int chunkSize, int concurrency) { - return collectionRepository.insertASync(documents, chunkSize, concurrency); - } - - // -------------------------- - // --- Save ---- - // -------------------------- - - /** - * Save by record. - * - * @param current - * object Mapping - * @return - * an unique identifier for the document - */ - public final DocumentMutationResult save(@NonNull Document current) { - return collectionRepository.save(current); - } - - /** - * Save by record asynchronously. - * - * @param current - * object Mapping - * @return - * an unique identifier for the document - */ - public final CompletableFuture> saveASync(@NonNull Document current) { - return collectionRepository.saveASync(current); - } - - - // -------------------------- - // --- saveAll ---- - // -------------------------- - - /** - * Create a new document a generating identifier. - * - * @param documentList - * object Mapping - * @return - * an unique identifier for the document - */ - public final List> saveAll(List> documentList) { - return collectionRepository.saveAll(documentList); - } - - /** - * Create a new document a generating identifier asynchronously - * - * @param documentList - * object Mapping - * @return - * an unique identifier for the document - */ - public final CompletableFuture>> saveAllASync(List> documentList) { - return collectionRepository.saveAllASync(documentList); - } - - /** - * Create a new document a generating identifier. - * - * @param documentList - * object Mapping - * @param chunkSize - * size of the chunk to process items - * @param concurrency - * concurrency to process items - * @return - * an unique identifier for the document - */ - public final List> saveAll(List> documentList, int chunkSize, int concurrency) { - return collectionRepository.saveAll(documentList, chunkSize, concurrency); - } - - /** - * Create a new document a generating identifier asynchronously - * - * @param documentList - * object Mapping - * @param chunkSize - * size of the chunk to process items - * @param concurrency - * concurrency to process items - * @return - * an unique identifier for the document - */ - public final CompletableFuture>> saveAllASync(List> documentList, int chunkSize, int concurrency) { - return collectionRepository.saveAllASync(documentList, chunkSize, concurrency); - } - - // -------------------------- - // --- Count ---- - // -------------------------- - - /** - * Count Document request. - * - * @return - * number of document. - */ - public final int count() { - return count(null); - } - - /** - * Count Document request. - * - * @param jsonFilter - * a filter for the count - * @return - * number of document. - */ - public final int count(Filter jsonFilter) { - return collectionRepository.count(jsonFilter); - } - - // -------------------------- - // --- Find ---- - // -------------------------- - - /** - * Find by id. - * - * @param id - * identifier - * @return - * object if presents - */ - public Optional> findById(@NonNull String id) { - return collectionRepository.findById(id); - } - - /** - * Find all item in the collection. - * - * @return - * retrieve all items - */ - public Stream> findAll() { - return collectionRepository.search(); - } - - /** - * Find all item in the collection. - * - * @param query - * search with a query - * @return - * retrieve all items - */ - public Stream> find(@NonNull SelectQuery query) { - return collectionRepository.search(query); - } - - /** - * Find a page in the collection. - * - * @param query - * current query - * @return - * page of records - */ - public Page> searchPage(SelectQuery query) { - return collectionRepository.searchPage(query); - } - - // -------------------------- - // --- Delete ---- - // -------------------------- - - /** - * Delete a document from id or vector. - * - * @param document - * document - * @return - * if document has been deleted. - */ - public boolean delete(Document document) { - return collectionRepository.delete(document); - } - - /** - * Delete all documents - * - * @return - * number of document deleted - */ - public DeleteResult deleteAll() { - return collectionRepository.deleteAll(); - } - - /** - * Use parallelism and async to delete all records. - * - * @param documents - * list of records - * @return - * number of records deleted - */ - public int deleteAll(List> documents) { - List> futures = documents.stream() - .map(record -> CompletableFuture.supplyAsync(() -> delete(record) ? 1 : 0)) - .collect(Collectors.toList()); - return futures.stream() - .map(CompletableFuture::join) // This will wait for the result of each future - .mapToInt(Integer::intValue) - .sum(); - } - - /** - * Delete item through a query. - * - * @param deleteQuery - * delete query - * @return - * number of records deleted - */ - public DeleteResult deleteAll(DeleteQuery deleteQuery) { - return collectionRepository.deleteAll(deleteQuery); - } - - /** - * Delete item through a query. - * - * @param deleteQuery - * delete query - * @param concurrent - * How many threads in parallel - * @return - * number of records deleted - */ - public DeleteResult deleteAllChunked(DeleteQuery deleteQuery, int concurrent) { - return collectionRepository.deleteAllChunked(deleteQuery, concurrent); - } - - // ------------------------------ - // --- OPERATIONS VECTOR ---- - // ------------------------------ - - /** - * Find by vector - * - * @param vector - * vector - * @return - * object if presents - */ - public Optional> findByVector(float[] vector) { - return collectionRepository.findByVector(vector); - } - - /** - * Delete by vector - * - * @param vector - * vector - * @return - * if object deleted - */ - public boolean deleteByVector(float[] vector) { - return collectionRepository.deleteByVector(vector); - } - - - /** - * Delete by vector - * - * @param id - * id - * @return - * if object deleted - */ - public boolean deleteById(String id) { - return collectionRepository.deleteById(id); - } - - // ------------------------------ - // --- Similarity Search ---- - // ------------------------------ - - /** - * Search similarity from the vector and a limit, if a limit / no paging - * - * @param vector - * vector - * @param metadataFilter - * metadata filtering - * @return - * page of results - */ - public Page> findVector(float[] vector, Filter metadataFilter) { - return collectionRepository.findVector(vector, metadataFilter); - } - - /** - * Search similarity from the vector and a limit, if a limit / no paging - * - * @param vector - * vector - * @param limit - * return count - * @return - * page of results - */ - public List> findVector(float[] vector, Integer limit) { - return collectionRepository.findVector(vector, limit); - } - /** - * Search similarity from the vector and a limit, if a limit / no paging - * - * @param vector - * vector - * @param limit - * return count - * @param metadataFilter - * metadata filtering - * @return - * page of results - */ - public List> findVector(float[] vector, Filter metadataFilter, Integer limit) { - return collectionRepository.findVector(vector, metadataFilter, limit); - } -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AbstractCassandraTable.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AbstractCassandraTable.java deleted file mode 100644 index dc0ccfe0..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AbstractCassandraTable.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.datastax.oss.driver.api.core.cql.Row; - -import java.util.concurrent.CompletableFuture; - -/** - * Abstract class for table management at Cassandra level. - * - * @param - * object in use with Cassandra - */ -public abstract class AbstractCassandraTable { - - /** - * Class needed to create a SAI Index. - */ - public static final String SAI_INDEX_CLASSNAME = "org.apache.cassandra.index.sai.StorageAttachedIndex"; - - /** - * Table column names. - */ - public static final String PARTITION_ID = "partition_id"; - - /** - * Table column names. - */ - public static final String ROW_ID = "row_id"; - - /** - * Table column names. - */ - public static final String ATTRIBUTES_BLOB = "attributes_blob"; - - /** - * Table column names. - */ - public static final String BODY_BLOB = "body_blob"; - - /** - * Table column names. - */ - public static final String METADATA_S = "metadata_s"; - - /** - * Table column names. - */ - public static final String VECTOR = "vector"; - - /** - * Table column names. - */ - public static final String COLUMN_SIMILARITY = "similarity"; - - /** - * Default Number of item retrieved - */ - public static final int DEFAULT_RECORD_COUNT = 4; - - /** Session to Cassandra. */ - protected final CqlSession cqlSession; - - /** Destination keyspace. */ - protected final String keyspaceName; - - /** Destination table. */ - protected final String tableName; - - /** - * Default cosntructor. - * - * @param session - * cassandra session - * @param keyspaceName - * keyspace - * @param tableName - * table Name - */ - public AbstractCassandraTable(CqlSession session, String keyspaceName, String tableName) { - this.cqlSession = session; - this.keyspaceName = keyspaceName; - this.tableName = tableName; - } - - /** - * Create table if not exist. - */ - public abstract void create(); - - /** - * Upsert a row of the table. - * - * @param row - * current row - */ - public abstract void put(RECORD row); - - /** - * Should be table to map from a Cassandra row to a record. - * - * @param row - * current cassandra row - * @return - * current record - */ - public abstract RECORD mapRow(Row row); - - /** - * Insert a row asynchronously. - * - * @param inputRow - * current row - * @return - * output - */ - public CompletableFuture putAsync(final RECORD inputRow) { - return CompletableFuture.runAsync(() -> put(inputRow)); - } - - /** - * Delete the table. - */ - public void delete() { - cqlSession.execute("DROP TABLE IF EXISTS " + keyspaceName + "." + tableName); - } - - /** - * Empty a table - */ - public void clear() { - cqlSession.execute("TRUNCATE " + keyspaceName + "." + tableName); - } - - /** - * Gets cqlSession - * - * @return value of cqlSession - */ - public CqlSession getCqlSession() { - return cqlSession; - } -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnQuery.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnQuery.java deleted file mode 100644 index fcfd72f3..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnQuery.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; -import java.util.Map; - -/** - * Wrap query parameters as a Bean. - */ -@Getter @Setter @Builder -public class AnnQuery { - - /** - * Maximum number of item returned - */ - private int recordCount; - - /** - * Minimum distance computation - */ - private double threshold = 0.0; - - /** - * Embeddings to be searched. - */ - private List embeddings; - - /** - * Default distance is cosine - */ - private CassandraSimilarityMetric metric = CassandraSimilarityMetric.COSINE; - - /** - * If provided search on metadata - */ - private Map metaData; - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnResult.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnResult.java deleted file mode 100644 index 7c1e91cd..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/AnnResult.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import lombok.Data; - -/** - * Item Retrieved by the search. - * - * @param - * record. - */ -@Data -public class AnnResult { - - /** - * Embedded object - */ - private EMBEDDED embedded; - - /** - * Score - */ - private float similarity; - - /** - * Default constructor. - */ - public AnnResult() {} - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassIO.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassIO.java deleted file mode 100644 index ded33f8d..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassIO.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import io.stargate.sdk.utils.Utils; -import lombok.extern.slf4j.Slf4j; - -import java.io.File; -import java.nio.file.Paths; -import java.util.UUID; - -import static com.dtsx.astra.sdk.AstraDBAdmin.DEFAULT_KEYSPACE; - -/** - * Utility to work with CassIO and Astra - */ -@Slf4j -public class CassIO { - - private static CqlSession cqlSession; - - /** - * Default constructor. - */ - public CassIO() { - Runtime.getRuntime().addShutdownHook(shutdownHook); - } - - /** - * Shutdown hook to close Session. - */ - private final Thread shutdownHook = new Thread() { - public void run() { - if (cqlSession != null) { - cqlSession.close(); - } - } - }; - - /** - * Accessing the session. - * - * @return - * the cassandra session - */ - public static CqlSession getCqlSession() { - if (cqlSession == null) { - throw new IllegalStateException("CqlSession not initialized, please use init() method"); - } - return cqlSession; - } - - /** - * Initialization from db is and region. - * - * @param cqlSession - * cassandra connection - * @return - * the cassandra session initialized - */ - public static synchronized CqlSession init(CqlSession cqlSession) { - if (cqlSession == null) { - throw new IllegalStateException("CqlSession not initialized, please use init() method"); - } - CassIO.cqlSession = cqlSession; - return cqlSession; - } - - /** - * Initialization from db is and region. - * - * @param dbId - * database identifier. - * @param dbRegion - * database region, - * @param token - * astra token - * @return - * the cassandra session initialized - */ - public static CqlSession init(String token, UUID dbId, String dbRegion) { - return init(token, dbId, dbRegion, DEFAULT_KEYSPACE, AstraEnvironment.PROD); - } - - /** - * Initialization from db is and region. - * - * @param dbId - * database identifier. - * @param dbRegion - * database region, - * @param token - * astra token - * @param keyspace - * destination keyspace - * @return - * the cassandra session initialized - */ - public static CqlSession init(String token, UUID dbId, String dbRegion, String keyspace) { - return init(token, dbId, dbRegion, keyspace, AstraEnvironment.PROD); - } - - /** - * Initialization from db is and region. - * - * @param dbId - * database identifier. - * @param dbRegion - * database region, - * @param token - * astra token - * @param keyspace - * destination keyspace - * @param env - * destination environment - * @return - * the cassandra session initialized - */ - public static synchronized CqlSession init(String token, UUID dbId, String dbRegion, String keyspace, AstraEnvironment env) { - String secureConnectBundleFolder = Utils - .readEnvVariable("ASTRA_DB_SCB_FOLDER") - .orElse(System.getProperty("user.home") + File.separator + ".astra" + File.separator + "scb"); - if (!new File(secureConnectBundleFolder).exists()) { - if (new File(secureConnectBundleFolder).mkdirs()) { - log.info("+ Folder Created to hold SCB {}", secureConnectBundleFolder); - } - } - - // Download SCB with Devops API - AstraDBOpsClient devopsApiClient = new AstraDBOpsClient(token, env); - devopsApiClient.database(dbId.toString()).downloadAllSecureConnectBundles(secureConnectBundleFolder); - String scb = secureConnectBundleFolder + File.separator + "scb_" + dbId + "_" + dbRegion + ".zip"; - // Create Session - cqlSession = CqlSession.builder() - .withAuthCredentials("token", token) - .withCloudSecureConnectBundle(Paths.get(scb)) - .withKeyspace(keyspace) - .build(); - return cqlSession; - } - - /** - * Create a new table to store vectors. - * - * @param tableName - * table name - * @param vectorDimension - * vector dimension - * @return - * table to store vector - */ - public static MetadataVectorTable metadataVectorTable(String tableName, int vectorDimension) { - if (tableName == null || tableName.isEmpty()) throw new IllegalArgumentException("Table name must be provided"); - if (vectorDimension < 1) throw new IllegalArgumentException("Vector dimension must be greater than 0"); - return new MetadataVectorTable( - getCqlSession(), - cqlSession.getKeyspace().orElseThrow(() -> - new IllegalArgumentException("CqlSession does not select any keyspace")).asInternal(), - tableName, vectorDimension); - } - - public static ClusteredMetadataVectorTable clusteredMetadataVectorTable(String tableName, int vectorDimension) { - if (tableName == null || tableName.isEmpty()) throw new IllegalArgumentException("Table name must be provided"); - if (vectorDimension < 1) throw new IllegalArgumentException("Vector dimension must be greater than 0"); - return new ClusteredMetadataVectorTable( - getCqlSession(), - cqlSession.getKeyspace().orElseThrow(() -> - new IllegalArgumentException("CqlSession does not select any keyspace")).asInternal(), - tableName, vectorDimension); - } -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassandraSimilarityMetric.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassandraSimilarityMetric.java deleted file mode 100644 index 2f02dfc8..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/CassandraSimilarityMetric.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import lombok.Getter; - -/** - * Option for the similarity metric. - */ -@Getter -public enum CassandraSimilarityMetric { - - /** dot product. */ - DOT_PRODUCT("DOT_PRODUCT","similarity_dot_product"), - - /** cosine. */ - COSINE("COSINE","similarity_cosine"), - - /** euclidean. */ - EUCLIDEAN("EUCLIDEAN","similarity_euclidean"); - - /** - * Option. - */ - private final String option; - - /** - * Function. - */ - private final String function; - - /** - * Constructor. - * - * @param option - * option in the index creation - * @param function - * function to be used in the query - */ - CassandraSimilarityMetric(String option, String function) { - this.option = option; - this.function = function; - } - - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorRecord.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorRecord.java deleted file mode 100644 index 42d264b6..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorRecord.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.cql.SimpleStatement; -import com.datastax.oss.driver.api.core.data.CqlVector; -import com.datastax.oss.driver.api.core.uuid.Uuids; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.ATTRIBUTES_BLOB; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.BODY_BLOB; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.METADATA_S; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.PARTITION_ID; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.ROW_ID; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.VECTOR; - -/** - * Partitioned table with cluster and vector. - */ -@Data -@AllArgsConstructor -public class ClusteredMetadataVectorRecord { - - /** Partition id (clustered). */ - String partitionId = "default"; - - /** - * Metadata (for metadata filtering) - */ - Map metadata = new HashMap<>(); - - /** - * Vector Store - */ - List vector; - - /** Row identifier. */ - UUID rowId; - - /** Text body. */ - String body; - - /** - * Store special attributes - */ - String attributes; - - /** - * Default Constructor. - */ - public ClusteredMetadataVectorRecord() {} - - /** - * Create a record with a vector. - * - * @param vector current vector. - */ - public ClusteredMetadataVectorRecord(List vector) { - this.rowId = Uuids.timeBased(); - this.vector = vector; - } - - - -} \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorTable.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorTable.java deleted file mode 100644 index 67c323c7..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorTable.java +++ /dev/null @@ -1,386 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.datastax.oss.driver.api.core.cql.PreparedStatement; -import com.datastax.oss.driver.api.core.cql.Row; -import com.datastax.oss.driver.api.core.cql.SimpleStatement; -import com.datastax.oss.driver.api.core.data.CqlVector; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; - -import static io.stargate.sdk.utils.AnsiUtils.cyan; -import static io.stargate.sdk.utils.AnsiUtils.yellow; - -/** - * Table representing persistence for LangChain operations. - * - parition key: partitionId - * - clustering key: rowId - * - column: value - */ -@Slf4j -public class ClusteredMetadataVectorTable extends AbstractCassandraTable { - - /** - * Dimension of the vector in use - */ - private final int vectorDimension; - - /** - * Similarity Metric, Vector is indexed with this metric. - */ - private final CassandraSimilarityMetric similarityMetric; - - /** - * Prepared statements - */ - private PreparedStatement findPartitionStatement; - private PreparedStatement deletePartitionStatement; - private PreparedStatement findRowStatement; - private PreparedStatement deleteRowStatement; - private PreparedStatement insertRowStatement; - - /** - * Constructor with mandatory parameters. - * - * @param session cassandra session - * @param keyspaceName keyspace name - * @param tableName table name - * @param vectorDimension vector dimension - * @param metric similarity metric - */ - public ClusteredMetadataVectorTable( - @NonNull CqlSession session, - @NonNull String keyspaceName, - @NonNull String tableName, - @NonNull Integer vectorDimension, - @NonNull CassandraSimilarityMetric metric) { - super(session, keyspaceName, tableName); - this.vectorDimension = vectorDimension; - this.similarityMetric = metric; - } - - /** - * Constructor with mandatory parameters. - * - * @param session cassandra session - * @param keyspaceName keyspace name - * @param tableName table name - * @param vectorDimension vector dimension - */ - public ClusteredMetadataVectorTable(CqlSession session, String keyspaceName, String tableName, int vectorDimension) { - this(session, keyspaceName, tableName, vectorDimension, CassandraSimilarityMetric.COSINE); - } - - /** - * Builder class for creating instances of {@link ClusteredMetadataVectorTable}. - * This class follows the builder pattern to allow setting various parameters - * before creating an instance of {@link ClusteredMetadataVectorTable}. - */ - public static class Builder { - private CqlSession session; - private String keyspaceName; - private String tableName; - private Integer vectorDimension; - private CassandraSimilarityMetric metric = CassandraSimilarityMetric.COSINE; - - /** - * Sets the CqlSession. - * - * @param session The CqlSession to be used by the ClusteredMetadataVectorCassandraTable. - * @return The current Builder instance for chaining. - */ - public Builder withSession(CqlSession session) { - this.session = session; - return this; - } - - /** - * Sets the keyspace name. - * - * @param keyspaceName The name of the keyspace to be used. - * @return The current Builder instance for chaining. - */ - public Builder withKeyspaceName(String keyspaceName) { - this.keyspaceName = keyspaceName; - return this; - } - - /** - * Sets the table name. - * - * @param tableName The name of the table to be used. - * @return The current Builder instance for chaining. - */ - public Builder withTableName(String tableName) { - this.tableName = tableName; - return this; - } - - /** - * Sets the vector dimension. - * - * @param vectorDimension The vector dimension to be used. - * @return The current Builder instance for chaining. - */ - public Builder withVectorDimension(Integer vectorDimension) { - this.vectorDimension = vectorDimension; - return this; - } - - /** - * Sets the similarity metric. - * - * @param metric The SimilarityMetric to be used. - * @return The current Builder instance for chaining. - */ - public Builder withMetric(CassandraSimilarityMetric metric) { - this.metric = metric; - return this; - } - - /** - * Creates a new instance of ClusteredMetadataVectorCassandraTable with the current builder settings. - * - * @return A new instance of ClusteredMetadataVectorCassandraTable. - */ - public ClusteredMetadataVectorTable build() { - return new ClusteredMetadataVectorTable(session, keyspaceName, tableName, vectorDimension, metric); - } - - /** - * Default constructor for Builder. - */ - public Builder() {} - } - - /** - * Builder for the class. - * - * @return - * builder for the class - */ - public static ClusteredMetadataVectorTable.Builder builder() { - return new Builder(); - } - - /** - * Prepare statements on first request. - */ - private synchronized void prepareStatements() { - if (findPartitionStatement == null) { - findPartitionStatement = cqlSession.prepare( - "select * from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? "); - deletePartitionStatement = cqlSession.prepare( - "delete from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? "); - findRowStatement = cqlSession.prepare( - "select * from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? " - + " and " + ROW_ID + " = ? "); - deleteRowStatement = cqlSession.prepare( - "delete from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? " - + " and " + ROW_ID + " = ? "); - insertRowStatement = cqlSession.prepare("INSERT INTO " + keyspaceName + "." + tableName + " (" - + PARTITION_ID + "," + ROW_ID + "," + VECTOR + "," + ATTRIBUTES_BLOB + "," + BODY_BLOB + "," + METADATA_S + ") VALUES (?,?,?,?,?,?)"); - } - } - - /* {@inheritDoc} */ - @Override - public void create() { - // Create Table - cqlSession.execute("CREATE TABLE IF NOT EXISTS " + tableName + " (" + - PARTITION_ID + " text, " + - ROW_ID + " timeuuid, " + - ATTRIBUTES_BLOB + " text, " + - BODY_BLOB + " text, " + - METADATA_S + " map, " + - VECTOR + " vector, " + - "PRIMARY KEY ((" + PARTITION_ID + "), " + ROW_ID + ")) " + - "WITH CLUSTERING ORDER BY (" + ROW_ID + " DESC)"); - cqlSession.execute( - "CREATE CUSTOM INDEX IF NOT EXISTS idx_vector_" + tableName - + " ON " + tableName + " (" + VECTOR + ") " - + "USING 'org.apache.cassandra.index.sai.StorageAttachedIndex' " - + "WITH OPTIONS = { 'similarity_function': '" + similarityMetric.getOption() + "'};"); - log.info("+ Index '{}' has been created (if needed).", "idx_vector_" + tableName); - // Create Metadata Index - cqlSession.execute( - "CREATE CUSTOM INDEX IF NOT EXISTS eidx_metadata_s_" + tableName - + " ON " + tableName + " (ENTRIES(" + METADATA_S + ")) " - + "USING 'org.apache.cassandra.index.sai.StorageAttachedIndex' "); - log.info("+ Index '{}' has been created (if needed).", "eidx_metadata_s_" + tableName); - } - - /** - * Find a partition. - * - * @param partitionDd - * partition id - * @return - * list of rows - */ - public List findPartition(@NonNull String partitionDd) { - prepareStatements(); - return cqlSession.execute(findPartitionStatement.bind(partitionDd)) - .all().stream() - .map(this::mapRow) - .collect(Collectors.toList()); - } - - /** - * Delete a partition. - * - * @param partitionDd - * partition id - */ - public void deletePartition(@NonNull String partitionDd) { - prepareStatements(); - cqlSession.execute(deletePartitionStatement.bind(partitionDd)); - } - - /** - * Access a record by its id - * - * @param partitionId - * partition id - * @param rowId - * rowId - * @return - * record if exists - */ - public Optional get(String partitionId, UUID rowId) { - prepareStatements(); - return Optional - .ofNullable(cqlSession.execute(findRowStatement.bind(partitionId, rowId)) - .one()) - .map(this::mapRow); - } - - /** - * Access a record by its id - * - * @param partitionId - * partition id - * @param rowId - * rowId - */ - public void delete(String partitionId, UUID rowId) { - prepareStatements(); - cqlSession.execute(deleteRowStatement.bind(partitionId, rowId)); - } - - public void save(ClusteredMetadataVectorRecord row) { - put(row); - } - - /* {@inheritDoc} */ - @Override - public void put(ClusteredMetadataVectorRecord row) { - prepareStatements(); - cqlSession.execute(insertRowStatement.bind( - row.getPartitionId(), - row.getRowId(), - CqlVector.newInstance(row.getVector()), - row.getAttributes(), - row.getBody(), - row.getMetadata())); - } - - /* {@inheritDoc} */ - @Override - @SuppressWarnings("unchecked") - public ClusteredMetadataVectorRecord mapRow(Row cqlRow) { - if (cqlRow == null ) return null; - ClusteredMetadataVectorRecord record = new ClusteredMetadataVectorRecord(); - // Clustered - record.setPartitionId(cqlRow.getString(PARTITION_ID)); - // Vector - record.setVector(((CqlVector) Objects.requireNonNull(cqlRow.getObject(VECTOR))) - .stream().collect(Collectors.toList())); - // Always There - record.setRowId(cqlRow.getUuid(ROW_ID)); - record.setBody(cqlRow.getString(BODY_BLOB)); - if (cqlRow.getColumnDefinitions().contains(ATTRIBUTES_BLOB)) { - record.setAttributes(cqlRow.getString(ATTRIBUTES_BLOB)); - } - if (cqlRow.getColumnDefinitions().contains(METADATA_S)) { - record.setMetadata(cqlRow.getMap(METADATA_S, String.class, String.class)); - } - return record; - } - - /** - * Compute Similarity Search. - * - * @param query - * current query - * @return - * results - */ - public List> similaritySearch(AnnQuery query) { - StringBuilder cqlQuery = new StringBuilder("SELECT ") - .append(String.join(",", PARTITION_ID, ROW_ID, VECTOR, BODY_BLOB, ATTRIBUTES_BLOB, METADATA_S, "")) - .append(query.getMetric().getFunction()).append("(vector, :vector) as ").append(COLUMN_SIMILARITY) - .append(" FROM ").append(tableName); - - List conditions = new ArrayList<>(); - - // Add metadata conditions - if (query.getMetaData() != null && !query.getMetaData().isEmpty()) { - if (query.getMetaData().containsKey(PARTITION_ID)) { - conditions.add(PARTITION_ID + " = '" + query.getMetaData().get(PARTITION_ID) + "'"); - // remove partition id (if any - query.getMetaData().remove(PARTITION_ID); - } - query.getMetaData().forEach((key, value) -> - conditions.add(METADATA_S + "['" + key + "'] = '" + value + "'")); - } - - if (!conditions.isEmpty()) { - cqlQuery.append(" WHERE ").append(String.join(" AND ", conditions)); - } - - cqlQuery.append(" ORDER BY vector ANN OF :vector LIMIT :maxRecord"); - - log.debug("Query on table '{}' with vector size '{}' and max record='{}'", - yellow(tableName), - cyan("[" + query.getEmbeddings().size() + "]"), - cyan("" + (query.getRecordCount() > 0 ? query.getRecordCount() : DEFAULT_RECORD_COUNT))); - return cqlSession.execute(SimpleStatement.builder(cqlQuery.toString()) - .addNamedValue("vector", CqlVector.newInstance(query.getEmbeddings())) - .addNamedValue("maxRecord", query.getRecordCount() > 0 ? query.getRecordCount() : DEFAULT_RECORD_COUNT) - .build()) - .all().stream() // max record is small and pagination is not needed - .map(this::mapResult) - .filter(r -> r.getSimilarity() >= query.getThreshold()) - .collect(Collectors.toList()); - } - - /** - * Marshall a row as a result. - * - * @param cqlRow cql row - * @return resul - */ - private AnnResult mapResult(Row cqlRow) { - if (cqlRow == null) return null; - AnnResult res = new AnnResult<>(); - res.setEmbedded(mapRow(cqlRow)); - res.setSimilarity(cqlRow.getFloat(COLUMN_SIMILARITY)); - log.debug("Result similarity '{}' for embedded id='{}'", res.getSimilarity(), res.getEmbedded().getRowId()); - return res; - } - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredRecord.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredRecord.java deleted file mode 100644 index 852e7326..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredRecord.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.UUID; - -/** - * Default Constructor. - */ -@Data -@AllArgsConstructor -public class ClusteredRecord { - - /** Partition id. */ - String partitionId; - - /** Row identifier. */ - UUID rowId; - - /** Text body. */ - String body; - - /** - * Record for a clustered table. - */ - public ClusteredRecord() {} - -} \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredTable.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredTable.java deleted file mode 100644 index d5ee5bcc..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/ClusteredTable.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.datastax.oss.driver.api.core.cql.BatchStatement; -import com.datastax.oss.driver.api.core.cql.BatchStatementBuilder; -import com.datastax.oss.driver.api.core.cql.BatchType; -import com.datastax.oss.driver.api.core.cql.PreparedStatement; -import com.datastax.oss.driver.api.core.cql.Row; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; - -/** - * Table representing persistence for LangChain operations - */ -@Slf4j -public class ClusteredTable extends AbstractCassandraTable { - - /** - * Prepared statements - */ - private PreparedStatement findPartitionStatement; - private PreparedStatement deletePartitionStatement; - private PreparedStatement deleteRowStatement; - private PreparedStatement insertRowStatement; - private PreparedStatement findRowStatement; - - /** - * Constructor with the mandatory parameters. - * - * @param session - * cassandra Session - * @param keyspaceName - * keyspace name - * @param tableName - * table name - */ - public ClusteredTable(@NonNull CqlSession session, @NonNull String keyspaceName, @NonNull String tableName) { - super(session, keyspaceName, tableName); - } - - /** - * Prepare statements on first request. - */ - private synchronized void prepareStatements() { - if (findPartitionStatement == null) { - findPartitionStatement = cqlSession.prepare( - "select * from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? "); - deletePartitionStatement = cqlSession.prepare( - "delete from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? "); - findRowStatement = cqlSession.prepare( - "select * from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? " - + " and " + ROW_ID + " = ? "); - deleteRowStatement = cqlSession.prepare( - "delete from " + keyspaceName + "." + tableName - + " where " + PARTITION_ID + " = ? " - + " and " + ROW_ID + " = ? "); - insertRowStatement = cqlSession.prepare( - "insert into " + keyspaceName + "." + tableName - + " (" + PARTITION_ID + ", " + ROW_ID + ", " + BODY_BLOB + ") " - + " values (?, ?, ?)"); - } - } - - /** {@inheritDoc} */ - @Override - public void create() { - cqlSession.execute("CREATE TABLE IF NOT EXISTS " + keyspaceName + "." + tableName + " (" - + PARTITION_ID + " text, " - + ROW_ID + " timeuuid, " - + BODY_BLOB + " text, " - + "PRIMARY KEY ((" + PARTITION_ID + "), " + ROW_ID + ")) " - + "WITH CLUSTERING ORDER BY (" + ROW_ID + " DESC)"); - log.info("+ Table '{}' has been created (if needed).", tableName); - } - - /** {@inheritDoc} */ - @Override - public void put(@NonNull ClusteredRecord row) { - prepareStatements(); - cqlSession.execute(insertRowStatement.bind(row.getPartitionId(), row.getRowId(), row.getBody())); - } - - /** {@inheritDoc} */ - @Override - public ClusteredRecord mapRow(@NonNull Row row) { - return new ClusteredRecord( - row.getString(PARTITION_ID), - row.getUuid(ROW_ID), - row.getString(BODY_BLOB)); - } - - /** - * Find a partition. - * - * @param partitionDd - * partition id - * @return - * list of rows - */ - public List findPartition(@NonNull String partitionDd) { - prepareStatements(); - return cqlSession.execute(findPartitionStatement.bind(partitionDd)) - .all().stream() - .map(this::mapRow) - .collect(Collectors.toList()); - } - - /** - * Update the history in one go. - * - * @param rows - * current rows. - */ - public void upsertPartition(List rows) { - prepareStatements(); - if (rows != null && !rows.isEmpty()) { - BatchStatementBuilder batch = BatchStatement.builder(BatchType.LOGGED); - String currentPartitionId = null; - for (ClusteredRecord row : rows) { - if (currentPartitionId != null && !currentPartitionId.equals(row.getPartitionId())) { - log.warn("Not all rows are part of the same partition"); - } - currentPartitionId = row.getPartitionId(); - batch.addStatement(insertRowStatement.bind(row.getPartitionId(), row.getRowId(), row.getBody())); - } - cqlSession.execute(batch.build()); - } - } - - /** - * Find a row by its id. - * @param partition - * partition id - * @param rowId - * row id - * @return - * record if exists - */ - public Optional findById(String partition, UUID rowId) { - prepareStatements(); - return Optional.ofNullable(cqlSession - .execute(findRowStatement.bind(partition, rowId)) - .one()).map(this::mapRow); - } - - /** - * Delete Partition. - * - * @param partitionId - * delete the whole partition - */ - public void deletePartition(@NonNull String partitionId) { - prepareStatements(); - cqlSession.execute(deletePartitionStatement.bind(partitionId)); - } - - /** - * Delete one row. - * - * @param partitionId - * current session - * @param rowId - * message id - */ - public void delete(@NonNull String partitionId, @NonNull UUID rowId) { - prepareStatements(); - cqlSession.execute(deleteRowStatement.bind(partitionId, rowId)); - } - - /** - * Insert Row. - * - * @param partitionId - * partition id - * @param rowId - * rowId - * @param bodyBlob - * body - */ - public void insert(@NonNull String partitionId, @NonNull UUID rowId, @NonNull String bodyBlob) { - prepareStatements(); - cqlSession.execute(insertRowStatement.bind(partitionId,rowId, bodyBlob)); - } - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorRecord.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorRecord.java deleted file mode 100644 index 7fa61375..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorRecord.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.cql.SimpleStatement; -import com.datastax.oss.driver.api.core.data.CqlVector; -import com.datastax.oss.driver.api.core.uuid.Uuids; -import lombok.Data; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.ATTRIBUTES_BLOB; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.BODY_BLOB; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.METADATA_S; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.ROW_ID; -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.VECTOR; - -/** - * Record for the table metadata + vector. - */ -@Data -public class MetadataVectorRecord implements Serializable { - - /** - * Identifier of the row in Cassandra - */ - private String rowId; - - /** - * Store special attributes - */ - private String attributes; - - /** - * Body, contains the Text Fragment. - */ - private String body; - - /** - * Metadata (for metadata filtering) - */ - private Map metadata = new HashMap<>(); - - /** - * Embeddings - */ - private List vector; - - /** - * Default Constructor - */ - public MetadataVectorRecord() { - this(Uuids.timeBased().toString(), null); - } - - /** - * Create a record with a vector. - * - * @param vector current vector. - */ - public MetadataVectorRecord(List vector) { - this(Uuids.timeBased().toString(), vector); - } - - /** - * Create a record with a vector. - * @param rowId identifier for the row - * @param vector current vector. - */ - public MetadataVectorRecord(String rowId, List vector) { - this.rowId = rowId; - this.vector = vector; - } - - /** - * Build insert statement dynamically. - * - * @param keyspaceName - * keyspace name - * @param tableName - * table bane - * @return - * statement - */ - public SimpleStatement insertStatement(String keyspaceName, String tableName) { - if (rowId == null) throw new IllegalStateException("Row Id cannot be null"); - if (vector == null) throw new IllegalStateException("Vector cannot be null"); - return SimpleStatement.newInstance("INSERT INTO " + keyspaceName + "." + tableName + " (" - + ROW_ID + "," + VECTOR + "," + ATTRIBUTES_BLOB + "," + BODY_BLOB + "," + METADATA_S + ") VALUES (?,?,?,?,?)", - rowId, CqlVector.newInstance(vector), attributes, body, metadata); - } - -} \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorTable.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorTable.java deleted file mode 100644 index b31d5f39..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/MetadataVectorTable.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.datastax.oss.driver.api.core.cql.Row; -import com.datastax.oss.driver.api.core.cql.SimpleStatement; -import com.datastax.oss.driver.api.core.data.CqlVector; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -import static io.stargate.sdk.utils.AnsiUtils.cyan; -import static io.stargate.sdk.utils.AnsiUtils.yellow; - -/** - * Table representing persistence for Vector Stores support. As the name stated - * it holds both a vector and a metadata map. - * - * CREATE TABLE langchain4j.test_embedding_store ( - * row_id text PRIMARY KEY, - * attributes_blob text, - * body_blob text, - * metadata_s map<text, text>, - * vector vector<float, 11> - * ); - * - */ -@Slf4j -@Getter -public class MetadataVectorTable extends AbstractCassandraTable { - - /** - * Dimension of the vector in use - */ - private final int vectorDimension; - - /** - * Similarity Metric, Vector is indexed with this metric. - */ - private final CassandraSimilarityMetric similarityMetric; - - /** - * Constructor with mandatory parameters. - * - * @param session cassandra session - * @param keyspaceName keyspace name - * @param tableName table name - * @param vectorDimension vector dimension - */ - public MetadataVectorTable(CqlSession session, String keyspaceName, String tableName, int vectorDimension) { - this(session, keyspaceName, tableName, vectorDimension, CassandraSimilarityMetric.COSINE); - } - - /** - * Constructor with mandatory parameters. - * - * @param session cassandra session - * @param keyspaceName keyspace name - * @param tableName table name - * @param vectorDimension vector dimension - * @param metric similarity metric - */ - public MetadataVectorTable(CqlSession session, String keyspaceName, String tableName, int vectorDimension, CassandraSimilarityMetric metric) { - super(session, keyspaceName, tableName); - this.vectorDimension = vectorDimension; - this.similarityMetric = metric; - create(); - } - - /** - * Create table and indexes if not exist. - */ - public void create() { - // Create Table - String cqlQueryCreateTable = "CREATE TABLE IF NOT EXISTS " + tableName + " (" + - ROW_ID + " text, " + - ATTRIBUTES_BLOB + " text, " + - BODY_BLOB + " text, " + - METADATA_S + " map, " + - VECTOR + " vector, " + - "PRIMARY KEY (" + - ROW_ID + ")" + - ")"; - cqlSession.execute(cqlQueryCreateTable); - log.info("Table '{}' has been created (if needed).", tableName); - cqlSession.execute( - "CREATE CUSTOM INDEX IF NOT EXISTS idx_vector_" + tableName - + " ON " + tableName + " (" + VECTOR + ") " - + "USING 'org.apache.cassandra.index.sai.StorageAttachedIndex' " - + "WITH OPTIONS = { 'similarity_function': '" + similarityMetric.getOption() + "'};"); - log.info("Index '{}' has been created (if needed).", "idx_vector_" + tableName); - // Create Metadata Index - cqlSession.execute( - "CREATE CUSTOM INDEX IF NOT EXISTS eidx_metadata_s_" + tableName - + " ON " + tableName + " (ENTRIES(" + METADATA_S + ")) " - + "USING 'org.apache.cassandra.index.sai.StorageAttachedIndex';"); - log.info("Index '{}' has been created (if needed).", "eidx_metadata_s_" + tableName); - } - - /** {@inheritDoc} */ - public void put(MetadataVectorRecord row) { - cqlSession.execute(row.insertStatement(keyspaceName, tableName)); - } - - /** - * Marshall a row as a result. - * - * @param cqlRow cql row - * @return resul - */ - private AnnResult mapResult(Row cqlRow) { - if (cqlRow == null) return null; - AnnResult res = new AnnResult<>(); - res.setEmbedded(mapRow(cqlRow)); - res.setSimilarity(cqlRow.getFloat(COLUMN_SIMILARITY)); - log.debug("Result similarity '{}' for embedded id='{}'", res.getSimilarity(), res.getEmbedded().getRowId()); - return res; - } - - @Override - @SuppressWarnings("unchecked") - public MetadataVectorRecord mapRow(Row cqlRow) { - if (cqlRow == null) return null; - - MetadataVectorRecord record = new MetadataVectorRecord(); - record.setRowId(cqlRow.getString(ROW_ID)); - record.setBody(cqlRow.getString(BODY_BLOB)); - record.setVector(((CqlVector) Objects.requireNonNull(cqlRow.getObject(VECTOR))) - .stream().collect(Collectors.toList())); - if (cqlRow.getColumnDefinitions().contains(ATTRIBUTES_BLOB)) { - record.setAttributes(cqlRow.getString(ATTRIBUTES_BLOB)); - } - if (cqlRow.getColumnDefinitions().contains(METADATA_S)) { - record.setMetadata(cqlRow.getMap(METADATA_S, String.class, String.class)); - } - return record; - } - - /** - * Compute Similarity Search. - * - * @param query - * current query - * @return - * results - */ - public List> similaritySearch(AnnQuery query) { - StringBuilder cqlQuery = new StringBuilder("SELECT " + ROW_ID + "," - + VECTOR + "," + BODY_BLOB + "," - + ATTRIBUTES_BLOB + "," + METADATA_S + ","); - cqlQuery.append(query.getMetric().getFunction()).append("(vector, :vector) as ").append(COLUMN_SIMILARITY); - cqlQuery.append(" FROM ").append(tableName); - if (query.getMetaData() != null && !query.getMetaData().isEmpty()) { - cqlQuery.append(" WHERE "); - boolean first = true; - for (Map.Entry entry : query.getMetaData().entrySet()) { - if (!first) { - cqlQuery.append(" AND "); - } - cqlQuery.append(METADATA_S).append("['") - .append(entry.getKey()) - .append("'] = '") - .append(entry.getValue()).append("'"); - first = false; - } - } - cqlQuery.append(" ORDER BY vector ANN OF :vector "); - cqlQuery.append(" LIMIT :maxRecord"); - log.debug("Query on table '{}' with vector size '{}' and max record='{}'", - yellow(tableName), - cyan("[" + query.getEmbeddings().size() + "]"), - cyan("" + (query.getRecordCount() > 0 ? query.getRecordCount() : DEFAULT_RECORD_COUNT))); - return cqlSession.execute(SimpleStatement.builder(cqlQuery.toString()) - .addNamedValue("vector", CqlVector.newInstance(query.getEmbeddings())) - .addNamedValue("maxRecord", query.getRecordCount() > 0 ? query.getRecordCount() : DEFAULT_RECORD_COUNT) - .build()) - .all().stream() // max record is small and pagination is not needed - .map(this::mapResult) - .filter(r -> r.getSimilarity() >= query.getThreshold()) - .collect(Collectors.toList()); - } - - -} diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/package-info.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/package-info.java deleted file mode 100644 index 06df7093..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/cassio/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Client for Astra DB through Cassandra Query Language (CQL) reusing data models from CassIO, - */ -package com.dtsx.astra.sdk.cassio; \ No newline at end of file diff --git a/astra-db-client/src/main/java/com/dtsx/astra/sdk/package-info.java b/astra-db-client/src/main/java/com/dtsx/astra/sdk/package-info.java deleted file mode 100644 index 348566ae..00000000 --- a/astra-db-client/src/main/java/com/dtsx/astra/sdk/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Client for Astra DB through Rest Data API. - */ -package com.dtsx.astra.sdk; \ No newline at end of file diff --git a/astra-db-client/src/test/java/com/datastax/astra/AstraDBTestSupport.java b/astra-db-client/src/test/java/com/datastax/astra/AstraDBTestSupport.java new file mode 100644 index 00000000..0acc4db9 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/AstraDBTestSupport.java @@ -0,0 +1,69 @@ +package com.datastax.astra; + +import com.datastax.astra.db.AstraDBClient; +import com.datastax.astra.db.AstraDBDatabase; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import io.stargate.sdk.utils.Utils; +import lombok.extern.slf4j.Slf4j; + +import java.util.UUID; + +/** + * This class will help us generate database or select the environment + * we are targeting. + */ +@Slf4j +public class AstraDBTestSupport { + + /** + * Test Constants + */ + public static final String DATABASE_NAME = "astra_db_client"; + + public static AstraDBClient getAstraDBClient(AstraEnvironment env) { + switch (env) { + case DEV: + return new AstraDBClient(Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN_DEV") + .orElseThrow(() -> new IllegalStateException("Please define env variable 'ASTRA_DB_APPLICATION_TOKEN_DEV'"))); + case PROD: + return new AstraDBClient(Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN") + .orElseThrow(() -> new IllegalStateException("Please define env variable 'ASTRA_DB_APPLICATION_TOKEN'"))); + case TEST: + return new AstraDBClient(Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN_TEST") + .orElseThrow(() -> new IllegalStateException("Please define env variable 'ASTRA_DB_APPLICATION_TOKEN_TEST'"))); + default: + throw new IllegalArgumentException("Invalid Environment"); + } + } + + public static AstraDBDatabase createDatabase(AstraEnvironment env) { + CloudProviderType cloud; + String region; + switch (env) { + case DEV: + case TEST: + cloud = CloudProviderType.GCP; + region = "europe-west4"; + break; + case PROD: + cloud = CloudProviderType.GCP; + region = "us-east1"; + break; + default: + throw new IllegalArgumentException("Invalid Environment"); + } + return createDatabase(env, cloud, region); + } + + public static AstraDBDatabase createDatabase(AstraEnvironment env, CloudProviderType cloud, String region) { + log.info("Working in environment '{}'", env.name()); + AstraDBClient client = getAstraDBClient(env); + UUID databaseId = client.createDatabase(DATABASE_NAME, cloud, region); + log.info("Working with api Endpoint '{}'", ApiLocator.getApiJsonEndpoint(env, databaseId.toString(), region)); + return client.getDatabase(databaseId); + } + + +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/QuickStart.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/QuickStart.java new file mode 100644 index 00000000..a326bae6 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/QuickStart.java @@ -0,0 +1,57 @@ +package com.datastax.astra.documentation; + +import com.datastax.astra.db.AstraDBCollection; +import com.datastax.astra.db.AstraDBDatabase; +import io.stargate.sdk.data.client.model.Document; +import io.stargate.sdk.data.client.model.Filter; +import io.stargate.sdk.data.client.model.FindIterable; +import io.stargate.sdk.data.client.model.SimilarityMetric; +import io.stargate.sdk.data.client.model.collections.CreateCollectionOptions; + +import static io.stargate.sdk.data.client.model.Filters.eq; + +public class QuickStart { + public static void main(String[] args) { + + // Connect to db + AstraDBDatabase myDb = new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Create collection with vector search + AstraDBCollection demoCollection = myDb.createCollection("demo", CreateCollectionOptions + .builder() + .withVectorDimension(14) + .withVectorSimilarityMetric(SimilarityMetric.cosine) + .build()); + + // Insert vectors + demoCollection.insertOne(new Document() + .id("doc1") // generated if not set + .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) + .append("product_name", "HealthyFresh - Beef raw dog food") + .append("product_price", 12.99)); + demoCollection.insertOne(new Document() + .id("doc2") + .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) + .append("product_name", "HealthyFresh - Chicken raw dog food") + .append("product_price", 9.99)); + demoCollection.insertOne(new Document() + .id("doc3") + .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f})); + demoCollection.insertOne(new Document() + .id("doc4") + .vector(new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) + .append("product_name", "HealthyFresh - Chicken raw dog food") + .append("product_price", 9.99)); + + // Perform a similarity search + float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; + Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); + int maxRecord = 10; + long top = System.currentTimeMillis(); + FindIterable docs = demoCollection + .find(eq("product_price", 9.99)); + //TODO FindOptions + System.out.println(System.currentTimeMillis() - top); + + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/client/CreateDatabase.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/CreateDatabase.java new file mode 100644 index 00000000..13c62450 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/CreateDatabase.java @@ -0,0 +1,19 @@ +package com.datastax.astra.documentation.client; + +import com.datastax.astra.db.AstraDBClient; +import com.datastax.astra.devops.db.domain.CloudProviderType; + +import java.util.UUID; + +public class CreateDatabase { + public static void main(String[] args) { + AstraDBClient client = new AstraDBClient("TOKEN"); + + // Choose a cloud provider (GCP, AZURE, AWS) and a region + CloudProviderType cloudProvider = CloudProviderType.GCP; + String cloudRegion = "us-east1"; + + // Create a database + UUID newDbId = client.createDatabase("DATABASE_NAME", cloudProvider, cloudRegion); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/client/DropDatabase.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/DropDatabase.java new file mode 100644 index 00000000..c634e486 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/DropDatabase.java @@ -0,0 +1,17 @@ +package com.datastax.astra.documentation.client; + +import com.datastax.astra.db.AstraDBClient; + +import java.util.UUID; + +public class DropDatabase { + public static void main(String[] args) { + AstraDBClient client = new AstraDBClient("TOKEN"); + + // Delete an existing database + client.dropDatabase(""); + + // Delete an existing database by ID + client.dropDatabase(UUID.fromString("")); + } +} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindDatabase.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/FindDatabase.java similarity index 58% rename from astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindDatabase.java rename to astra-db-client/src/test/java/com/datastax/astra/documentation/client/FindDatabase.java index 30892663..2b9f8fc1 100644 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindDatabase.java +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/FindDatabase.java @@ -1,17 +1,18 @@ -package com.dtsx.astra.sdk.documentation; +package com.datastax.astra.documentation.client; + +import com.datastax.astra.db.AstraDBClient; +import com.datastax.astra.devops.db.domain.Database; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.db.domain.Database; import java.util.Optional; import java.util.UUID; import java.util.stream.Stream; public class FindDatabase { public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); + AstraDBClient client = new AstraDBClient("TOKEN"); // Check if a database exists - boolean exists = client.isDatabaseExists(""); + boolean exists = client.databaseExists(""); // Find a database by name (names may not be unique) Stream dbStream = client.getDatabaseInformations(""); @@ -19,6 +20,6 @@ public static void main(String[] args) { // Find a database by ID Optional dbById = client - .getDatabaseInformations(UUID.fromString("")); + .getDatabaseInformations(UUID.fromString("")); } } diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/client/InitAstraDBClient.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/InitAstraDBClient.java new file mode 100644 index 00000000..be825cc3 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/client/InitAstraDBClient.java @@ -0,0 +1,23 @@ +package com.datastax.astra.documentation.client; + +import com.datastax.astra.db.AstraDBClient; +import com.datastax.astra.db.AstraDBOptions; + +public class InitAstraDBClient { + public static void main(String[] args) { + + // Default Initialization + AstraDBClient client = new AstraDBClient("TOKEN"); + + // Specialize with some extra options + AstraDBClient client2 = new AstraDBClient("TOKEN", AstraDBOptions.builder() + .connectionRequestTimeoutInSeconds(10) + .responseTimeoutInSeconds(10) + // more options + .build()); + + // You can omit the token if you defined the `ASTRA_DB_APPLICATION_TOKEN` + // environment variable or if you are using the Astra CLI. + AstraDBClient defaultClient = new AstraDBClient(); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/collection/ClearCollection.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/collection/ClearCollection.java new file mode 100644 index 00000000..a01606f0 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/collection/ClearCollection.java @@ -0,0 +1,18 @@ +package com.datastax.astra.documentation.collection; + +import com.datastax.astra.db.AstraDBCollection; +import com.datastax.astra.db.AstraDBDatabase; +import io.stargate.sdk.data.client.model.Document; + +public class ClearCollection { + public static void main(String[] args) { + // Connect to running dn + AstraDBDatabase db = new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Accessing the collection + AstraDBCollection collection = db.getCollection("collection_simple"); + + // Delete all rows from an existing collection + collection.deleteAll(); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateCollection.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateCollection.java new file mode 100644 index 00000000..320cbfbb --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateCollection.java @@ -0,0 +1,39 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBCollection; +import com.datastax.astra.db.AstraDBDatabase; +import io.stargate.sdk.data.client.exception.DataApiException; +import io.stargate.sdk.data.client.model.Document; +import io.stargate.sdk.data.client.model.SimilarityMetric; +import io.stargate.sdk.data.client.model.collections.CreateCollectionOptions; + +public class CreateCollection { + public static void main(String[] args) { + AstraDBDatabase db = + new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Create a non-vector collection + AstraDBCollection col = + db.createCollection("col"); + + // Create a vector collection + AstraDBCollection col_v = db.createCollection("col_v", CreateCollectionOptions + .builder() + .withVectorDimension(1536) + .withVectorSimilarityMetric(SimilarityMetric.euclidean) + .build()); + + // Create a collection with indexing (deny) + AstraDBCollection col_i = db.createCollection("col_i", CreateCollectionOptions + .builder() + .withIndexingDeny("blob") + .build()); + + // Collection names should use snake case ([a-zA-Z][a-zA-Z0-9_]*) + try { + db.createCollection("invalid.name"); + } catch(DataApiException e) { + // invalid.name is not valid + } + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateNamespace.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateNamespace.java new file mode 100644 index 00000000..f7f9d915 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/CreateNamespace.java @@ -0,0 +1,13 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBDatabase; + +public class CreateNamespace { + public static void main(String[] args) { + // Default initialization + AstraDBDatabase db = new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Create a new namespace + db.createNamespace(""); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropCollection.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropCollection.java new file mode 100644 index 00000000..6e5a1843 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropCollection.java @@ -0,0 +1,12 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBDatabase; + +public class DropCollection { + public static void main(String[] args) { + AstraDBDatabase db = new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Delete an existing collection + db.dropCollection("collection_vector2"); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropNamespace.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropNamespace.java new file mode 100644 index 00000000..ec96a872 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/DropNamespace.java @@ -0,0 +1,14 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBDatabase; + +public class DropNamespace { + + public static void main(String[] args) { + // Default initialization + AstraDBDatabase db = new AstraDBDatabase("API_ENDPOINT", "TOKEN"); + + // Drop a Namespace + db.dropNamespace(""); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/FindCollection.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/FindCollection.java new file mode 100644 index 00000000..26f3856f --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/FindCollection.java @@ -0,0 +1,21 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBDatabase; +import io.stargate.sdk.data.client.DataApiCollection; +import io.stargate.sdk.data.client.model.Document; +import io.stargate.sdk.data.client.model.collections.CreateCollectionOptions; + +public class FindCollection { + public static void main(String[] args) { + AstraDBDatabase db = new AstraDBDatabase("TOKEN", "API_ENDPOINT"); + + // Find a collection + DataApiCollection collection = db.getCollection("collection_vector1"); + + // Gather collection information + CreateCollectionOptions options = collection.getOptions(); + + // Check if a collection exists + boolean collectionExists = db.getCollection("collection_vector2").exists(); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/documentation/db/InitAstraDBDatabase.java b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/InitAstraDBDatabase.java new file mode 100644 index 00000000..fa57f2e7 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/documentation/db/InitAstraDBDatabase.java @@ -0,0 +1,26 @@ +package com.datastax.astra.documentation.db; + +import com.datastax.astra.db.AstraDBDatabase; +import com.datastax.astra.db.AstraDBOptions; + +public class InitAstraDBDatabase { + public static void main(String[] args) { + // Default initialization + AstraDBDatabase db = new AstraDBDatabase("TOKEN", "API_ENDPOINT"); + + // 'Options' allows fined-grained configuration. + AstraDBOptions options = AstraDBOptions.builder() + .connectionRequestTimeoutInSeconds(10) + .connectionRequestTimeoutInSeconds(10) + .build(); + AstraDBDatabase db2 = new AstraDBDatabase("TOKEN", "API_ENDPOINT", options); + + // Initialize with a non-default namespace. + AstraDBDatabase db3 = + new AstraDBDatabase("TOKEN", "API_ENDPOINT", "NAMESPACE"); + + // non-default namespace + options + AstraDBDatabase db4 = + new AstraDBDatabase("TOKEN", "API_ENDPOINT", "NAMESPACE", options); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/integration/AstraCollectionITTest.java b/astra-db-client/src/test/java/com/datastax/astra/integration/AstraCollectionITTest.java new file mode 100644 index 00000000..7b58c847 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/integration/AstraCollectionITTest.java @@ -0,0 +1,15 @@ +package com.datastax.astra.integration; + +import com.datastax.astra.devops.utils.AstraEnvironment; +import io.stargate.sdk.data.client.DataApiNamespace; +import io.stargate.sdk.data.test.integration.AbstractCollectionITTest; + +import static com.datastax.astra.AstraDBTestSupport.createDatabase; + +public class AstraCollectionITTest extends AbstractCollectionITTest { + + @Override + public DataApiNamespace initNamespace() { + return createDatabase(AstraEnvironment.PROD); + } +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/integration/AstraNamespaceITTest.java b/astra-db-client/src/test/java/com/datastax/astra/integration/AstraNamespaceITTest.java new file mode 100644 index 00000000..7c2b265b --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/integration/AstraNamespaceITTest.java @@ -0,0 +1,19 @@ +package com.datastax.astra.integration; + +import com.datastax.astra.devops.utils.AstraEnvironment; +import io.stargate.sdk.data.client.DataApiNamespace; +import io.stargate.sdk.data.test.integration.AbstractNamespaceITTest; + +import static com.datastax.astra.AstraDBTestSupport.createDatabase; + +/** + * Run the namespace test Suite against Astra. + */ +public class AstraNamespaceITTest extends AbstractNamespaceITTest { + + @Override + public DataApiNamespace initNamespace() { + return createDatabase(AstraEnvironment.PROD); + } + +} diff --git a/astra-db-client/src/test/java/com/datastax/astra/unit/AstraDBEndpointTest.java b/astra-db-client/src/test/java/com/datastax/astra/unit/AstraDBEndpointTest.java new file mode 100644 index 00000000..b0534574 --- /dev/null +++ b/astra-db-client/src/test/java/com/datastax/astra/unit/AstraDBEndpointTest.java @@ -0,0 +1,40 @@ +package com.datastax.astra.unit; + +import com.datastax.astra.db.AstraDBEndpoint; +import com.datastax.astra.devops.utils.AstraEnvironment; +import org.junit.jupiter.api.Test; + +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Work with the AstraDBEndpoint Object. + */ +public class AstraDBEndpointTest { + + @Test + public void shouldParseApiEndpoint() { + String url1 = "https://4391daae-016c-49e3-8d0a-b4633a86082c-us-east1.apps.astra.datastax.com"; + AstraDBEndpoint example1 = AstraDBEndpoint.parse(url1); + assertThat(example1).isNotNull(); + assertThat(example1.getEnv()).isEqualTo(AstraEnvironment.PROD); + assertThat(example1.getDatabaseId()).isEqualTo(UUID.fromString("4391daae-016c-49e3-8d0a-b4633a86082c")); + assertThat(example1.getDatabaseRegion()).isEqualTo("us-east1"); + assertThat(example1.getOriginalEndPoint()).isEqualTo(url1); + + AstraDBEndpoint example2 = AstraDBEndpoint + .parse("https://4391daae-016c-49e3-8d0a-b4633a86082c-us-west-2.apps.astra.datastax.com"); + assertThat(example2).isNotNull(); + assertThat(example2.getEnv()).isEqualTo(AstraEnvironment.PROD); + assertThat(example2.getDatabaseId()).isEqualTo(UUID.fromString("4391daae-016c-49e3-8d0a-b4633a86082c")); + assertThat(example2.getDatabaseRegion()).isEqualTo("us-west-2"); + + AstraDBEndpoint example3 = AstraDBEndpoint + .parse("https://25cf3382-d3d2-45d3-86af-b0b498c79cd7-europe-west4.apps.astra-dev.datastax.com"); + assertThat(example3).isNotNull(); + assertThat(example3.getEnv()).isEqualTo(AstraEnvironment.DEV); + assertThat(example3.getDatabaseId()).isEqualTo(UUID.fromString("25cf3382-d3d2-45d3-86af-b0b498c79cd7")); + assertThat(example3.getDatabaseRegion()).isEqualTo("europe-west4"); + } +} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBReworkTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBReworkTest.java deleted file mode 100644 index fab719f9..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBReworkTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dtsx.astra.sdk; - -import org.junit.jupiter.api.Test; - -public class AstraDBReworkTest { - - @Test - public void testReword() { - AstraDBAdmin client = AstraDBClients.create("token"); - AstraDB db = client.getDatabase("sample_database"); - - AstraDB db1 = new AstraDB("apiEnpoint", "token"); - AstraDBCollection collection = db.getCollection("sample_collection"); - - - //collection.find().all().forEach(System.out::println); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBTestSuiteIT.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBTestSuiteIT.java deleted file mode 100644 index 37cd9208..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/AstraDBTestSuiteIT.java +++ /dev/null @@ -1,1536 +0,0 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.CollectionDefinition; -import io.stargate.sdk.data.domain.DocumentMutationResult; -import io.stargate.sdk.data.domain.DocumentMutationStatus; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.SimilarityMetric; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import io.stargate.sdk.data.domain.query.UpdateQuery; -import io.stargate.sdk.data.exception.DataApiDocumentAlreadyExistException; -import io.stargate.sdk.data.exception.DataApiException; -import io.stargate.sdk.data.exception.DataApiInvalidArgumentException; -import io.stargate.sdk.data.exception.DataApiNamespaceNotFoundException; -import io.stargate.sdk.utils.Utils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static io.stargate.sdk.http.domain.FilterOperator.EQUALS_TO; -import static io.stargate.sdk.http.domain.FilterOperator.EXISTS; -import static io.stargate.sdk.http.domain.FilterOperator.GREATER_THAN; -import static io.stargate.sdk.http.domain.FilterOperator.GREATER_THAN_OR_EQUALS_TO; -import static io.stargate.sdk.http.domain.FilterOperator.LESS_THAN; - -/** - * Once upon a time in the vector database wonderland. - */ -@Slf4j -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class AstraDBTestSuiteIT { - - /** - * Test Constants - */ - public static final String TEST_DBNAME = "astra_db_client"; - static final String TEST_COLLECTION_NAME = "collection_simple"; - static final String TEST_COLLECTION_VECTOR = "collection_vector"; - static final String TEST_COLLECTION_DENY = "collection_deny"; - static final String TEST_COLLECTION_ALLOW = "collection_allow"; - - /** - * Test Environment - */ - static AstraEnvironment targetEnvironment = AstraEnvironment.PROD; - static CloudProviderType targetCloud = AstraDBAdmin.FREE_TIER_CLOUD; - static String targetRegion = AstraDBAdmin.FREE_TIER_CLOUD_REGION; - static String astraToken; - - /** - * Shared working objects - */ - static AstraDBAdmin astraDbAdmin; - static AstraDB astraDb; - static UUID databaseId; - static AstraDBCollection collectionSimple; - static AstraDBCollection collectionDeny; - static AstraDBCollection collectionAllow; - static AstraDBCollection collectionVector; - - /** - * Bean to be used for the test suite - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - static class Product { - @JsonProperty("product_name") - private String name; - @JsonProperty("product_price") - private Double price; - } - - // SELECT WHERE TO RUN TESTS - static boolean DEV = false; - - // ------------------------------------- - // ------- INITIALIZATION -------------- - // ------------------------------------- - - @BeforeAll - @DisplayName("00. Connect to Astra") - public static void setupAndConnectToAstra() { - if (DEV) { - targetEnvironment = AstraEnvironment.DEV; - astraToken = "AstraCS:ZiWfNzYJtUGszRuGyyTjFIXU:2c5a21a4623c6ee688d4bca4b8e55a269aa3ee864fcd16b26b7f9a82ca57b999"; - targetCloud = CloudProviderType.GCP; - targetRegion = "europe-west4"; - } else { - targetEnvironment = AstraEnvironment.PROD; - astraToken = Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN").get(); - targetCloud = CloudProviderType.GCP; - targetRegion = "us-east1"; - } - // When - astraDbAdmin = new AstraDBAdmin(astraToken, targetEnvironment); - // When - Assertions.assertNotNull(astraDbAdmin.getToken()); - } - - @Test - @Order(1) - public void shouldCreateDatabase() { - // Given - Assertions.assertNotNull(targetCloud); - Assertions.assertNotNull(targetRegion); - Assertions.assertNotNull(astraDbAdmin.getDevopsApiClient()); - // When - databaseId = astraDbAdmin.createDatabase(TEST_DBNAME, targetCloud, targetRegion); - // Then - Assertions.assertNotNull(databaseId); - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(TEST_DBNAME)); - log.info("Api Endpoint {}", ApiLocator.getApiJsonEndpoint(targetEnvironment, databaseId.toString(), targetRegion)); - } - - // ------------------------------------- - // ----------- CONNECTION -------------- - // ------------------------------------- - - @Test - @Order(2) - public void shouldConnectToDatabase() { - if (databaseId == null) shouldCreateDatabase(); - // Given - Assertions.assertNotNull(databaseId); - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(TEST_DBNAME)); - Assertions.assertNotNull(astraDbAdmin.getDataApiClient(databaseId)); - // When - astraDb = astraDbAdmin.getDatabase(databaseId); - Assertions.assertNotNull(astraDb.getNamespaceClient()); - Assertions.assertNotNull(astraDb); - // When - astraDb = astraDbAdmin.getDatabase(TEST_DBNAME); - Assertions.assertNotNull(astraDb); - } - - @Test - @Order(3) - public void shouldConnectToDatabaseWithEndpoint() { - if (databaseId == null) shouldCreateDatabase(); - // Given - Assertions.assertNotNull(astraDb.getApiEndpoint()); - Assertions.assertNotNull(astraDbAdmin.getToken()); - Assertions.assertNotNull(astraDbAdmin.getDataApiClient(TEST_DBNAME)); - // When - AstraDB astraDb2 = new AstraDB(astraDbAdmin.getToken(), astraDb.getApiEndpoint()); - // Then - Assertions.assertNotNull(astraDb2); - Assertions.assertNotNull(astraDb2.findAllCollections()); - } - - @Test - @Order(4) - public void shouldConnectToDatabaseWithEndpointAndKeyspace() { - // When initializing with a keyspace - AstraDB astraDb3 = new AstraDB(astraDbAdmin.getToken(), astraDb.getApiEndpoint(), AstraDBAdmin.DEFAULT_KEYSPACE); - // Then - Assertions.assertNotNull(astraDb3); - Assertions.assertNotNull(astraDb3.findAllCollections()); - // When initializing with an INVALID keyspace - Assertions.assertThrows(DataApiNamespaceNotFoundException.class, () -> new AstraDB(astraDbAdmin.getToken(), astraDb.getApiEndpoint(), "invalid_keyspace")); - } - - // ------------------------------------------ - // ----------- WORKING WITH DB -------------- - // ------------------------------------------ - - @Test - @Order(5) - public void shouldFindDatabaseById() { - if (databaseId == null) shouldCreateDatabase(); - // When - Optional opt = astraDbAdmin.getDatabaseInformations(databaseId); - // Then - Assertions.assertNotNull(opt); - Assertions.assertTrue(opt.isPresent()); - Assertions.assertEquals(TEST_DBNAME, opt.get().getInfo().getName()); - } - - @Test - @Order(6) - public void shouldFindDatabaseByName() { - if (databaseId == null) shouldCreateDatabase(); - // Given - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(TEST_DBNAME)); - // When - Stream dbs = astraDbAdmin.getDatabaseInformations(TEST_DBNAME); - // Then - Assertions.assertNotNull(dbs); - dbs.findFirst().ifPresent(db -> { - Assertions.assertEquals(TEST_DBNAME, db.getInfo().getName()); - Assertions.assertEquals(databaseId.toString(), db.getId()); - }); - } - - @Test - @Order(7) - @DisplayName("04. Find all databases") - public void shouldFindAllDatabases() { - // Given - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(TEST_DBNAME)); - // When - Assertions.assertTrue(astraDbAdmin - .listDatabases() - .anyMatch(db -> db.getInfo().getName().equals(TEST_DBNAME))); - } - - @Test - @Order(8) - @Disabled("slow") - public void shouldDeleteDatabaseByName() throws InterruptedException { - String dbName = "test_delete_db_by_name"; - // Given - Assertions.assertFalse(astraDbAdmin.isDatabaseExists(dbName)); - // When - UUID dbId = astraDbAdmin.createDatabase(dbName, targetCloud, targetRegion); - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(dbName)); - // When - boolean isDeleted = astraDbAdmin.dropDatabase(dbName); - // Then - Thread.sleep(5000); - Assertions.assertTrue(isDeleted); - } - - @Test - @Order(8) - @Disabled("slow") - public void shouldDeleteDatabaseById() throws InterruptedException { - String dbName = "test_delete_db_by_id"; - // Given - Assertions.assertFalse(astraDbAdmin.isDatabaseExists(dbName)); - // When - UUID tmpDbId = astraDbAdmin.createDatabase(dbName, targetCloud, targetRegion); - Assertions.assertTrue(astraDbAdmin.isDatabaseExists(dbName)); - boolean isDeleted = astraDbAdmin.dropDatabase(tmpDbId); - Thread.sleep(5000); - Assertions.assertTrue(isDeleted); - } - - // ------------------------------------ - // --------- Collections -------------- - // ------------------------------------ - - @Test - @Order(6) - @DisplayName("06. Create a Collection (no vector)") - public void shouldCreateCollectionSimple() { - if (astraDb == null) shouldConnectToDatabase(); - // Given - astraDb.deleteCollection(TEST_COLLECTION_NAME); - Assertions.assertFalse(astraDb.isCollectionExists(TEST_COLLECTION_NAME)); - // When - collectionSimple = astraDb.createCollection(TEST_COLLECTION_NAME); - // Then - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_NAME)); - } - - @Test - @Order(7) - @DisplayName("07. Create Collections (with vector)") - public void shouldCreateCollectionVector() { - if (astraDb == null) shouldConnectToDatabase(); - - // Given - astraDb.deleteCollection(TEST_COLLECTION_VECTOR); - Assertions.assertFalse(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - // When - astraDb.createCollection(TEST_COLLECTION_VECTOR, 14); - // Then - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - - // Given - astraDb.deleteCollection(TEST_COLLECTION_VECTOR); - Assertions.assertFalse(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - collectionVector = astraDb.createCollection(CollectionDefinition.builder() - .name(TEST_COLLECTION_VECTOR) - .vector(14, SimilarityMetric.cosine) - .build()); - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - } - - @Test - @Order(7) - @DisplayName("07. Create Collections (with vector)") - public void shouldCreateCollectionWithIndexingOptions() { - - // Given - if (astraDb == null) shouldConnectToDatabase(); - - astraDb.deleteCollection(TEST_COLLECTION_VECTOR); - Assertions.assertFalse(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - - // Allow and Deny are mutually exclusive - Assertions.assertThrows(IllegalStateException.class, () -> collectionVector = astraDb.createCollection(CollectionDefinition.builder() - .name(TEST_COLLECTION_VECTOR) - .vector(14, SimilarityMetric.cosine) - .indexingDeny("blob_body") - .indexingAllow("property1") - .build())); - } - - - - @Test - @Order(8) - @DisplayName("08. Find a single collection") - public void shouldFindCollection() { - if (astraDb == null) shouldConnectToDatabase(); - - // Find a collection (1) - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_VECTOR)); - Optional def = astraDb.findCollectionByName(TEST_COLLECTION_VECTOR); - Assertions.assertTrue(def.isPresent()); - Assertions.assertEquals(14, def.get().getOptions().getVector().getDimension()); - - // Find a collection (2) - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_NAME)); - Assertions.assertTrue(astraDb.findCollectionByName(TEST_COLLECTION_NAME).isPresent()); - - // Find a collection (3) - Assertions.assertFalse(astraDb.isCollectionExists("invalid")); - Assertions.assertFalse(astraDb.findCollectionByName("invalid").isPresent()); - } - - @Test - @Order(9) - @DisplayName("09. Find all collections") - public void shouldListCollection() { - if (astraDb == null) shouldConnectToDatabase(); - - List collections = astraDb - .findAllCollections() - .map(CollectionDefinition::getName) - .collect(Collectors.toList()); - Assertions.assertTrue(collections.contains(TEST_COLLECTION_NAME)); - Assertions.assertTrue(collections.contains(TEST_COLLECTION_VECTOR)); - } - - @Test - @Order(10) - @DisplayName("10. Delete all documents in a collection") - @Disabled("Product Issues") - public void shouldDeleteACollection() { - if (astraDb == null) shouldConnectToDatabase(); - - String deleted_collection = "deleted_collection"; - astraDb.createCollection(deleted_collection); - Assertions.assertTrue(astraDb.isCollectionExists(deleted_collection)); - - astraDb.deleteCollection(deleted_collection); - Assertions.assertFalse(astraDb.isCollectionExists(deleted_collection)); - } - - @Test - @Order(11) - @DisplayName("11. Delete a collection") - public void shouldClearACollection() { - // Given - if (collectionSimple == null) shouldCreateCollectionSimple(); - Assertions.assertTrue(astraDb.isCollectionExists(TEST_COLLECTION_NAME)); - collectionSimple.deleteAll(); - collectionSimple.insertOne(new JsonDocument().id("1")); - Assertions.assertEquals(1, collectionSimple.countDocuments()); - // When - collectionSimple.deleteAll(); - // Then - Assertions.assertEquals(0, collectionSimple.countDocuments()); - } - - // ------------------------------------ - // --------- Documents -------------- - // ------------------------------------ - - // ======== INSERT ========= - - @Test - @Order(12) - @DisplayName("12. InsertOne with json String") - public void shouldInsertOneJson() { - initializeCollectionVector(); - - String json = "{" + - "\"$vector\": [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3], " + - "\"product_name\": \"HealthyFresh - Chicken raw dog food\", " + - "\"product_price\": 9.99" + - "}"; - JsonDocumentMutationResult dmr = collectionVector.insertOne(json); - Assertions.assertNotNull(dmr.getDocument().getId()); - Assertions.assertEquals(9.99d, dmr.getDocument().getDouble("product_price")); - Assertions.assertEquals(DocumentMutationStatus.CREATED, dmr.getStatus()); - - // Insert again Asynchronously - collectionVector.insertOneAsync(json).thenAccept(dmr2 -> { - Assertions.assertNotNull(dmr2.getDocument().getId()); - Assertions.assertEquals(9.99d, dmr2.getDocument().getDouble("product_price")); - Assertions.assertEquals(DocumentMutationStatus.CREATED, dmr2.getStatus()); - }); - } - - @Test - @Order(13) - @DisplayName("13. InsertOne with a JsonDocument") - public void shouldInsertOneJsonDocument() { - initializeCollectionSimple(); - - // Working document - JsonDocument doc = new JsonDocument().id("1").put("a", "a").put("b", true); - - // Insert ONE - JsonDocumentMutationResult res = collectionSimple.insertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - Assertions.assertEquals("a", res.getDocument().getString("a")); - Assertions.assertEquals(true, res.getDocument().getBoolean("b")); - - // Insert ONE => ERROR - Assertions.assertThrows(DataApiDocumentAlreadyExistException.class, () -> collectionSimple.insertOne(doc)); - - // Insert ONE => Asynchronously - JsonDocument doc2 = new JsonDocument().id("2").put("a", "a").put("b", true); - collectionSimple.insertOneASync(doc2).thenAccept(res2 -> { - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, res2.getStatus()); - Assertions.assertEquals("2", res2.getDocument().getId()); - }); - } - - @Test - @Order(14) - @DisplayName("14. InsertOne with a Java Bean") - public void shouldInsertOneDocument() { - initializeCollectionSimple(); - - // Working document - Document doc = new Document().id("p1").data(new Product("p1", 10.1)); - - // Insert ONE - DocumentMutationResult res = collectionSimple.insertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("p1", res.getDocument().getId()); - Assertions.assertEquals("p1", res.getDocument().getData().getName()); - - // Insert ONE => ERROR - Assertions.assertThrows(DataApiDocumentAlreadyExistException.class, () -> collectionSimple.insertOne(doc)); - - // Insert Async - Document doc2 = new Document().id("p2").data(new Product("p2", 10.1)); - collectionSimple.insertOneASync(doc2).thenAccept(res2 -> { - Assertions.assertEquals(DocumentMutationStatus.CREATED, res2.getStatus()); - Assertions.assertEquals("p2", res2.getDocument().getId()); - }); - - } - - @Test - @Order(15) - @DisplayName("15. Insert Doc and find By Id") - public void shouldInsertAndRetrieve() { - initializeCollectionSimple(); - - // Working document - Document doc = new Document().id("p1").data(new Product("p1", 10.1)); - - // Insert ONE - DocumentMutationResult res = collectionSimple.insertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("p1", res.getDocument().getId()); - Assertions.assertEquals("p1", res.getDocument().getData().getName()); - - // Find the retrieved object - Optional> optRes = collectionSimple.findById("p1", Product.class); - if (optRes.isPresent()) { - DocumentResult res2 = optRes.get(); - Assertions.assertEquals("p1", res2.getId()); - Assertions.assertEquals("p1", res2.getData().getName()); - } else { - Assertions.fail("Should have found a document"); - } - } - - @Test - @Order(16) - @DisplayName("16. Insert a JsonDocument with multiple Manner") - public void shouldInsertADocument() { - initializeCollectionVector(); - - // You must delete any existing rows with the same IDs as the - // rows you want to insert - collectionVector.deleteAll(); - - // Insert rows defined by key/value - collectionVector.insertOne( - new JsonDocument() - .id("doc1") // uuid is generated if not explicitely set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99)); - - // Insert rows defined as a JSON String - collectionVector.insertOne( - new JsonDocument() - .data( - "{" + - "\"_id\": \"doc2\", " + - "\"$vector\": [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], " + - "\"product_name\": \"HealthyFresh - Chicken raw dog food\", " + - "\"product_price\": 9.99" + - "}")); - - // Insert rows defined as a Map - collectionVector.insertOne( - new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food"))); - - // Insert rows defined as a combination of key/value, JSON, and Map - collectionVector.insertOne( - new JsonDocument() - .id("doc4") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data("{" + - "\"product_name\": \"HealthyFresh - Chicken raw dog food\", " + - "\"product_price\": 8.99" + - "}")); - - // If you do not provide an ID, they are generated automatically - collectionVector.insertOne(new JsonDocument().put("demo", 1)); - Assertions.assertEquals(5, collectionVector.countDocuments()); - } - - @Test - @Order(17) - @DisplayName("17. Insert document with a lot of properties and retrieve them") - public void shouldInsertOneComplexDocument() { - initializeCollectionSimple(); - Assertions.assertEquals(0, collectionSimple.countDocuments()); - - // Adding Many with a Json document with a lof properties - collectionSimple.insertOne( - new JsonDocument().id("1") - .put("metadata_instant", Instant.now()) - .put("metadata_date", new Date()) - .put("metadata_calendar", Calendar.getInstance()) - .put("metadata_int", 1) - .put("metadata_long", 12321323L) - .put("metadata_double", 1213.343243d) - .put("metadata_float", 1.1232434543f) - .put("metadata_string", "hello") - .put("metadata_short", Short.valueOf("1")) - .put("metadata_string_array", new String[]{"a", "b", "c"}) - .put("metadata_int_array", new Integer[]{1, 2, 3}) - .put("metadata_long_array", new Long[]{1L, 2L, 3L}) - .put("metadata_double_array", new Double[]{1d, 2d, 3d}) - .put("metadata_float_array", new Float[]{1f, 2f, 3f}) - .put("metadata_short_array", new Short[]{1, 2, 3}) - .put("metadata_boolean", true) - .put("metadata_boolean_array", new Boolean[]{true, false, true}) - .put("metadata_uuid", UUID.randomUUID()) - .put("metadata_uuid_array", new UUID[]{UUID.randomUUID(), UUID.randomUUID()}) - .put("metadata_map", Map.of("key1", "value1", "key2", "value2")) - .put("metadata_list", List.of("value1", "value2")) - .put("metadata_byte", Byte.valueOf("1")) - .put("metadata_character", 'c') - .put("metadata_enum", AstraDBAdmin.FREE_TIER_CLOUD) - .put("metadata_enum_array", new CloudProviderType[]{AstraDBAdmin.FREE_TIER_CLOUD, CloudProviderType.AWS}) - .put("metadata_object", new Product("name", 1d))); - - // Search By id - JsonDocumentResult res = collectionSimple.findById("1") - .orElseThrow(() -> new IllegalStateException("Should have found a document" )); - - // Accessing result - Instant i = res.getInstant("metadata_instant"); - Assertions.assertNotNull(i); - Date d = res.getDate("metadata_date"); - Assertions.assertNotNull(d); - Calendar c = res.getCalendar("metadata_calendar"); - Assertions.assertNotNull(c); - Integer integer = res.getInteger("metadata_int"); - Assertions.assertNotNull(integer); - Long l = res.getLong("metadata_long"); - Assertions.assertNotNull(l); - Double db = res.getDouble("metadata_double"); - Assertions.assertNotNull(db); - Float f = res.getFloat("metadata_float"); - Assertions.assertNotNull(f); - String s = res.getString("metadata_string"); - Assertions.assertNotNull(s); - Short sh = res.getShort("metadata_short"); - Assertions.assertNotNull(sh); - Boolean b = res.getBoolean("metadata_boolean"); - Assertions.assertNotNull(b); - UUID u = res.getUUID("metadata_uuid"); - Assertions.assertNotNull(u); - Byte by = res.getByte("metadata_byte"); - Assertions.assertNotNull(by); - Character ch = res.getCharacter("metadata_character"); - Assertions.assertNotNull(ch); - Product p = res.getObject("metadata_object", Product.class); - Assertions.assertNotNull(p); - List l2 = res.getList("metadata_list", String.class); - Assertions.assertNotNull(l2); - Boolean[] ba = res.getArray("metadata_boolean_array", Boolean.class); - Assertions.assertNotNull(ba); - } - - // ======== UPSERT ========= - - @Test - @Order(18) - @DisplayName("18. UpsertOne with a jsonDocument") - public void shouldUpsertOneWithJson() - throws ExecutionException, InterruptedException { - initializeCollectionSimple(); - String json = "{" + - "\"_id\": \"doc1\", " + - "\"$vector\": [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3], " + - "\"product_name\": \"HealthyFresh - Chicken raw dog food\", " + - "\"product_price\": 9.99" + - "}"; - - // First insertion will give you a CREATED status - JsonDocumentMutationResult res = collectionSimple.upsertOne(json); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("doc1", res.getDocument().getId()); - - // Second will give you with no UNCHANGED (Async_ - res = collectionSimple.upsertOneASync(json).get(); - Assertions.assertEquals(DocumentMutationStatus.UNCHANGED, res.getStatus()); - - // Third will give you with a CHANGED - String jsonUdated = json.replaceAll("9.99", "10.99"); - res = collectionSimple.upsertOne(jsonUdated); - Assertions.assertEquals(DocumentMutationStatus.UPDATED, res.getStatus()); - - } - - @Test - @Order(19) - @DisplayName("19. UpdateOne with a jsonDocument") - public void shouldUpdate() - throws ExecutionException, InterruptedException { - initializeCollectionSimple(); - - JsonDocument doc1 = new JsonDocument().id("1").put("a", "a").put("b", "c"); - JsonDocument doc2 = new JsonDocument().id("2").put("a", "a").put("b", "b"); - collectionSimple.insertMany(doc1, doc2); - - /* - collectionSimple.updateOne(UpdateQuery.builder() - .updateSet("a", "b") - .filter(f) - .withUpsert() - .build());*/ - - collectionSimple.updateMany(UpdateQuery.builder() - .updateSet("a", "b") - .filter(new Filter().where("a").isEqualsTo("a")) - .withUpsert() - .build()); - } - - @Test - @Order(19) - @DisplayName("19. UpsertOne with a jsonDocument") - public void shouldUpsertOneWithJsonDocument() - throws ExecutionException, InterruptedException { - initializeCollectionSimple(); - - JsonDocument doc = new JsonDocument().id("1").put("a", "a").put("b", "c"); - JsonDocumentMutationResult res = collectionSimple.upsertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - - // Upsert with no CHANGE - res = collectionSimple.upsertOneASync(doc).get(); - Assertions.assertEquals(DocumentMutationStatus.UNCHANGED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - - // Upsert with a CHANGE - doc.put("b", "updated"); - res = collectionSimple.upsertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.UPDATED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - } - - @Test - @Order(20) - @DisplayName("20. UpsertOne with a Document") - public void shouldUpsertOneWithDocument() - throws ExecutionException, InterruptedException { - initializeCollectionSimple(); - - Document doc = new Document().id("1").data(new Product("p1", 10.1)); - DocumentMutationResult res = collectionSimple.upsertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - - // Upsert with no CHANGE - res = collectionSimple.upsertOneASync(doc).get(); - Assertions.assertEquals(DocumentMutationStatus.UNCHANGED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - - // Upsert with a CHANGE - doc.getData().setName("updated"); - res = collectionSimple.upsertOne(doc); - Assertions.assertEquals(DocumentMutationStatus.UPDATED, res.getStatus()); - Assertions.assertEquals("1", res.getDocument().getId()); - } - - // ======== INSERT MANY ========= - - @Test - @Order(21) - @DisplayName("21. InsertMany Json") - public void shouldInsertManyJson() { - initializeCollectionSimple(); - - String jsonMany = "[" + - "{\"product_name\":\"test1\",\"product_price\":12.99,\"_id\":\"doc1\"}," + - "{\"product_name\":\"test2\",\"product_price\":2.99,\"_id\":\"doc2\"}" + - "]"; - List status = collectionSimple.insertMany(jsonMany); - Assertions.assertEquals(2, status.size()); - List ids = status.stream() - .map(JsonDocumentMutationResult::getDocument) - .map(Document::getId) - .collect(Collectors.toList()); - Assertions.assertTrue(ids.contains("doc1")); - Assertions.assertTrue(ids.contains("doc2")); - status.forEach(s -> Assertions.assertEquals(DocumentMutationStatus.CREATED, s.getStatus())); - - status = collectionSimple.insertMany(jsonMany); - status.forEach(s -> Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, s.getStatus())); - - collectionSimple.deleteAll(); - collectionSimple.insertManyASync(jsonMany).thenAccept(status2 -> { - Assertions.assertEquals(2, status2.size()); - List ids2 = status2.stream() - .map(JsonDocumentMutationResult::getDocument) - .map(Document::getId) - .collect(Collectors.toList()); - Assertions.assertTrue(ids2.contains("doc1")); - Assertions.assertTrue(ids2.contains("doc2")); - status2.forEach(s -> Assertions.assertEquals(DocumentMutationStatus.CREATED, s.getStatus())); - }); - - } - - @Test - @Order(22) - @DisplayName("22. InsertMany Java Bean") - public void shouldInsertManyJavaBean() { - initializeCollectionSimple(); - - Document p1 = new Document().id("doc1").data(new Product("test1", 12.99)); - Document p2 = new Document().id("doc2").data(new Product("test2", 2.99)); - List> results = collectionSimple.insertMany(List.of(p1, p2)); - if (results !=null) { - results.forEach(r -> { - Assertions.assertEquals(DocumentMutationStatus.CREATED, r.getStatus()); - Assertions.assertNotNull(r.getDocument().getId()); - Product p = r.getDocument().getData(); - Assertions.assertNotNull(p.getName()); - }); - } - - // Same with async - collectionSimple.deleteAll(); - collectionSimple.insertManyASync(List.of(p1, p2)).thenAccept(results2 -> { - if (results2 !=null) { - results2.forEach(r -> { - Assertions.assertEquals(DocumentMutationStatus.CREATED, r.getStatus()); - Assertions.assertNotNull(r.getDocument().getId()); - Product p = r.getDocument().getData(); - Assertions.assertNotNull(p.getName()); - }); - } - }); - } - - JsonDocument player1 = new JsonDocument().id("1").put("firstName", "Lucas").put("lastName", "Hernandez"); - JsonDocument player2 = new JsonDocument().id("2").put("firstName", "Antoine").put("lastName", "Griezmann"); - JsonDocument player3 = new JsonDocument().id("3").put("firstName", "N'Golo").put("lastName", "Kanté"); - JsonDocument player4 = new JsonDocument().id("4").put("firstName", "Paul").put("lastName", "Pogba"); - JsonDocument player5 = new JsonDocument().id("5").put("firstName", "Raphaël").put("lastName", "Varane"); - JsonDocument player6 = new JsonDocument().id("6").put("firstName", "Hugo").put("lastName", "Lloris"); - JsonDocument player7 = new JsonDocument().id("7").put("firstName", "Olivier").put("lastName", "Giroud"); - JsonDocument player8 = new JsonDocument().id("8").put("firstName", "Benjamin").put("lastName", "Pavard"); - JsonDocument player9 = new JsonDocument().id("9").put("firstName", "Kylian").put("lastName", "Mbappé"); - JsonDocument player10 = new JsonDocument().id("10").put("firstName", "Blaise").put("lastName", "Matuidi"); - JsonDocument player11 = new JsonDocument().id("11").put("firstName", "Samuel").put("lastName", "Umtiti"); - JsonDocument player12 = new JsonDocument().id("12").put("firstName", "Thomas").put("lastName", "Lemar"); - JsonDocument player13 = new JsonDocument().id("13").put("firstName", "Ousmane").put("lastName", "Dembélé"); - JsonDocument player14 = new JsonDocument().id("14").put("firstName", "Karim").put("lastName", "Benzema"); - JsonDocument player15 = new JsonDocument().id("15").put("firstName", "Adrien").put("lastName", "Rabiot"); - JsonDocument player16 = new JsonDocument().id("16").put("firstName", "Kingsley").put("lastName", "Coman"); - JsonDocument player17 = new JsonDocument().id("17").put("firstName", "Moussa").put("lastName", "Sissoko"); - JsonDocument player18 = new JsonDocument().id("18").put("firstName", "Lucas").put("lastName", "Digne"); - JsonDocument player19 = new JsonDocument().id("19").put("firstName", "Steve").put("lastName", "Mandanda"); - JsonDocument player20 = new JsonDocument().id("20").put("firstName", "Presnel").put("lastName", "Kimpembe"); - JsonDocument player21 = new JsonDocument().id("21").put("firstName", "Clement").put("lastName", "Lenglet"); - JsonDocument player22 = new JsonDocument().id("22").put("firstName", "Leo").put("lastName", "Dubois"); - JsonDocument player23 = new JsonDocument().id("23").put("firstName", "Kurt").put("lastName", "Zouma"); - JsonDocument player24 = new JsonDocument().id("24").put("firstName", "Tanguy").put("lastName", "Ndombele"); - - @Test - @Order(23) - @DisplayName("23. InsertMany JsonDocuments") - public void shouldManyJsonDocuments() { - initializeCollectionSimple(); - collectionSimple.insertManyJsonDocuments(List.of(player1, player2)).forEach(r -> { - Assertions.assertEquals(DocumentMutationStatus.CREATED, r.getStatus()); - Assertions.assertNotNull(r.getDocument().getId()); - Assertions.assertNotNull(r.getDocument().getString("firstName")); - }); - collectionSimple.deleteAll(); - - // Same but Async - collectionSimple.insertManyJsonDocumentsASync(List.of(player1, player2)).thenAccept(r -> { - Assertions.assertEquals(2, r.size()); - r.forEach(res -> { - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - Assertions.assertNotNull(res.getDocument().getId()); - Assertions.assertNotNull(res.getDocument().getString("firstName")); - }); - }); - } - - @Test - @Order(24) - @DisplayName("24. InsertMany too many items") - public void shouldInsertTooMany() { - initializeCollectionSimple(); - //Assertions.assertThrows(DataApiInvalidArgumentException.class, - // () -> collectionSimple.insertMany( List.of( - // player1, player2, player3, player4, player5, player6, - // player7, player8, player9, player10,player11, player12, - // player13, player14, player15, player16, player17, player18, - // player19, player20, player21, player22, player23, player24))); - try { - collectionSimple.insertMany( List.of( - player1, player2, player3, player4, player5, player6, - player7, player8, player9, player10,player11, player12, - player13, player14, player15, player16, player17, player18, - player19, player20, player21, player22, player23, player24)); - } catch(DataApiInvalidArgumentException dai) { - dai.printStackTrace();; - } - } - - - @Test - @Order(25) - @DisplayName("25. InsertMany order true, no replace") - public void shouldInsertManyOrdered() { - initializeCollectionSimple(); - - List>> othersPlayers = new ArrayList<>(List.of( - player1, player2, player3, - player4, player5, player6, - player7, player8, player9)); - List statuses1 = new ArrayList<>(); - collectionSimple.insertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - statuses1.add(res.getStatus()); - }); - log.info("Statuses => " + statuses1.stream().map(Enum::name).collect(Collectors.joining(", "))); - - // Insert again - List statuses = new ArrayList<>(); - collectionSimple.enableOrderingWhenInsert(); - collectionSimple.insertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - if (player1.getId().equals(res.getDocument().getId())) { - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, res.getStatus()); - } else { - Assertions.assertEquals(DocumentMutationStatus.NOT_PROCESSED, res.getStatus()); - } - statuses.add(res.getStatus()); - }); - log.info("Statuses => " + statuses.stream().map(Enum::name).collect(Collectors.joining(", "))); - } - - @Test - @Order(26) - @DisplayName("26. InsertMany with replacements") - public void shouldInsertManyWithDuplicatesOrder() { - initializeCollectionSimple(); - - List>> othersPlayers = new ArrayList<>(List.of( - player1, player2, player3, - player4, player5, player6, - player7, player8)); - othersPlayers.add(new JsonDocument().id("9").put("firstName", "Kylian2").put("lastName", "Mbappé")); - othersPlayers.addAll(List.of(player9, player10,player11)); - log.info("Players order, 9 is duplicate :" + othersPlayers - .stream().map(Document::getId) - .collect(Collectors.joining(", "))); - - - // Status CREATED up to the duplicate - List statuses = new ArrayList<>(); - collectionSimple.enableOrderingWhenInsert(); - collectionSimple.insertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - int id = Integer.parseInt(res.getDocument().getId()); - if (id<9) { - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - } else if (id==9) { - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, res.getStatus()); - } else { - Assertions.assertEquals(DocumentMutationStatus.NOT_PROCESSED, res.getStatus()); - } - statuses.add(res.getStatus()); - }); - log.info("Statuses1 => " + statuses.stream().map(Enum::name).collect(Collectors.joining(", "))); - - // Status ALREADY EXIST for first and else NOT PROCESS - List statuses2 = new ArrayList<>(); - collectionSimple.insertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - int id = Integer.parseInt(res.getDocument().getId()); - if (id==1) { - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, res.getStatus()); - } else { - Assertions.assertEquals(DocumentMutationStatus.NOT_PROCESSED, res.getStatus()); - } - statuses2.add(res.getStatus()); - }); - log.info("Statuses2 => " + statuses2.stream().map(Enum::name).collect(Collectors.joining(", "))); - - // 1 to 9 is ALREADY_EXIST, 10 and 11 are created - collectionSimple.disableOrderingWhenInsert(); - List statuses3 = new ArrayList<>(); - collectionSimple.insertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - int id = Integer.parseInt(res.getDocument().getId()); - if (id<10) { - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, res.getStatus()); - } else { - Assertions.assertEquals(DocumentMutationStatus.CREATED, res.getStatus()); - } - statuses3.add(res.getStatus()); - }); - log.info("Statuses3 => " + statuses3.stream().map(Enum::name).collect(Collectors.joining(", "))); - - // Try to replace - List statuses4 = new ArrayList<>(); - collectionSimple.upsertMany(othersPlayers).forEach(res -> { - Assertions.assertNotNull(res.getDocument().getId()); - int id = Integer.parseInt(res.getDocument().getId()); - if (id==9) { - Assertions.assertEquals(DocumentMutationStatus.UPDATED, res.getStatus()); - } else { - Assertions.assertEquals(DocumentMutationStatus.UNCHANGED, res.getStatus()); - } - statuses4.add(res.getStatus()); - }); - log.info("Statuses4 => " + statuses4.stream().map(Enum::name).collect(Collectors.joining(", "))); - } - - // ======== INSERT MANY ========= - - @Test - @Order(27) - @DisplayName("27. InsertVeryMany Documents") - public void shouldInsertManyChunkedSequential() { - initializeCollectionSimple(); - - int nbDocs = 251; - List> documents = new ArrayList<>(); - long start = System.currentTimeMillis(); - for (int i = 0; i < nbDocs; i++) { - documents.add(new Document().id(String.valueOf(i)).data(new Product("Desc " + i, i * 1.0d))); - } - List> result = collectionSimple.insertManyChunked(documents, 20, 1); - long end = System.currentTimeMillis(); - log.info("Inserting {} documents took {} ms", nbDocs, end - start); - Assertions.assertEquals(nbDocs, collectionSimple.countDocuments()); - Assertions.assertEquals(nbDocs, result.size()); - collectionSimple.deleteAll(); - collectionSimple - .insertManyChunkedASync(documents, 20, 1) - .thenAccept(res -> Assertions.assertEquals(nbDocs, res.size())); - } - - @Test - @Order(28) - @DisplayName("28. InsertVeryMany concurrently") - public void shouldInsertManyChunkedParallel() { - initializeCollectionSimple(); - List> documents = new ArrayList<>(); - long start = System.currentTimeMillis(); - - int nbDocs = 999; - for (int i = 0; i < nbDocs; i++) { - documents.add(new Document().id(String.valueOf(i)).data(new Product("Desc " + i, i * 1.0d))); - } - collectionSimple.insertManyChunked(documents, 20, 20); - long end = System.currentTimeMillis(); - log.info("Inserting {} documents took {} ms", nbDocs, end - start); - - collectionSimple.countDocuments(); - - long top = System.currentTimeMillis(); - //DeleteQuery query = DeleteQuery.builder() - // .where("product_price", GREATER_THAN, 100) - // .build(); - //collectionSimple.deleteMany(query); - //collectionSimple.deleteManyChunked(query, 5); - //System.out.println("Total time " + (System.currentTimeMillis() - top)); - //collectionSimple.countDocuments(); - - /* - collectionSimple.insertManyChunkedASync(documents, 20, 20).thenAccept(res -> { - Assertions.assertEquals(nbDocs, res.size()); - Assertions.assertEquals(nbDocs, collectionSimple.countDocuments()); - });*/ - - } - - @Test - @Order(29) - @DisplayName("29. InsertMany with duplicates") - public void insertWithDuplicatesLeadToErrors() { - initializeCollectionSimple(); - collectionSimple.enableOrderingWhenInsert(); - List status = collectionSimple.insertManyJsonDocuments(List.of( - new JsonDocument().id("1").put("firstName", "Kylian").put("lastName", "Mbappé"), - new JsonDocument().id("1").put("firstName", "Antoine").put("lastName", "Griezmann"))); - Assertions.assertEquals(DocumentMutationStatus.ALREADY_EXISTS, status.get(0).getStatus()); - } - - @Test - @Order(30) - @DisplayName("30. UpsertMany") - public void insertVeryWithDuplicatesLeadToErrors() { - initializeCollectionSimple(); - List status = collectionSimple.upsertManyJsonDocuments(List.of(player1, player2, player3)); - Assertions.assertEquals(DocumentMutationStatus.CREATED, status.get(0).getStatus()); - } - - // ======== FIND ========= - - @Test - @Order(25) - @DisplayName("25. Find with $gte") - public void shouldFindWithGreaterThan() { - shouldInsertADocument(); - Assertions.assertEquals(1, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isGreaterOrEqualsThan(12.99)) - .build()).count()); - } - - @Test - @Order(25) - @DisplayName("25. Find with $gte") - public void shouldFindWithEquals() { - shouldInsertADocument(); - /* - Filter f1 = new Filter().where("product_price").isEqualsTo(12.99); - Assertions.assertEquals(1, collectionVector.find(new SelectQuery(f1)).count()); - - Filter f2 = new Filter(). - and() - .where("product_price", FilterOperator.EQUALS_TO,12.99) - .where("product_name", FilterOperator.EQUALS_TO, "HealthyFresh - Beef raw dog food") - .end(); - Assertions.assertEquals(1, collectionVector.find(new SelectQuery(f2)).count()); - Filter f3 = new Filter() - .not() - .where("product_price", FilterOperator.EQUALS_TO,10.99) - .end(); - Assertions.assertEquals(5, collectionVector.find(new SelectQuery(f3)).count()); - - Filter f4 = new Filter("{\"$not\":{\"product_price\":{\"$eq\":10.99}}}"); - Assertions.assertEquals(5, collectionVector.find(new SelectQuery(f4)).count()); - */ - - Filter yaFilter = new Filter() - .and() - .or() - .where("a", EQUALS_TO, 10) - .where("b", EXISTS, true) - .end() - .or() - .where("c", GREATER_THAN, 5) - .where("d", GREATER_THAN_OR_EQUALS_TO, 5) - .end() - .not() - .where("e", LESS_THAN, 5) - .end(); - - collectionVector.find(new SelectQuery(yaFilter)); - - } - - @Test - @Order(26) - @DisplayName("26. Find with $gt") - // Greater than - public void shouldFindGreaterThan() { - shouldInsertADocument(); - Assertions.assertEquals(1, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isGreaterThan(10)) - .build()).count()); - } - - @Test - @Order(27) - @DisplayName("27. Find with $lt (less than)") - // Greater than - public void shouldFindLessThen() { - shouldInsertADocument(); - Assertions.assertEquals(2, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isLessThan(10)) - .build()).count()); - } - - @Test - @Order(28) - @DisplayName("28. Find with $lte (less than or equals)") - // Greater than - public void shouldFindLessOrEqualsThen() { - shouldInsertADocument(); - Assertions.assertEquals(2, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isLessOrEqualsThan(9.99)) - .build()).count()); - } - - @Test - @Order(29) - @DisplayName("29. Find with $eq") - // Greater than - public void shouldEqualsThen() { - shouldInsertADocument(); - Assertions.assertEquals(1, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isEqualsTo(9.99)) - .build()).count()); - } - - @Test - @Order(30) - @DisplayName("30. Find Nwith $ne (not equals)") - // Greater than - public void shouldNotEqualsThen() { - shouldInsertADocument(); - Assertions.assertEquals(4, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .isNotEqualsTo(9.99)) - .build()).count()); - } - - @Test - @Order(31) - @DisplayName("31. Find with $exists") - // Greater than - public void shouldFindExists() { - shouldInsertADocument(); - Assertions.assertEquals(3, collectionVector.find(SelectQuery.builder() - .filter(new Filter().where("product_price") - .exists()) - .build()).count()); - } - - @Test - @Order(32) - @DisplayName("32. AND with Exists and Not Equals") - // Greater than - public void shouldFindAndExistsAndNotEquals() { - shouldInsertADocument(); - // Exists AND not equals - // {"find":{"filter":{"$and":[{"product_price":{"$exists":true}},{"product_price":{"$ne":9.99}}]}}} - SelectQuery existAndNotEquals = new SelectQuery(); - List>> andCriteriaList = new ArrayList<>(); - Map> criteria1 = new HashMap<>(); - criteria1.put("product_price", Map.of("$exists", true)); - Map> criteria2 = new HashMap<>(); - criteria2.put("product_price", Map.of("$ne", 9.99)); - andCriteriaList.add(criteria1); - andCriteriaList.add(criteria2); - existAndNotEquals.setFilter(Map.of("$and", andCriteriaList)); - Assertions.assertEquals(2, collectionVector.find(existAndNotEquals).count()); - - SelectQuery query2 = SelectQuery.builder().filter(new Filter("{" + - "\"$and\":[" + - " {" + - "\"product_price\": {\"$exists\":true}" + - "}," + - "{" + - "\"product_price\":{\"$ne\":9.99}}]" + - "}")) - .build(); - Assertions.assertEquals(2, collectionVector.find(query2).count()); - - } - - @Test - @Order(33) - @DisplayName("33. Find $in") - public void shouldFindWithIn() { - shouldInsertOneComplexDocument(); - - // $in - log.info("Search with $in..."); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("metadata_string") - .isInArray(new String[]{"hello", "world"})).build()) - .findFirst().isPresent()); - } - - @Test - @Order(34) - @DisplayName("34. Find $nin") - public void shouldFindWithNIn() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("metadata_string") - .isNotInArray(new String[]{"Hallo", "Welt"})).build()) - .findFirst().isPresent()); - } - - @Test - @Order(35) - @DisplayName("35. Should find with $size") - public void shouldFindWithSize() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("metadata_boolean_array") - .hasSize(3)).build()).findFirst().isPresent()); - } - - @Test - @Order(36) - @DisplayName("36. Should find with $lt") - public void shouldFindWithLT() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("metadata_int") - .isLessThan(2)).build()).findFirst().isPresent()); - } - - @Test - @Order(37) - @DisplayName("37. Should find with $lte") - public void shouldFindWithLTE() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("metadata_int") - .isLessOrEqualsThan(1)).build()).findFirst().isPresent()); - } - - @Test - @Order(38) - @DisplayName("38. Should find with $gt") - public void shouldFindWithGTE() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find( - SelectQuery.builder().filter(new Filter() - .where("metadata_int") - .isGreaterThan(0)).build()).findFirst().isPresent()); - } - - @Test - @Order(39) - @DisplayName("39. Should find with $gte and Instant") - public void shouldFindWithGTEInstant() { - shouldInsertOneComplexDocument(); - Assertions.assertTrue(collectionSimple.find(SelectQuery.builder().filter(new Filter() - .where("metadata_instant") - .isLessThan(Instant.now())).build()).findFirst().isPresent()); - } - - @Test - @Order(40) - @DisplayName("40. ToString should provide the json String") - public void shouldSerializedAsJson() { - - // Serializing a JsonDocument give you back the Json String - JsonDocument doc1 = new JsonDocument().id("1").put("a", "a").put("b", "c"); - Assertions.assertEquals("{\"a\":\"a\",\"b\":\"c\",\"_id\":\"1\"}", doc1.toString()); - - // Serializing a Document give you back a Json String - Document doc2 = new Document().id("1").data(new Product("name", 1d)); - Assertions.assertEquals("{\"product_name\":\"name\",\"product_price\":1.0,\"_id\":\"1\"}", doc2.toString()); - - initializeCollectionVector(); - collectionVector.insertManyJsonDocuments(List.of( - new JsonDocument() - .id("doc1") // generated if not set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99), - new JsonDocument() - .id("doc2") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data("{\"product_name\": \"HealthyFresh - Chicken raw dog food\", \"product_price\": 9.99}"), - new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food")), - new JsonDocument() - .id("doc4") - .vector(new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99) - )); - - SelectQuery query2 = SelectQuery.builder() - .orderByAnn(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .withLimit(4) - .includeSimilarity() - .build(); - collectionVector.find(query2).forEach(System.out::println); - } - - @Test - @Order(41) - @DisplayName("41. Create Collections (with deny)") - public void shouldCreateCollectionWithDenyOptions() { - if (astraDb == null) shouldConnectToDatabase(); - // When - collectionDeny = astraDb.createCollection(CollectionDefinition.builder() - .name(TEST_COLLECTION_DENY) - .vector(14, SimilarityMetric.cosine) - .indexingDeny("blob_body") - .build()); - collectionDeny.insertOne(new JsonDocument() - .id("p1") - .put("prop1", "value1") - .put("blob_body", "hello")); - // Then - Assertions.assertTrue(collectionDeny - .findById("p1").isPresent()); - Assertions.assertTrue(collectionDeny - .findOne(SelectQuery - .builder().filter(new Filter().where("prop1") - .isEqualsTo("value1")).build()).isPresent()); - Assertions.assertThrows(DataApiException.class, () -> collectionDeny - .findOne(SelectQuery.builder() - .filter(new Filter().where("blob_body") - .isEqualsTo("hello")) - .build())); - } - - @Test - public void shouldDoSemanticSearch() { - if (astraDb == null) shouldConnectToDatabase(); - initializeCollectionVector(); - - // When - // Insert vectors - collectionVector.insertOne( - new JsonDocument() - .id("doc1") // generated if not set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99)); - collectionVector.insertOne( - new JsonDocument() - .id("doc2") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)); - collectionVector.insertOne( - new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food"))); - collectionVector.insertOne( - new JsonDocument() - .id("doc4") - .vector(new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)); - - // Perform a similarity search - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - //Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - int maxRecord = 10; - long top = System.currentTimeMillis(); - Stream resultsSet = collectionVector.findVector(embeddings, null, maxRecord); - System.out.println(System.currentTimeMillis() - top); - } - - @Test - @Order(42) - @DisplayName("42. Create Collections (with allow)") - public void shouldCreateCollectionWithAllowOptions() { - if (astraDb == null) shouldConnectToDatabase(); - // ---- TESTING WITH ALLOW ----- - - // When - astraDb.deleteCollection(TEST_COLLECTION_ALLOW); - collectionAllow = astraDb.createCollection(CollectionDefinition.builder() - .name(TEST_COLLECTION_ALLOW) - .vector(14, SimilarityMetric.cosine) - .indexingAllow("prop1") - .build()); - collectionAllow.insertOne(new JsonDocument() - .id("p1") - .put("prop1", "value1") - .put("blob_body", "hello")); - Assertions.assertTrue(collectionAllow - .findOne(SelectQuery.builder() .filter(new Filter().where("prop1").isEqualsTo("value1")) - .build()).isPresent()); - Assertions.assertThrows(DataApiException.class, () -> collectionAllow - .findOne(SelectQuery.builder() - .filter(new Filter().where("blob_body") - .isEqualsTo("hello")) - .build())); - - } - - @Test - @Order(43) - @DisplayName("43. Find in array (not keyword)") - public void testFindInArray() { - initializeCollectionSimple(); - // Given 2 records - collectionSimple.insertManyJsonDocuments(List.of( - new JsonDocument().id("1").put("names", List.of("John", "Doe")), - new JsonDocument().id("2").put("names", List.of("Cedrick", "Lunven")) - )); - // I should perform an any filter in a collection - Assertions.assertEquals(1, collectionSimple.find(SelectQuery.builder() - .filter(new Filter().where("names") - .isEqualsTo("John")) - .build()).count()); - } - - // ---------------------------------------- - // --------- Object Mapping --------------- - // ---------------------------------------- - - static AstraDBRepository productRepositoryVector; - static AstraDBRepository productRepositorySimple; - - @Test - @Order(50) - @DisplayName("50. Insert with CollectionRepository and vector") - public void shouldInsertRecords() { - initializeCollectionVector(); - - productRepositoryVector = astraDb.getCollection(TEST_COLLECTION_VECTOR, Product.class); - productRepositoryVector.insert(new Document<>( - "product1", - new Product("something Good", 9.99), - new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f})); - - // Add vector without an id - productRepositoryVector.insert(new Document() - .data(new Product("id will be generated for you", 10.99)) - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f})); - - // Insert a full-fledged object - productRepositoryVector.insert(new Document() - .id("pf2000") - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f})); - } - - @Test - @Order(51) - @DisplayName("51. Insert with CollectionRepository") - public void shouldInsertWithSimpleCollectionObjectMapping() { - productRepositorySimple = astraDb.getCollection(TEST_COLLECTION_NAME, Product.class); - Assertions.assertNotNull(productRepositorySimple); - productRepositorySimple.save(new Document().id("p1").data(new Product("Pupper Sausage Beef dog Treats", 9.99))); - productRepositorySimple.save(new Document().id("p2").data(new Product("Dog Ring Chew Toy", 10.99))); - productRepositorySimple.saveAll(List.of( - new Document().id("p3").data(new Product("Dog Ring Chew Toy", 9.99)), - new Document().id("p4").data(new Product("Pepper Sausage Bacon dog Treats", 9.99)) - )); - } - - private void initializeCollectionSimple() { - if (astraDb == null) { - databaseId = astraDbAdmin.createDatabase(TEST_DBNAME, targetCloud, targetRegion); - astraDb = astraDbAdmin.getDatabase(databaseId); - } - if (collectionSimple == null) { - collectionSimple = astraDb.createCollection(TEST_COLLECTION_NAME); - } - collectionSimple.deleteAll(); - } - - private void initializeCollectionVector() { - if (astraDb == null) { - databaseId = astraDbAdmin.createDatabase(TEST_DBNAME, targetCloud, targetRegion); - astraDb = astraDbAdmin.getDatabase(databaseId); - } - if (collectionVector == null) { - collectionVector = astraDb.createCollection(TEST_COLLECTION_VECTOR, 14); - } - collectionVector.deleteAll(); - } - -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/BreakAstraTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/BreakAstraTest.java deleted file mode 100644 index 0cbecff3..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/BreakAstraTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.utils.Utils; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.UUID; - -public class BreakAstraTest { - - public static final String TEST_DBNAME = "astra_db_client"; - - static CloudProviderType targetCloud = AstraDBAdmin.FREE_TIER_CLOUD; - static String targetRegion = AstraDBAdmin.FREE_TIER_CLOUD_REGION; - static String astraToken = Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN").get(); - - static AstraDBAdmin astraDbAdmin; - static AstraDB astraDb; - static UUID databaseId; - static AstraDBCollection collectionSimple; - - @Test - public void testQueryBust() { - astraDbAdmin = new AstraDBAdmin(astraToken, AstraEnvironment.PROD); - databaseId = astraDbAdmin.createDatabase(TEST_DBNAME, targetCloud, targetRegion); - astraDb = astraDbAdmin.getDatabase(databaseId); - collectionSimple = astraDb.createCollection("collection_vector", 1536); - collectionSimple.deleteAll(); - List> documents = new ArrayList<>(); - - // Create an instance of Random - Random random = new Random(); - int size = 1536; - float[] fakeEmbeddings = new float[size]; - for(int i = 0; i < size; i++) { - fakeEmbeddings[i] = random.nextFloat(); - } - - long start = System.currentTimeMillis(); - int nbDocs = 200000; - for (int i = 0; i < nbDocs; i++) { - documents.add(new Document() - .id(String.valueOf(i)) - .vector(fakeEmbeddings) - .data(new AstraDBTestSuiteIT.Product("Desc " + i, i * 1.0d))); - } - collectionSimple.insertManyChunked(documents, 20, 200); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorStore.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorStore.java deleted file mode 100644 index 1692181f..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/ClusteredMetadataVectorStore.java +++ /dev/null @@ -1,213 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.uuid.Uuids; -import dev.langchain4j.data.document.Metadata; -import dev.langchain4j.data.embedding.Embedding; -import dev.langchain4j.data.segment.TextSegment; -import dev.langchain4j.internal.ValidationUtils; -import dev.langchain4j.store.embedding.CosineSimilarity; -import dev.langchain4j.store.embedding.EmbeddingMatch; -import dev.langchain4j.store.embedding.EmbeddingStore; -import dev.langchain4j.store.embedding.RelevanceScore; -import lombok.NonNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import static java.util.stream.Collectors.toList; - -/** - * Implementation of {@link EmbeddingStore} using Cassandra. - * - * @see EmbeddingStore - */ -public class ClusteredMetadataVectorStore implements EmbeddingStore { - - /** Represents an embedding table in Cassandra, it is a table with a vector column. */ - protected ClusteredMetadataVectorTable embeddingTable; - - /** - * Embedding Store. - * - * @param table - * Cassandra Table - */ - public ClusteredMetadataVectorStore(ClusteredMetadataVectorTable table) { - this.embeddingTable = table; - } - - /** - * Delete the table. - */ - public void delete() { - embeddingTable.delete(); - } - - /** - * Delete all rows. - */ - public void clear() { - embeddingTable.clear(); - } - - /** - * Add a new embedding to the store. - * - the row id is generated - * - text and metadata are not stored - * - * @param embedding representation of the list of floats - * @return newly created row id - */ - @Override - public String add(@NonNull Embedding embedding) { - return add(embedding, null); - } - - /** - * Add a new embedding to the store. - * - the row id is generated - * - text and metadata coming from the text Segment - * - * @param embedding representation of the list of floats - * @param textSegment text content and metadata - * @return newly created row id - */ - @Override - public String add(@NonNull Embedding embedding, TextSegment textSegment) { - ClusteredMetadataVectorRecord record = new ClusteredMetadataVectorRecord(); - record.setVector(embedding.vectorAsList()); - record.setPartitionId("default"); - record.setRowId(Uuids.timeBased()); - if (textSegment != null) { - record.setBody(textSegment.text()); - Map metaData = textSegment.metadata().asMap(); - if (metaData != null && !metaData.isEmpty()) { - if (metaData.containsKey(ClusteredMetadataVectorTable.PARTITION_ID)) { - record.setPartitionId(metaData.get(ClusteredMetadataVectorTable.PARTITION_ID)); - metaData.remove(ClusteredMetadataVectorTable.PARTITION_ID); - } - record.setMetadata(metaData); - } - } - embeddingTable.save(record); - return record.getRowId().toString(); - } - - /** - * Add a new embedding to the store. - * - * @param rowId the row id - * @param embedding representation of the list of floats - */ - @Override - public void add(@NonNull String rowId, @NonNull Embedding embedding) { - ClusteredMetadataVectorRecord record = new ClusteredMetadataVectorRecord(); - record.setVector(embedding.vectorAsList()); - record.setPartitionId("default"); - record.setRowId(UUID.fromString(rowId)); - embeddingTable.save(record); - } - - /** - * They will all be added in the same partition. - * - * @param embeddingList embeddings list - * @return list of new row if (same order as the input) - */ - @Override - public List addAll(List embeddingList) { - return embeddingList.stream() - .map(Embedding::vectorAsList) - .map(ClusteredMetadataVectorRecord::new) - .peek(embeddingTable::save) - .map(ClusteredMetadataVectorRecord::getRowId) - .map(UUID::toString) - .collect(toList()); - } - - /** - * Add multiple embeddings as a single action. - * - * @param embeddingList embeddings - * @param textSegmentList text segments - * @return list of new row if (same order as the input) - */ - @Override - public List addAll(List embeddingList, List textSegmentList) { - if (embeddingList == null || textSegmentList == null || embeddingList.size() != textSegmentList.size()) { - throw new IllegalArgumentException("embeddingList and textSegmentList must not be null and have the same size"); - } - // Looping on both list with an index - List ids = new ArrayList<>(); - for (int i = 0; i < embeddingList.size(); i++) { - ids.add(add(embeddingList.get(i), textSegmentList.get(i))); - } - return ids; - } - - /** - * Search for relevant. - * - * @param embedding current embeddings - * @param maxResults max number of result - * @param minScore threshold - * @return list of matching elements - */ - public List> findRelevant(Embedding embedding, int maxResults, double minScore) { - return findRelevant(embedding, maxResults, minScore, null); - } - - /** - * Similarity Search ANN based on the embedding. - * - * @param embedding vector - * @param maxResults max number of results - * @param minScore score minScore - * @param metadata map key-value to build a metadata filter - * @return list of matching results - */ - public List> findRelevant(Embedding embedding, int maxResults, double minScore, Metadata metadata) { - AnnQuery.AnnQueryBuilder builder = AnnQuery.builder() - .embeddings(embedding.vectorAsList()) - .metric(CassandraSimilarityMetric.COSINE) - .recordCount(ValidationUtils.ensureGreaterThanZero(maxResults, "maxResults")) - .threshold(CosineSimilarity.fromRelevanceScore(ValidationUtils.ensureBetween(minScore, 0, 1, "minScore"))); - if (metadata != null) { - builder.metaData(metadata.asMap()); - } - return embeddingTable - .similaritySearch(builder.build()) - .stream() - .map(this::mapSearchResult) - .collect(toList()); - } - - /** - * Map Search result coming from Astra. - * - * @param record current record - * @return search result - */ - private EmbeddingMatch mapSearchResult(AnnResult record) { - - TextSegment embedded = null; - String body = record.getEmbedded().getBody(); - if (body != null - && !body.isEmpty() - && record.getEmbedded().getMetadata() != null) { - embedded = TextSegment.from(record.getEmbedded().getBody(), - new Metadata(record.getEmbedded().getMetadata())); - } - return new EmbeddingMatch<>( - // Score - RelevanceScore.fromCosineSimilarity(record.getSimilarity()), - // EmbeddingId : unique identifier - record.getEmbedded().getRowId().toString(), - // Embeddings vector - Embedding.from(record.getEmbedded().getVector()), - // Text segment and metadata - embedded); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/RagPdfVectorTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/RagPdfVectorTest.java deleted file mode 100644 index c8338b95..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/cassio/RagPdfVectorTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.dtsx.astra.sdk.cassio; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.utils.TestUtils; -import dev.langchain4j.data.document.Document; -import dev.langchain4j.data.document.DocumentParser; -import dev.langchain4j.data.document.DocumentSplitter; -import dev.langchain4j.data.document.parser.apache.pdfbox.ApachePdfBoxDocumentParser; -import dev.langchain4j.data.document.splitter.DocumentSplitters; -import dev.langchain4j.data.embedding.Embedding; -import dev.langchain4j.data.message.AiMessage; -import dev.langchain4j.data.segment.TextSegment; -import dev.langchain4j.model.chat.ChatLanguageModel; -import dev.langchain4j.model.embedding.EmbeddingModel; -import dev.langchain4j.model.input.Prompt; -import dev.langchain4j.model.input.PromptTemplate; -import dev.langchain4j.model.openai.OpenAiChatModel; -import dev.langchain4j.model.openai.OpenAiEmbeddingModel; -import dev.langchain4j.model.openai.OpenAiTokenizer; -import dev.langchain4j.model.output.Response; -import dev.langchain4j.store.embedding.EmbeddingMatch; -import dev.langchain4j.store.embedding.EmbeddingStore; -import dev.langchain4j.store.embedding.EmbeddingStoreIngestor; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; - -import java.io.InputStream; -import java.time.Duration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import static com.dtsx.astra.sdk.utils.TestUtils.getAstraToken; -import static dev.langchain4j.model.openai.OpenAiModelName.GPT_3_5_TURBO; -import static java.util.stream.Collectors.joining; - -@Slf4j -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class RagPdfVectorTest { - - public static final String LLM_MODEL_CHAT_COMPLETION = "gpt-3.5-turbo"; - public static final String TEXT_EMBEDDING_ADA_002 = "text-embedding-ada-002"; - public static final int LLM_MODEL_DIMENSION = 1536; - - public static EmbeddingModel embeddingModel; - public static EmbeddingStore embeddingStore; - - /** - * Settings from Astra Usage - */ - private static final String ASTRA_DB_DATABASE = "test_java_astra_db_client"; - static CqlSession cqlSession; - static ClusteredMetadataVectorTable cassandraTable; - - @BeforeAll - public static void init() { - - // Initializing DV - UUID databaseId = new AstraDBAdmin(getAstraToken()).createDatabase(ASTRA_DB_DATABASE); - log.info("Astra Database is ready"); - - // Initializing Session - cqlSession = CassIO.init(getAstraToken(), databaseId, TestUtils.TEST_REGION, AstraDBAdmin.DEFAULT_KEYSPACE); - log.info("Astra connection is opened"); - - // Initializing table - cassandraTable = CassIO.clusteredMetadataVectorTable("vector_store", LLM_MODEL_DIMENSION); - CassIO.metadataVectorTable("", 1536); - cassandraTable.create(); - log.info("Destination Table is created"); - - // Initializing Embedding Store - embeddingStore = new ClusteredMetadataVectorStore(cassandraTable); - log.info("Embedding Store is ready"); - - // Initializing Embedding Model - embeddingModel = OpenAiEmbeddingModel.builder() - .apiKey(System.getenv("OPENAI_API_KEY")) - .modelName(TEXT_EMBEDDING_ADA_002) - .build(); - log.info("Embedding Model is ready"); - } - - @Test - @SuppressWarnings("unchecked") - public void shouldIngestPDF() { - - DocumentParser parser = new ApachePdfBoxDocumentParser(); - InputStream inputStream = RagPdfVectorTest.class.getClassLoader().getResourceAsStream("johnny.pdf"); - - Document document = parser.parse(inputStream); - - DocumentSplitter splitter = DocumentSplitters - .recursive(100, 10, new OpenAiTokenizer(GPT_3_5_TURBO)); - - EmbeddingStoreIngestor ingestor = EmbeddingStoreIngestor.builder() - .documentSplitter(splitter) - .embeddingModel(embeddingModel) - .embeddingStore(embeddingStore) - .build(); - ingestor.ingest(document); - - } - - @Test - public void shouldDoRAG() { - String question = "What animal is Johnny ?"; - - // Embed the question - Response questionEmbedding = embeddingModel.embed(question); - - // Find relevant embeddings in embedding store by semantic similarity - // You can play with parameters below to find a sweet spot for your specific use case - int maxResults = 5; - double minScore = 0.8; - List> relevantEmbeddings = - embeddingStore.findRelevant(questionEmbedding.content(), maxResults, minScore); - - - // Create a prompt for the model that includes question and relevant embeddings - PromptTemplate promptTemplate = PromptTemplate.from( - "Answer the following question to the best of your ability:\n" - + "\n" - + "Question:\n" - + "{{question}}\n" - + "\n" - + "Base your answer on the following information:\n" - + "{{information}}"); - - String information = relevantEmbeddings.stream() - .map(match -> match.embedded().text()) - .collect(joining("\n\n")); - - Map variables = new HashMap<>(); - variables.put("question", question); - variables.put("information", information); - - Prompt prompt = promptTemplate.apply(variables); - - // Send the prompt to the OpenAI chat model - ChatLanguageModel chatModel = OpenAiChatModel.builder() - .apiKey(System.getenv("OPENAI_API_KEY")) - .modelName(GPT_3_5_TURBO) - .temperature(0.7) - .timeout(Duration.ofSeconds(15)) - .maxRetries(3) - .logResponses(true) - .logRequests(true) - .build(); - - Response aiMessage = chatModel.generate(prompt.toUserMessage()); - - // See an answer from the model - String answer = aiMessage.content().text(); - System.out.println(answer); - - - } - -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOClusteredMetadataVectorTable.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOClusteredMetadataVectorTable.java deleted file mode 100644 index 5e94f025..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOClusteredMetadataVectorTable.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.cassio.AnnQuery; -import com.dtsx.astra.sdk.cassio.CassIO; -import com.dtsx.astra.sdk.cassio.ClusteredMetadataVectorRecord; -import com.dtsx.astra.sdk.cassio.ClusteredMetadataVectorTable; -import com.dtsx.astra.sdk.utils.TestUtils; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import static com.dtsx.astra.sdk.cassio.AbstractCassandraTable.PARTITION_ID; - -public class CassIOClusteredMetadataVectorTable { - public static void main(String[] args) { - - // Create db if not exists - UUID databaseId = new AstraDBAdmin("TOKEN") - .createDatabase("database"); - - // Initializing CqlSession - try (CqlSession cqlSession = CassIO.init("TOKEN", - databaseId, TestUtils.TEST_REGION, - AstraDBAdmin.DEFAULT_KEYSPACE)) { - - // Initializing table with the dimension - ClusteredMetadataVectorTable vector_Store = CassIO - .clusteredMetadataVectorTable("vector_store", 1536); - vector_Store.create(); - - // Insert Vectors - String partitionId = UUID.randomUUID().toString(); - ClusteredMetadataVectorRecord record = new ClusteredMetadataVectorRecord(); - record.setVector(List.of(0.1f, 0.2f, 0.3f, 0.4f)); - record.setMetadata(Map.of("key", "value")); - record.setPartitionId(partitionId); - record.setBody("Sample text fragment"); - record.setAttributes("handy field for special attributes"); - vector_Store.put(record); - - // Semantic Search - AnnQuery query = AnnQuery - .builder() - .embeddings(List.of(0.1f, 0.2f, 0.3f, 0.4f)) - .metaData(Map.of(PARTITION_ID, partitionId)) - .build(); - - vector_Store.similaritySearch(query).forEach(result -> { - System.out.println("Similarity : " + result.getSimilarity()); - System.out.println("Record : " + result.getEmbedded().getBody()); - }); - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOConnection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOConnection.java deleted file mode 100644 index 5af1428f..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOConnection.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.cassio.CassIO; -import com.dtsx.astra.sdk.utils.TestUtils; - -import java.util.UUID; - -public class CassIOConnection { - - public static void main(String[] args) { - - // Create db if not exists - UUID databaseId = new AstraDBAdmin("TOKEN") - .createDatabase("database"); - - // Initializing CqlSession - try (CqlSession cqlSession = CassIO.init("TOKEN", - databaseId, TestUtils.TEST_REGION, - AstraDBAdmin.DEFAULT_KEYSPACE)) { - cqlSession - .execute("SELECT datacenter FROM system.local;") - .one() - .get("datacenter", String.class); - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOMetadataVectorTable.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOMetadataVectorTable.java deleted file mode 100644 index 10561d3c..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CassIOMetadataVectorTable.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.cassio.AnnQuery; -import com.dtsx.astra.sdk.cassio.CassIO; -import com.dtsx.astra.sdk.cassio.MetadataVectorRecord; -import com.dtsx.astra.sdk.cassio.MetadataVectorTable; -import com.dtsx.astra.sdk.utils.TestUtils; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class CassIOMetadataVectorTable { - public static void main(String[] args) { - - // Create db if not exists - UUID databaseId = new AstraDBAdmin("TOKEN") - .createDatabase("database"); - - // Initializing CqlSession - try (CqlSession cqlSession = CassIO.init("TOKEN", - databaseId, TestUtils.TEST_REGION, - AstraDBAdmin.DEFAULT_KEYSPACE)) { - - // Initializing table with the dimension - MetadataVectorTable vector_Store = CassIO - .metadataVectorTable("vector_store", 1536); - vector_Store.create(); - - // Insert Vectors - String partitionId = UUID.randomUUID().toString(); - MetadataVectorRecord record = new MetadataVectorRecord(); - record.setVector(List.of(0.1f, 0.2f, 0.3f, 0.4f)); - record.setMetadata(Map.of("key", "value")); - record.setBody("Sample text fragment"); - record.setAttributes("handy field for special attributes"); - vector_Store.put(record); - - // Semantic Search - AnnQuery query = AnnQuery - .builder() - .embeddings(List.of(0.1f, 0.2f, 0.3f, 0.4f)) - .metaData(Map.of("key", "value")) - .build(); - - vector_Store.similaritySearch(query).forEach(result -> { - System.out.println("Similarity : " + result.getSimilarity()); - System.out.println("Record : " + result.getEmbedded().getBody()); - }); - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ClearCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ClearCollection.java deleted file mode 100644 index 5b5e8dac..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ClearCollection.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; - -public class ClearCollection { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Delete all rows from an existing collection - collection.deleteAll(); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Connecting.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Connecting.java deleted file mode 100644 index 0f047fba..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Connecting.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; - -import java.util.UUID; - -public class Connecting { - public static void main(String[] args) { - // Default initialization - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Initialize with a non-default keyspace - AstraDB db1 = new AstraDB("TOKEN", "API_ENDPOINT", ""); - - // Initialize with an identifier instead of an endpoint - UUID databaseUuid = UUID.fromString(""); - AstraDB db2 = new AstraDB("TOKEN", databaseUuid); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ConnectingAdmin.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ConnectingAdmin.java deleted file mode 100644 index 57b0816e..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ConnectingAdmin.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; - -public class ConnectingAdmin { - public static void main(String[] args) { - // Default Initialization - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - - // You can omit the token if you defined the `ASTRA_DB_APPLICATION_TOKEN` - // environment variable or if you are using the Astra CLI. - AstraDBAdmin defaultClient=new AstraDBAdmin(); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateCollection.java deleted file mode 100644 index b134bd82..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateCollection.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.CollectionDefinition; -import io.stargate.sdk.data.domain.SimilarityMetric; -import io.stargate.sdk.data.exception.DataApiException; - -public class CreateCollection { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Create a non-vector collection - AstraDBCollection collection1 = db.createCollection("collection_simple"); - - // Create a vector collection - AstraDBCollection collection2 = db.createCollection( - "collection_vector1", - 14, - SimilarityMetric.cosine); - - // Create a vector collection with a builder - AstraDBCollection collection3 = db.createCollection(CollectionDefinition - .builder() - .name("collection_vector2") - .vector(1536, SimilarityMetric.euclidean) - .build()); - - // Collection names should use snake case ([a-zA-Z][a-zA-Z0-9_]*) - try { - db.createCollection("invalid.name"); - } catch(DataApiException e) { - // invalid.name is not valid - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateDatabase.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateDatabase.java deleted file mode 100644 index 32576e31..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateDatabase.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import java.util.UUID; - -public class CreateDatabase { - public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - - // Choose a cloud provider (GCP, AZURE, AWS) and a region - CloudProviderType cloudProvider = CloudProviderType.GCP; - String cloudRegion = "us-east1"; - - // Create a database - UUID newDbId = client.createDatabase("", cloudProvider, cloudRegion); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateKeyspace.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateKeyspace.java deleted file mode 100644 index bb1c6d57..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateKeyspace.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; - -public class CreateKeyspace { - - public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - - // Create a Keyspace - client.createKeyspace("", ""); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteCollection.java deleted file mode 100644 index 43d987fc..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteCollection.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; - -public class DeleteCollection { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Delete an existing collection - db.deleteCollection("collection_vector2"); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteDatabase.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteDatabase.java deleted file mode 100644 index 8f3c1e1f..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteDatabase.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; - -import java.util.UUID; - -public class DeleteDatabase { - public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - - // Delete an existing database - client.dropDatabase(""); - - // Delete an existing database by ID - client.dropDatabase( - UUID.fromString("")); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteKeyspace.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteKeyspace.java deleted file mode 100644 index 4e898d8c..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteKeyspace.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; - -public class DeleteKeyspace { - - public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - - // Create a Keyspace - client.deleteKeyspace("", ""); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteMany.java deleted file mode 100644 index bcbc8048..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteMany.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.DeleteQuery; -import io.stargate.sdk.data.domain.query.DeleteResult; - -import static io.stargate.sdk.http.domain.FilterOperator.EQUALS_TO; - -public class DeleteMany { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Build our query - DeleteQuery deleteQuery = DeleteQuery.builder() - .where("product_price", EQUALS_TO, 9.99) - .build(); - - // Deleting only up to 20 record - DeleteResult page = collection - .deleteManyPaged(deleteQuery); - - // Deleting all documents matching query - DeleteResult allDeleted = collection - .deleteMany(deleteQuery); - - // Deleting all documents matching query in distributed way - DeleteResult result = collection - .deleteManyChunked(deleteQuery, 5); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteOne.java deleted file mode 100644 index a8291266..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteOne.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.DeleteQuery; -import io.stargate.sdk.data.domain.query.DeleteResult; - -public class DeleteOne { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Delete items from an existing collection with a query - DeleteResult deletedCount = collection - .deleteOne(DeleteQuery.deleteById("id1")); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Find.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Find.java deleted file mode 100644 index 71ee7993..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Find.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Find { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Retrieve the first document with a product_price - Filter filter = new Filter() - .where("product_price") - .exists(); - collection.find( - SelectQuery.builder().filter(filter).build() - ).forEach(System.out::println); - - // Retrieve the first document where the product_price is 12.99 - Filter filter2 = new Filter() - .where("product_price") - .isEqualsTo(12.99); - collection - .find(SelectQuery.builder().filter(filter2).build()) - .forEach(System.out::println); - - // Only retrieve the product_name and product_price fields - collection.find( - SelectQuery.builder() - .select("product_name", "product_price") - .filter(filter2) - .build()) - .forEach(System.out::println); - - // Order the results by similarity - collection.find( - SelectQuery.builder() - .filter(filter2) - .orderByAnn(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .build()) - .forEach(System.out::println); - - // Order the results by a specific field - Filter filter3 = new Filter() - .where("product_name") - .isEqualsTo("HealthyFresh - Chicken raw dog food"); - collection.find( - SelectQuery.builder() - .filter(filter3) - .orderBy("product_price", 1) - .build()) - .forEach(System.out::println); - - // Complex query with AND and OR: - // (product_price == 9.99 OR product_name == "HealthyFresh - Beef raw dog food") - // AND (product_price == 12.99 OR product_name == "HealthyFresh - Beef raw dog food") - SelectQuery sq2 = new SelectQuery(); - sq2.setFilter(new HashMap<>()); - Map>> or1Criteria = new HashMap<>(); - or1Criteria.put("$or", new ArrayList>()); - or1Criteria.get("$or").add(Map.of("product_price", 9.99)); - or1Criteria.get("$or").add(Map.of("product_name", "HealthyFresh - Beef raw dog food")); - Map>> or2Criteria = new HashMap<>(); - or2Criteria.put("$or", new ArrayList>()); - or2Criteria.get("$or").add(Map.of("product_price", 12.99)); - or2Criteria.get("$or").add(Map.of("product_name", "HealthyFresh - Beef raw dog food")); - List>>> andCriteria = new ArrayList<>(); - andCriteria.add(or1Criteria); - andCriteria.add(or2Criteria); - sq2.getFilter().put("$and", andCriteria); - collection.find(sq2).forEach(System.out::println); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllCollections.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllCollections.java deleted file mode 100644 index 956bf83f..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllCollections.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import io.stargate.sdk.data.domain.CollectionDefinition; - -public class FindAllCollections { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Get Collection Names - db.findAllCollectionsNames().forEach(System.out::println); - - // Iterate over all collections and print each vector definition - db.findAllCollections().forEach(col -> { - System.out.print("\nname=" + col.getName()); - if (col.getOptions() != null && col.getOptions().getVector() != null) { - CollectionDefinition.Options.Vector vector = col.getOptions().getVector(); - System.out.print(", dim=" + vector.getDimension()); - System.out.print(", metric=" + vector.getMetric()); - } - }); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllDatabases.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllDatabases.java deleted file mode 100644 index d4f1c220..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllDatabases.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.db.domain.Database; -import java.util.stream.Stream; - -public class FindAllDatabases { - public static void main(String[] args) { - AstraDBAdmin client = new AstraDBAdmin("TOKEN"); - boolean exists = client.isDatabaseExists(""); - - // List all available databases - Stream dbStream = client.listDatabases(); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindById.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindById.java deleted file mode 100644 index f1eface9..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindById.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import java.util.Optional; - -public class FindById { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // Fetch a document by ID and return it as JSON - Optional res = collection.findById("doc1"); - res.ifPresent(jsonResult -> System.out.println(jsonResult.getSimilarity())); - - // Fetch a document by ID and map it to an object with ResultMapper - Optional> res2 = collection.findById("doc1", record -> { - MyBean bean = new MyBean( - (String) record.getData().get("product_name"), - (Double) record.getData().get("product_price")); - return new DocumentResult<>(record, bean); - }); - - // Fetch a document by ID and map it to a class - Optional> res3 = collection.findById("doc1", MyBean.class); - - // Check if a document exists - boolean exists = collection.isDocumentExists("doc1"); - } - - public static class MyBean { - @JsonProperty("product_name") String name; - @JsonProperty("product_price") Double price; - public MyBean(String name, Double price) { - this.name = name; - this.price = price; - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindByVector.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindByVector.java deleted file mode 100644 index 5d3bf8b9..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindByVector.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.DocumentResult; - -import java.util.Optional; - -public class FindByVector { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // Fetch a row by vector and return JSON - collection - .findOneByVector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .ifPresent(jsonResult -> System.out.println(jsonResult.getSimilarity())); - - // Fetch a row by ID and map it to an object with ResultMapper - Optional> res2 = collection - .findOneByVector( - new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}, - record -> { - MyBean bean = new MyBean( - (String)record.getData().get("product_name"), - (Double)record.getData().get("product_price")); - return new DocumentResult<>(record, bean); - } - ); - - // Fetch a row by ID and map the result to a class - Optional> res3 = collection.findOneByVector( - new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}, - MyBean.class); - } - - public static class MyBean { - @JsonProperty("product_name") String name; - @JsonProperty("product_price") Double price; - public MyBean(String name, Double price) { - this.name = name; - this.price = price; - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindCollection.java deleted file mode 100644 index 9d2bb3e1..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindCollection.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import io.stargate.sdk.data.domain.CollectionDefinition; -import java.util.Optional; - -public class FindCollection { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Find a collection - Optional collection = db.findCollectionByName("collection_vector1"); - - // Check if a collection exists - boolean collectionExists = db.isCollectionExists("collection_vector2"); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindKeyspace.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindKeyspace.java deleted file mode 100644 index 434cc87e..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindKeyspace.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; - -public class FindKeyspace { - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // List all keyspaces in the db - db.findAllKeyspaceNames().forEach(System.out::println); - - // validate is a keyspace exists - boolean ks = db.isKeyspaceExists("keyspace_name"); - - // Show Current keyspace name - String currentKs = db.getCurrentKeyspace(); - - // Switch keyspace if needed - db.changeKeyspace("keyspace_name"); - } -} - diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindMany.java deleted file mode 100644 index e5ca5867..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindMany.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; - -public class FindMany { - public static void main(String[] args) { - AstraDB db = new AstraDB("", ""); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - - - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindOne.java deleted file mode 100644 index 7fc74bcf..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindOne.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; - -import static io.stargate.sdk.http.domain.FilterOperator.EQUALS_TO; - -public class FindOne { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Retrieve the first document where product_price exists - Filter filter = new Filter() - .where("product_price") - .exists(); - collection.findOne(SelectQuery.builder() - .filter(filter).build()) - .ifPresent(System.out::println); - - // Retrieve the first document where product_price is 12.99 - Filter filter2 = new Filter() - .where("product_price") - .isEqualsTo(12.99); - collection.findOne(SelectQuery.builder() - .filter(filter2).build()) - .ifPresent(System.out::println); - - // Send the request as a JSON String - collection.findOne( - "{" + - "\"filter\":{" + - "\"product_price\":9.99," + - "\"product_name\":\"HealthyFresh - Chicken raw dog food\"}" + - "}") - .ifPresent(System.out::println); - - // Only retrieve the product_name and product_price fields - collection.findOne(SelectQuery.builder() - .select("product_name", "product_price") - .filter(filter2) - .build()) - .ifPresent(System.out::println); - - // Perform a similarity search - collection.findOne(SelectQuery.builder() - .filter(filter2) - .orderByAnn(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .build()); - - // Perform a complex query with AND and OR - SelectQuery sq2 = new SelectQuery(); - Filter yaFilter = new Filter() - .and() - .or() - .where("product_price", EQUALS_TO, 9.99) - .where("product_name", EQUALS_TO, "HealthyFresh - Beef raw dog food") - .end() - .or() - .where("product_price", EQUALS_TO, 9.99) - .where("product_name", EQUALS_TO, "HealthyFresh - Beef raw dog food") - .end(); - collection.findOne(sq2).ifPresent(System.out::println); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindPage.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindPage.java deleted file mode 100644 index 6ace7b3b..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindPage.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.core.domain.Page; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; - -public class FindPage { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Retrieve page 1 of a search (up to 20 results) - Filter filter = new Filter() - .where("product_price") - .exists(); - Page page1 = collection.findPage( - SelectQuery.builder() - .filter(filter) - .build()); - - // Retrieve page 2 of the same search (if there are more than 20 results) - Filter filter2 = new Filter() - .where("product_price") - .isEqualsTo(12.99); - page1.getPageState().ifPresent(pageState -> { - Page page2 = collection.findPage( - SelectQuery.builder() - .filter(filter2) - .withPagingState(pageState) - .build()); - }); - - // You can map the output as Result using either a Java pojo or mapper - Page> page = collection.findPage( - SelectQuery.builder().filter(filter2).build(), - MyBean.class); - } - - public static class MyBean { - @JsonProperty("product_name") String name; - @JsonProperty("product_price") Double price; - - public MyBean(String name, Double price) { - this.name = name; - this.price = price; - } - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindVector.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindVector.java deleted file mode 100644 index 41f44ca4..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindVector.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import java.util.stream.Stream; - -public class FindVector { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - float[] embeddings = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - int maxRecord = 10; - - // Retrieve all document with product price based on the ann search - collection.findVector(SelectQuery.builder() - .filter(metadataFilter) - .orderByAnn(embeddings) - .withLimit(maxRecord) - .build()) - .forEach(System.out::println); - - // Same using another signature - Stream result = collection.findVector(embeddings, metadataFilter, maxRecord); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertMany.java deleted file mode 100644 index cb6e492f..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertMany.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import io.stargate.sdk.data.domain.JsonDocument; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class InsertMany { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1",14); - - // Insert documents into the collection (IDs are generated automatically) - List identifiers = collection.insertManyJsonDocuments(List.of( - new JsonDocument() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "Yet another product") - .put("product_price", 99.99), - new JsonDocument() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "product3") - .put("product_price", 99.99))); - - // Insert large collection of documents - List largeList = IntStream - .rangeClosed(1, 1000) - .mapToObj(id -> new JsonDocument() - .id(String.valueOf(id)) - .put("sampleKey", id)) - .collect(Collectors.toList()); - int chunkSize = 20; // In between 1 and 20 - int threadCount = 10; // How many chunks processed in parallel - List result = collection - .insertManyChunkedJsonDocuments(largeList, chunkSize, threadCount); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertOne.java deleted file mode 100644 index e22d14cc..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertOne.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import io.stargate.sdk.data.domain.JsonDocument; -import java.util.Map; - -public class InsertOne { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Assumes a collection with a vector field of dimension 14 - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // You must delete any existing rows with the same IDs as the - // rows you want to insert - collection.deleteAll(); - - // Insert rows defined by key/value - collection.insertOne( - new JsonDocument() - .id("doc1") // uuid is generated if not explicitely set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99)); - - // Insert rows defined as a JSON String - collection.insertOne( - new JsonDocument() - .data( - "{" + - "\"_id\": \"doc2\", " + - "\"$vector\": [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], " + - "\"product_name\": \"HealthyFresh - Chicken raw dog food\", " + - "\"product_price\": 9.99" + - "}")); - - // Insert rows defined as a Map Asynchronously - collection.insertOneASync( - new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food"))); - - // If you do not provide an ID, they are generated automatically - JsonDocumentMutationResult result = collection.insertOne( - new JsonDocument().put("demo", 1)); - String generatedId = result.getDocument().getId(); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingClearCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingClearCollection.java deleted file mode 100644 index 94a1f4ef..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingClearCollection.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ObjectMappingClearCollection { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository collection1 = - db.createCollection("collection_simple", Product.class); - - // Delete all rows in a collection - collection1.deleteAll(); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingCreateCollection.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingCreateCollection.java deleted file mode 100644 index a5e4ebdf..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingCreateCollection.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.CollectionDefinition; -import io.stargate.sdk.data.domain.SimilarityMetric; - -public class ObjectMappingCreateCollection { - - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Create a non-vector collection - AstraDBRepository collection1 = - db.createCollection("collection_simple", Product.class); - - // Create a vector collection with a builder - AstraDBRepository collection2 = - db.createCollection( - CollectionDefinition.builder() - .name("collection_vector2") - .vector(1536, SimilarityMetric.euclidean) - .build(), - Product.class); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteMany.java deleted file mode 100644 index f438b3b7..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteMany.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.query.DeleteQuery; -import io.stargate.sdk.data.domain.query.DeleteResult; - -import static io.stargate.sdk.http.domain.FilterOperator.EQUALS_TO; - -public class ObjectMappingDeleteMany { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Create a vector collection - AstraDBRepository collection1 = - db.createCollection("collection_simple", Product.class); - - // Delete rows based on a query - DeleteQuery q = DeleteQuery.builder() - .where("product_price", EQUALS_TO, 9.99) - .build(); - DeleteResult res = collection1.deleteAll(q); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteOne.java deleted file mode 100644 index 4322a715..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteOne.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.Document; - -public class ObjectMappingDeleteOne { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository collection1 = - db.createCollection("collection_simple", Product.class); - - // Delete a document by ID - collection1.deleteById("id1"); - - // Delete a specific document - collection1.delete(new Document().id("id2")); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFind.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFind.java deleted file mode 100644 index 591485b7..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFind.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ObjectMappingFind { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.createCollection("collection_vector1", 14); - - // Retrieve the first document with a product_price - Filter filter = new Filter() - .where("product_price") - .exists(); - collection.find( - SelectQuery.builder() - .filter(filter) - .build()) - .forEach(System.out::println); - - // Retrieve the first document where product_price is 12.99 - Filter filter2 = new Filter() - .where("product_price") - .isEqualsTo(12.99); - collection.find( - SelectQuery.builder() - .filter(filter2) - .build()) - .forEach(System.out::println); - - // Only retrieve the product_name and product_price fields - collection.find( - SelectQuery.builder() - .select("product_name", "product_price") - .filter(filter2) - .build()) - .forEach(System.out::println); - - // Order the results by similarity - collection.find( - SelectQuery.builder() - .filter(filter2) - .orderByAnn(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .build()) - .forEach(System.out::println); - - // Order the results by a specific field - collection.find( - SelectQuery.builder() - .filter(filter2) - .orderBy("product_price", 1) - .build()) - .forEach(System.out::println); - - // Complex query with AND and OR: - // (product_price == 9.99 OR product_name == "HealthyFresh - Beef raw dog food") - // AND (product_price == 12.99 OR product_name == "HealthyFresh - Beef raw dog food") - SelectQuery sq2 = new SelectQuery(); - sq2.setFilter(new HashMap<>()); - Map>> or1Criteria = new HashMap<>(); - or1Criteria.put("$or", new ArrayList>()); - or1Criteria.get("$or").add(Map.of("product_price", 9.99)); - or1Criteria.get("$or").add(Map.of("product_name", "HealthyFresh - Beef raw dog food")); - Map>> or2Criteria = new HashMap<>(); - or2Criteria.put("$or", new ArrayList>()); - or2Criteria.get("$or").add(Map.of("product_price", 12.99)); - or2Criteria.get("$or").add(Map.of("product_name", "HealthyFresh - Beef raw dog food")); - List>>> andCriteria = new ArrayList<>(); - andCriteria.add(or1Criteria); - andCriteria.add(or2Criteria); - sq2.getFilter().put("$and", andCriteria); - collection.find(sq2).forEach(System.out::println); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindOne.java deleted file mode 100644 index f97dc327..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindOne.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import java.util.Optional; - -public class ObjectMappingFindOne { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Retrieve a products from its id - Optional> res1 = productRepository.findById("id1"); - - // Retrieve a product from its vector - float[] vector = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Optional> res2 = productRepository.findByVector(vector); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindVector.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindVector.java deleted file mode 100644 index 55170779..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindVector.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import io.stargate.sdk.data.domain.query.Filter; - -import java.util.List; - -public class ObjectMappingFindVector { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Perform a semantic search - float[] embeddings = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - int maxRecord = 10; - List> res = productRepository.findVector(embeddings, metadataFilter, maxRecord); - - // If you do not have max record or metadata filter, you can use the following - productRepository.findVector(embeddings, maxRecord); - productRepository.findVector(embeddings, metadataFilter); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertMany.java deleted file mode 100644 index 97bbb4bc..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertMany.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.DocumentMutationResult; -import io.stargate.sdk.data.domain.odm.Document; -import java.util.List; - -public class ObjectMappingInsertMany { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - Product(String name, Double price) { - this.name = name; - this.price = price; - } - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Insert documents into the collection (IDs are generated automatically) - List> identifiers = productRepository.saveAll( - List.of( - new Document() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product1", 9.99)), - new Document() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product2", 12.99)))); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertOne.java deleted file mode 100644 index 8658208a..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertOne.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.Document; - -public class ObjectMappingInsertOne { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - Product(String name, Double price) { - this.name = name; - this.price = price; - } - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Upsert document - productRepository.save(new Document() - .id("product1") - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product1", 9.99))); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingPaging.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingPaging.java deleted file mode 100644 index e9c8bde8..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingPaging.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.core.domain.Page; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.odm.DocumentResult; - -public class ObjectMappingPaging { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - } - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Retrieve page 1 of a search (up to 20 results) - float[] embeddings = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - Page> page1 = productRepository.findVector(embeddings, metadataFilter); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateMany.java deleted file mode 100644 index ed934457..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateMany.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.DocumentMutationResult; -import io.stargate.sdk.data.domain.odm.Document; -import java.util.List; - -public class ObjectMappingUpdateMany { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - Product(String name, Double price) { - this.name = name; - this.price = price; - } - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Insert documents into the collection (IDs are generated automatically) - List> identifiers = productRepository.saveAll( - List.of( - new Document() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product1", 9.99)), - new Document() - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product2", 12.99)))); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateOne.java deleted file mode 100644 index 3cbc4191..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateOne.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.odm.Document; - -public class ObjectMappingUpdateOne { - static class Product { - @JsonProperty("product_name") private String name; - @JsonProperty("product_price") private Double price; - Product(String name, Double price) { - this.name = name; - this.price = price; - } - } - - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBRepository productRepository = - db.createCollection("collection_vector1", 14, Product.class); - - // Upsert a document - productRepository.save(new Document() - .id("product1") - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(new Product("product1", 9.99))); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStart.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStart.java deleted file mode 100644 index c78caaac..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStart.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentResult; - -import java.util.Map; -import java.util.stream.Stream; - -public class QuickStart { - public static void main(String[] args) { - - // Initialize the client - AstraDB myDb = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Create a collection - AstraDBCollection demoCollection = myDb.createCollection("demo",14); - - // Insert vectors - demoCollection.insertOne( - new JsonDocument() - .id("doc1") // generated if not set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99)); - demoCollection.insertOne( - new JsonDocument() - .id("doc2") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)); - demoCollection.insertOne( - new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food"))); - demoCollection.insertOne( - new JsonDocument() - .id("doc4") - .vector(new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)); - - // Perform a similarity search - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - int maxRecord = 10; - long top = System.currentTimeMillis(); - Stream resultsSet = demoCollection.findVector(embeddings, metadataFilter, maxRecord); - System.out.println(System.currentTimeMillis() - top); - - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStartAA.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStartAA.java deleted file mode 100644 index c3136ba4..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/QuickStartAA.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraDBCollection; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.query.Filter; - -import java.util.List; -import java.util.stream.Stream; - -public class QuickStartAA { - - public static void main(String[] args) { - - // Organization level token as describe in pre-requisites - AstraDBAdmin astraDBAdmin = new AstraDBAdmin(""); - - // Create a Database if needed - astraDBAdmin.createDatabase("quickstart", CloudProviderType.GCP, "us-east-1"); - - // Accessing the database - AstraDB myDb = astraDBAdmin.getDatabase("quickstart"); - - // Create a collection - AstraDBCollection demoCollection = myDb.createCollection("demo",14); - - // Insertions - demoCollection.insertManyJsonDocuments(List.of( - new JsonDocument() - .id("doc1") // generated if not set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99), - new JsonDocument() - .id("doc2") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)) - ); - - // Search - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter() - .where("product_price").isEqualsTo(9.99); - int maxRecord = 10; - Stream resultsSet = demoCollection. - findVector(embeddings, metadataFilter, maxRecord); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateMany.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateMany.java deleted file mode 100644 index 90928299..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateMany.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.UpdateQuery; -import io.stargate.sdk.http.domain.FilterOperator; - -public class UpdateMany { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // Update multiple documents based on a query - collection.updateMany(UpdateQuery.builder() - .updateSet("product_name", 12.99) - .filter(new Filter("product_name", FilterOperator.EQUALS_TO, "HealthyFresh - Beef raw dog food")) - .build()); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateOne.java deleted file mode 100644 index 41f4a92c..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateOne.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.query.UpdateQuery; - -import static io.stargate.sdk.http.domain.FilterOperator.EQUALS_TO; - -public class UpdateOne { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // You must delete any existing rows with the same IDs as the - // rows you want to insert - collection.deleteAll(); - - // Upsert a document based on a query - collection.updateOne(UpdateQuery.builder() - .updateSet("product_name", 12.99) - .where("product_name", EQUALS_TO, "HealthyFresh - Beef raw dog food") - .build()); - - // Upsert a document by ID - collection.upsertOne(new JsonDocument() - .id("id1") - .put("product_name", 12.99)); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpsertOne.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpsertOne.java deleted file mode 100644 index a70d23ec..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpsertOne.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.dtsx.astra.sdk.documentation; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBCollection; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import org.junit.jupiter.api.Assertions; - -import static io.stargate.sdk.data.domain.DocumentMutationStatus.CREATED; -import static io.stargate.sdk.data.domain.DocumentMutationStatus.UNCHANGED; -import static io.stargate.sdk.data.domain.DocumentMutationStatus.UPDATED; - -public class UpsertOne { - public static void main(String[] args) { - AstraDB db = new AstraDB("TOKEN", "API_ENDPOINT"); - - // Assumes a collection with a vector field of dimension 14 - AstraDBCollection collection = db.getCollection("collection_vector1"); - - // Insert rows defined by key/value - JsonDocument doc1 = new JsonDocument() - .id("doc1") // uuid is generated if not explicitely set - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99); - - // Create the document - JsonDocumentMutationResult res1 = collection.upsertOne(doc1); - Assertions.assertEquals(CREATED, res1.getStatus()); - - // Nothing happened - JsonDocumentMutationResult res2 = collection.upsertOne(doc1); - Assertions.assertEquals(UNCHANGED, res1.getStatus()); - - // Document is updated (async) - doc1.put("new_property", "value"); - collection.upsertOneASync(doc1).thenAccept(res -> - Assertions.assertEquals(UPDATED, res.getStatus())); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBDemoTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBDemoTest.java deleted file mode 100644 index 9d725356..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBDemoTest.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.dtsx.astra.sdk.vector; - -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraDBTestSuiteIT; -import io.stargate.sdk.core.domain.Page; -import io.stargate.sdk.data.CollectionClient; -import io.stargate.sdk.data.domain.JsonDocumentMutationResult; -import io.stargate.sdk.data.NamespaceClient; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.JsonDocumentResult; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.query.SelectQuery; -import io.stargate.sdk.data.domain.query.UpdateQuery; -import io.stargate.sdk.data.domain.query.UpdateQueryBuilder; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -/** - * Demo using Json client - */ -public class AstraDBDemoTest { - - @Test - public void shouldDoCollection() { - - // Token retrieved from CLI config or env var - AstraDBAdmin astraDBAdmin = new AstraDBAdmin(); - - // Create Database - UUID uuid = astraDBAdmin.createDatabase(AstraDBTestSuiteIT.TEST_DBNAME); - - // Select Database / Namespace - NamespaceClient db = astraDBAdmin - .getDataApiClient(AstraDBTestSuiteIT.TEST_DBNAME) - .namespace("default_keyspace"); - - // Create a collection - db.deleteCollection("collection_test"); - db.createCollection("collection_test", 5); - - // User the collection - CollectionClient collection = db.collection("collection_test"); - - // # Insert into vector collection - collection.insertOne(new JsonDocument().id("4") - .put("name", "Coded Cleats Copy") - .put("description", "ChatGPT integrated sneakers that talk to you") - .vector(new float[]{0.25f, 0.25f, 0.25f, 0.25f, 0.25f})); - // # Insert non-vector document - collection.insertOne(new JsonDocument().id("Cliff1") - .put("first_name", "Cliff") - .put("last_name", "Wicklow")); - - // Insert Many document - List docs = collection.insertManyJsonDocuments(List.of( - new JsonDocument().id("1") - .vector(new float[]{0.1f, 0.15f, 0.3f, 0.12f, 0.05f}) - .put("name", "Coded Cleats") - .put("description", "ChatGPT integrated sneakers that talk to you"), - new JsonDocument().id("2") - .vector(new float[]{0.45f, 0.09f, 0.01f, 0.2f, 0.11f}) - .put("name", "Logic Layers") - .put("description", "An AI quilt to help you sleep forever"), - new JsonDocument().id("3") - .vector(new float[]{0.1f, 0.05f, 0.08f, 0.3f, 0.6f}) - .put("name", "Vision Vector Frame") - .put("description", "Vision Vector Frame - A deep learning display that controls your mood") - )); - - // Find a document - Filter filter = new Filter().where("_id").isEqualsTo("4"); - Optional doc1 = collection.findOne(SelectQuery.builder().filter(filter).build()); - Optional doc2 = collection.findById("4"); - doc2.ifPresent(this::showResult); - - // Find documents using vector search - Filter filterVector = new Filter().where("$vector").isEqualsTo(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}); - Page results = collection.findPage( - SelectQuery.builder().filter(filterVector) - // best way to do it below - //.orderByAnn(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}) - .withLimit(2) - .build()); - System.out.println(results.getResults().get(0).getData().get("name")); - System.out.println(results.getResults().size()); - showPage(results); - - /** - * Find documents using vector search and projection. - * - * sort = {"$vector": [0.15, 0.1, 0.1, 0.35, 0.55]} - * options = {"limit": 100} - * projection = {"$vector": 1, "$similarity": 1} - */ - Page results2 = collection.findPage( - SelectQuery.builder() - .orderByAnn(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}) - .withLimit(2) - .includeSimilarity() - .build()); - showPage(results2); - - /** - * Find one document using vector search and projection - * - * sort = {"$vector": [0.15, 0.1, 0.1, 0.35, 0.55]} - * projection = {"$vector": 1} - */ - Optional doc3 = collection.findOne(SelectQuery.builder() - .orderByAnn(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}) - .build()); - doc3.ifPresent(this::showResult); - - /** - * Find one and update with vector search - * - * sort = {"$vector": [0.15, 0.1, 0.1, 0.35, 0.55]} - * update = {"$set": {"status": "active"}} - * options = {"returnDocument": "after"} - */ - collection.findOneAndUpdate(UpdateQuery.builder() - .updateSet("status", "active") - .orderByAnn(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}) - .withReturnDocument(UpdateQueryBuilder.ReturnDocument.after) - .build()); - Filter filter3 = new Filter().where("status").isEqualsTo("active"); - Optional result = collection.findOne(SelectQuery.builder() - .filter(filter3) - .build()); - result.ifPresent(this::showResult); - - /** - * Find one and replace with vector search - * - * sort = ({"$vector": [0.15, 0.1, 0.1, 0.35, 0.55]},) - * replacement = { - * "_id": "3", - * "name": "Vision Vector Frame", - * "description": "Vision Vector Frame - A deep learning display that controls your mood", - * "$vector": [0.1, 0.05, 0.08, 0.3, 0.6], - * "status": "inactive", - * } - * options = {"returnDocument": "after"} - */ - collection.findOneAndReplace(UpdateQuery.builder() - .replaceBy(new JsonDocument().id("3") - .vector(new float[]{0.1f, 0.05f, 0.08f, 0.3f, 0.6f}) - .put("name", "Vision Vector Frame") - .put("description", "Vision Vector Frame - A deep learning display that controls your mood") - .put("status", "inactive")) - .orderByAnn(new float[]{0.15f, 0.1f, 0.1f, 0.35f, 0.55f}) - .withReturnDocument(UpdateQueryBuilder.ReturnDocument.after) - .build()); - Filter filter4 = new Filter().where("name").isEqualsTo("Vision Vector Frame"); - Optional result2 = collection.findOne(SelectQuery.builder() - .filter(filter4) - .build()); - result2.ifPresent(this::showResult); - } - - private void showPage(Page page) { - if (page != null) { - System.out.println("Page size: " + page.getPageSize()); - System.out.println("Page state: " + page.getPageState()); - System.out.println("Page results: " + page.getResults().size()); - page.getResults().forEach(this::showResult); - } - } - - private void showResult(JsonDocumentResult r) { - String row = r.getId() + " - "; - if (r.getSimilarity() != null) { - row += r.getSimilarity() + " - "; - } - System.out.println(row + r.getData() + " " + Arrays.toString(r.getVector())); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBQuickStart.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBQuickStart.java deleted file mode 100644 index c46bef61..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraDBQuickStart.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.dtsx.astra.sdk.vector; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraDBCollection; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.dtsx.astra.sdk.AstraDBTestSuiteIT; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.JsonDocument; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.Map; - -public class AstraDBQuickStart { - - @Test - public void quickStartTest() { - String astraToken = System.getenv("ASTRA_DB_APPLICATION_TOKEN"); - String databaseName = AstraDBTestSuiteIT.TEST_DBNAME; - String collectionName = "collection_quickstart"; - - // 1a. Initialization with a client - AstraDBAdmin astraDBAdmin = new AstraDBAdmin(astraToken); - // 1b. Create DB (Skip if you already have a database running) - if (!astraDBAdmin.isDatabaseExists(databaseName)) { - astraDBAdmin.createDatabase(databaseName); - } - - // 2. Create a store (delete if exist) - AstraDB astraDB = astraDBAdmin.getDatabase(databaseName); - // 3. Insert data in the store - astraDB.deleteCollection(collectionName); - AstraDBCollection collection = astraDB.createCollection(collectionName, 14); - // 3a. Insert One (attributes as key/value) - collection.insertOne(new JsonDocument() - .id("doc1") // generated if not set - .vector(new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .put("product_name", "HealthyFresh - Beef raw dog food") - .put("product_price", 12.99)); - // 3b. Insert One (attributes as JSON) - collection.insertOne(new JsonDocument() - .id("doc2") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data("{" - +" \"product_name\": \"HealthyFresh - Chicken raw dog food\", " - + " \"product_price\": 9.99" - + "}") - ); - // 3c. Insert One (attributes as a MAP) - collection.insertOne(new JsonDocument() - .id("doc3") - .vector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}) - .data(Map.of("product_name", "HealthyFresh - Chicken raw dog food")) - ); - // 3d. Insert as a single Big JSON - collection.insertOne(new JsonDocument() - .id("doc4") - .vector(new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}) - .put("product_name", "HealthyFresh - Chicken raw dog food") - .put("product_price", 9.99)); - collection.findVector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}); - - // ------------------------------------------ - // ----- Crud Repository ---- - // ------------------------------------------ - - // With ODM - AstraDBRepository productRepository = - astraDB.getCollection(collectionName, Product.class); - - // 3 fields: id, payload, vector - productRepository.insert(new Document<>("doc5", - new Product("HealthyFresh - Beef raw dog food", 12.99), - new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f})); - - // build the "document" and insert the document - Document doc6 = new Document<>("doc6", - new Product("HealthyFresh - Beef raw dog food", 12.99), - new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}); - productRepository.insert(doc6); - - Assertions.assertEquals(6, productRepository.count()); - - List> results = productRepository - .findVector(new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}, null, 2); - } - - @Data - @NoArgsConstructor - @AllArgsConstructor - static class Product { - @JsonProperty("product_name") - private String name; - @JsonProperty("product_price") - private Double price; - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraUIQuickStart.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraUIQuickStart.java deleted file mode 100644 index eaf15c74..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/AstraUIQuickStart.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dtsx.astra.sdk.vector; - -import com.dtsx.astra.sdk.AstraDB; -import io.stargate.sdk.data.domain.CollectionDefinition; - -public class AstraUIQuickStart { - public static void main(String[] args) { - AstraDB db = new AstraDB("", ""); - System.out.println("Connected to AstraDB"); - db.findAllCollections() - .map(CollectionDefinition::getName) - .forEach(col -> System.out.println("Collection:" + col)); - } -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientPhilosopherTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientPhilosopherTest.java deleted file mode 100644 index 7f8c6f58..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientPhilosopherTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.dtsx.astra.sdk.vector; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.dtsx.astra.sdk.utils.AstraRc; -import dev.langchain4j.model.openai.OpenAiEmbeddingModel; -import dev.langchain4j.model.openai.OpenAiModelName; -import io.stargate.sdk.data.domain.odm.Document; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; - -import java.io.File; -import java.io.FileNotFoundException; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Scanner; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -@Slf4j -class VectorClientPhilosopherTest { - - static final String DBNAME_VECTOR_CLIENT = "test_java_astra_db_client"; - static final String VECTOR_STORE_NAME = "demo_philosophers"; - static final String DATASET = "/philosopher-quotes.csv"; - - @Data @AllArgsConstructor @NoArgsConstructor - static class Quote { - private String philosopher; - private String quote; - private Set tags; - } - - static AstraDBRepository quoteRepository; - - static OpenAiEmbeddingModel openaiVectorizer = OpenAiEmbeddingModel.builder() - .apiKey(System.getenv("OPENAI_API_KEY")) - .modelName(OpenAiModelName.TEXT_EMBEDDING_ADA_002) - .timeout(Duration.ofSeconds(15)) - .logRequests(true) - .logResponses(true) - .build(); - - static float[] vectorize(String inputText) { - return openaiVectorizer.embed(inputText).content().vector(); - } - - @BeforeAll - public static void setup() { - if (System.getenv(AstraRc.ASTRA_DB_APPLICATION_TOKEN) == null) { - throw new IllegalStateException("Please setup 'ASTRA_DB_APPLICATION_TOKEN' env variable"); - } - new AstraDBAdmin().createDatabase(DBNAME_VECTOR_CLIENT); - log.info("db is created and active"); - } - - @Test - @Order(1) - @DisplayName("01. Import Data") - @EnabledIfEnvironmentVariable(named = "ASTRA_DB_APPLICATION_TOKEN", matches = "Astra.*") - public void shouldIngestCsv() { - // Init the Store - AstraDB dbClient = new AstraDBAdmin().getDatabase(DBNAME_VECTOR_CLIENT); - dbClient.deleteCollection(VECTOR_STORE_NAME); - quoteRepository = dbClient.createCollection(VECTOR_STORE_NAME, 1536, Quote.class); - log.info("store {} is created ", VECTOR_STORE_NAME); - assertTrue(dbClient.isCollectionExists(VECTOR_STORE_NAME)); - - // Populate the Store - AtomicInteger rowId = new AtomicInteger(); - loadQuotesFromCsv(DATASET).forEach(quote -> { - log.info("Inserting {}: {}", rowId.get(), quote.getQuote()); - Document quoteDoc = new Document( - String.valueOf(rowId.incrementAndGet()), - quote, - vectorize(quote.getQuote())); - quoteRepository.insert(quoteDoc); - }); - } - - @Test - @Order(2) - @DisplayName("02. Should Similarity Search") - public void shouldSimilaritySearch() { - - quoteRepository = new AstraDBAdmin() - .getDatabase(DBNAME_VECTOR_CLIENT) - .getCollection(VECTOR_STORE_NAME, Quote.class); - - float[] embeddings = vectorize("We struggle all our life for nothing"); - quoteRepository.findVector(embeddings,3) - .stream() - .map(Document::getData) - .map(Quote::getQuote) - .forEach(System.out::println); - } - - - // --- Utilities (loading CSV) --- - - private List loadQuotesFromCsv(String filePath) { - List quotes = new ArrayList<>(); - File csvFile = new File(VectorClientPhilosopherTest.class.getResource(filePath).getFile()); - try (Scanner scanner = new Scanner(csvFile)) { - while (scanner.hasNextLine()) { - Quote q = mapCsvLine(scanner.nextLine()); - if (q != null) quotes.add(q); - } - } catch (FileNotFoundException fex) { - throw new IllegalArgumentException("file is not in the classpath", fex); - } - return quotes; - } - - private Quote mapCsvLine(String line) { - String[] parts = line.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1); - if (parts.length >= 3) { - String author = parts[0]; - String quote = parts[1].replaceAll("\"", ""); - Set tags = new HashSet<>(Arrays.asList(parts[2].split("\\;"))); - return new Quote(author, quote, tags); - } - return null; - } - - -} diff --git a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientProductTest.java b/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientProductTest.java deleted file mode 100644 index 630c47ce..00000000 --- a/astra-db-client/src/test/java/com/dtsx/astra/sdk/vector/VectorClientProductTest.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.dtsx.astra.sdk.vector; - -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraDBRepository; -import com.dtsx.astra.sdk.utils.AstraRc; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.stargate.sdk.data.domain.query.Filter; -import io.stargate.sdk.data.domain.odm.Document; -import io.stargate.sdk.data.domain.odm.DocumentResult; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; - -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test the Vector Store Client with no third party embeddings. - */ -@Slf4j -class VectorClientProductTest { - - public static final String DBNAME_VECTOR_CLIENT = "test_java_astra_db_client"; - - public static final String VECTOR_STORE_NAME = "demo_product"; - - @Data - @NoArgsConstructor - @AllArgsConstructor - static class Product { - - @JsonProperty("product_name") - private String name; - - @JsonProperty("product_price") - private Double price; - } - - static AstraDBRepository productRepository; - - @BeforeAll - public static void setup() { - if (System.getenv(AstraRc.ASTRA_DB_APPLICATION_TOKEN) == null) { - throw new IllegalStateException("Please setup 'ASTRA_DB_APPLICATION_TOKEN' env variable"); - } - AstraDBAdmin vectorClient = new AstraDBAdmin(); - UUID databaseId = vectorClient.createDatabase(DBNAME_VECTOR_CLIENT); - log.info("{} is created and active", databaseId); - } - - @Test - @Order(1) - @DisplayName("01. Import Data") - @EnabledIfEnvironmentVariable(named = "ASTRA_DB_APPLICATION_TOKEN", matches = "Astra.*") - public void shouldInsertStaticDocument() { - // Recreating the store - AstraDB astraDB = new AstraDBAdmin().getDatabase(DBNAME_VECTOR_CLIENT); - astraDB.deleteCollection(VECTOR_STORE_NAME); - productRepository = astraDB.createCollection(VECTOR_STORE_NAME, 14, Product.class); - log.info("store {} is created ", VECTOR_STORE_NAME); - assertTrue(astraDB.isCollectionExists(VECTOR_STORE_NAME)); - - // Easy insert one - Document doc = new Document<>("pf7044", - new Product("Pupper Sausage Beef dog Treats", 9.99), - new float[]{0f, 0f, 0f, 1f, 0f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 0f}); - productRepository.insert(doc); - // Easy insert many - productRepository.insert(List.of( - new Document<>("pt0041", - new Product("Dog Ring Chew Toy", 9.99), - new float[]{0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f, 1f, 1f, 0f, 0f, 0f, 0f}), - new Document<>("pf7043", - new Product("Pepper Sausage Bacon dog Treats", 9.99), - new float[]{0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f, 1f, 1f, 0f, 0f, 0f, 0f}) - )); - // Insert Many with Json - productRepository.saveAll(List.of( - new Document<>("pf1844", - new Product("HealthyFresh - Beef raw dog food", 12.99), - new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}), - new Document<>("pf1843", - new Product("HealthyFresh - Beef raw dog food", 12.99), - new float[]{1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}), - new Document() - .id("pt0021") - .data(new Product("Dog Tennis Ball Toy", 12.99)) - .vector(new float[]{0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 0f, 1f, 1f, 1f, 0f, 0f})) - ); - assertEquals(6, productRepository.count()); - assertEquals(3, productRepository.count(new Filter() - .where("product_price").isEqualsTo(9.99))); - } - - @Test - @Order(2) - @DisplayName("02. Similarity Search") - public void shouldSimilaritySearch() { - - productRepository = new AstraDBAdmin() - .getDatabase(DBNAME_VECTOR_CLIENT) - .getCollection(VECTOR_STORE_NAME, Product.class); - - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - for(DocumentResult result : productRepository.findVector(embeddings,null, 2)) { - System.out.println(result.getId() - + ") similarity=" + result.getSimilarity() - + ", vector=" + Arrays.toString(result.getVector())); - } - } - - @Test - @Order(3) - @DisplayName("03. Search with Meta Data") - public void shouldSimilaritySearchWithMetaData() { - productRepository = new AstraDBAdmin() - .getDatabase(DBNAME_VECTOR_CLIENT) - .getCollection(VECTOR_STORE_NAME, Product.class); - - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - - for(DocumentResult result : productRepository - .findVector(embeddings, metadataFilter, 2)) { - System.out.println(result.getId() - + ") similarity=" + result.getSimilarity() - + ", vector=" + Arrays.toString(result.getVector())); - } - - } - - @Test - @Order(4) - @DisplayName("04. Search with Meta Data") - public void shouldSimilaritySearcAndNotReturnVector() { - productRepository = new AstraDBAdmin() - .getDatabase(DBNAME_VECTOR_CLIENT) - .getCollection(VECTOR_STORE_NAME, Product.class); - - float[] embeddings = new float[] {1f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}; - Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99); - new Filter().where("product_price").isEqualsTo(9.99); - - for(DocumentResult result : productRepository - .findVector(embeddings, metadataFilter, 2)) { - System.out.println(result.getId() - + ") similarity=" + result.getSimilarity() - + ", vector=" + Arrays.toString(result.getVector())); - } - - } - -} diff --git a/astra-db-client/src/test/resources/documentation.asciidoc b/astra-db-client/src/test/resources/documentation.asciidoc deleted file mode 100644 index 1499be63..00000000 --- a/astra-db-client/src/test/resources/documentation.asciidoc +++ /dev/null @@ -1,1433 +0,0 @@ -= Java client reference -:navtitle: Java reference -:page-toclevels: 3 - -Astra SDK Java is the official Java client for {product}. -See common usages below, or check out the https://github.com/datastax/astra-sdk-java[GitHub repo]. - -[.ds-feature-buttons] -xref:astra-api-docs:ROOT:attachment$java-client/com/dtsx/astra/sdk/package-summary.html[API reference,role="ds-button ds-button\--color-primary ds-button\--variant-solid"] - -== Prerequisites - -The code samples on this page assume the following: - -* You have an active https://astra.datastax.com/signup[Astra account^]. -* You have created an xref:administration:manage-application-tokens.adoc[application token] with the Database Administrator role. -* You have installed Java 11+. - -== Databases - -Use the `AstraDBAdmin` and `AstraDB` classes to work with databases. - -=== Connect to Astra - -Connect to Astra by initializing the `AstraDBAdmin` class. - -[source,java] ----- -AstraDBAdmin(); -AstraDBAdmin(String token); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `token` -| `String` -| The authentication token used to access AstraDB. This is optional if the `ASTRA_DB_APPLICATION_TOKEN` environment variable is set or the Astra CLI is used. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ConnectingAdmin.java[] ----- - -=== Connect to a database - -Connect to a database by initializing the `AstraDB` class. - -[source,java] ----- -AstraDB(String token, String apiEndpoint); -AstraDB(String token, String apiEndpoint, String keyspace); -AstraDB(String token, UUID databaseId); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `token` -| `String` -| The authentication token used to access AstraDB. - -| `apiEndpoint` -| `String` -| The API endpoint for the AstraDB instance. - -| `keyspace` -| `String` -| The keyspace to use, if not provided default is `default_keyspace` - -| `databaseId` -| `UUID` -| The database identifier. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Connecting.java[] ----- - -=== Create a database - -Create a database with the `AstraDBAdmin.createDatabase` method. - -[source,java] ----- -UUID createDatabase(String name); -UUID createDatabase(String name, CloudProviderType cloud, String cloudRegion); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the database to create. - -| `cloud` -| `CloudProviderType` -| The cloud provider where the database will be created. - -| `cloudRegion` -| `String` -| The region of the cloud provider where the database will be created. -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `UUID` -| The unique identifier of the created database. - -|=== - -NOTE: The service is blocking until the database is created and status is `ACTIVE`. - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateDatabase.java[] ----- - -=== Find a single database - -Find one database by ID or name, using the `AstraDBAdmin.findDatabaseById` and `AstraDBAdmin.findDatabaseByName` methods, respectively. - -[source,java] ----- -Optional findDatabaseById(UUID id); -Stream findDatabaseByName(String name); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `id` -| `UUID` -| The unique identifier of the database to find. - -| `name` -| `String` -| The name of the database to find. -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `Optional` -| Database information wrapped in an Optional object. UUID ensures the unicity of the database: you get one database or nothing. - -| `Stream` -| Database information list exposed as a Stream. Several databases can have the same name. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindDatabase.java[] ----- - -=== Find all databases - -Find all databases with the `AstraDBAdmin.findAllDatabases` method. - -[source,java] ----- -Stream findAllDatabases(); ----- - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `Stream` -| Database information list exposed as a Stream. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllDatabases.java[] ----- - -=== Delete a database - -Delete a database with the `AstraDBAdmin.deleteDatabase` method. - -[source,java] ----- -boolean deleteDatabase(String name); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the database to delete. -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `boolean` -| Flag indicating if the database was deleted. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteDatabase.java[] ----- - -== Collections - -Use the `AstraDB` and `AstraDBCollection` classes to work with collections. - -=== Create a collection - -Create a collection with the `AstraDB.createCollection` method. - -[source,java] ----- -AstraDBCollection createCollection(String name); -AstraDBCollection createCollection(String name, int vectorDimension); -AstraDBCollection createCollection(String name, int vectorDimension, SimilarityMetric metric); -AstraDBCollection createCollection(CollectionDefinition def); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the collection to create. - -| `vectorDimension` -| `int` -| The dimension for the vector in the collection. - -| `metric` -| `SimilarityMetric` -| The similarity metric to use for the vectors in the collection. - -| `def` -| `CollectionDefinition` -| The definition of the collection to create. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/CreateCollection.java[] ----- - -=== Find a single collection - -Find one collection with the `AstraDB.findCollection` method. - -[source,java] ----- -Optional findCollection(String name); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the collection to find. -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `Optional` -| Collection information wrapped in an Optional object. Collection name ensures unicity: you get one collection or nothing. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindCollection.java[] ----- - -=== Find all collections - -Find all collections with the `AstraDB.findAllCollections` method. - -[source,java] ----- -Stream findAllCollections(); ----- - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `Stream` -| Collections information list exposed as a Stream. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindAllCollections.java[] ----- - -=== Delete all documents in a collection - -Delete all documents in a collection with the `AstraDBCollection.deleteAll` method. - -[source,java] ----- -int deleteAll(); ----- - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `int` -| Number of deleted documents. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ClearCollection.java[] ----- - -=== Delete a collection - -Delete a collection with the `AstraDB.deleteCollection` method. - -[source,java] ----- -void deleteCollection(String name); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the store to delete. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteCollection.java[] ----- - -== Documents - -Use the `AstraDBCollection` class to work with documents. - -=== Insert a document - -Insert one document with the `AstraDBCollection.insertOne` method. -The system generates IDs automatically as needed. Each method is available in synchronous and asynchronous mode. - -[source,java] ----- -JsonDocumentMutationResult insertOne(String json); -CompletableFuture insertOneASync(String json); - -JsonDocumentMutationResult insertOne(JsonDocument jsonDocument); -CompletableFuture insertOneASync(JsonDocument jsonDocument); - -DocumentMutationResult insertOne(Document bean); -CompletableFuture> insertOneASync(Document bean); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `json` -| `String` -| The Json String representing the document to insert. - -| `bean` -| `Document` -| The bean representing the document to insert. - -| `jsonDocument` -| `JsonDocument` -| The JSON document to insert. -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `JsonDocumentMutationResult` -| An object containing the document amended with a generated id and a status `DocumentMutationStatus` which can take the values `CREATED`, `UPDATED`,`UNCHANGED`,`NOT_PROCESSED` or `ALREADY_EXISTS`. - -| `DocumentMutationResult` -| An object containing the document amended with a generated id and a status `DocumentMutationStatus` which can take the values `CREATED`, `UPDATED`,`UNCHANGED`,`NOT_PROCESSED` or `ALREADY_EXISTS`. - -|=== - -NOTE: You cannot insert a document with an existing ID, the exception `DataApiDocumentAlreadyExistException` is raised. To update a document if it already exists use the method `upsert`. - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertOne.java[] ----- - -=== Upsert a document - -Upsert one document with the `AstraDBCollection.upsertOne` method. - -- If the document does not exist it will be created -- If the document exists it will be updated. - -[source,java] ----- -JsonDocumentMutationResult - upsertOne(String json); -CompletableFuture - upsertOneAsync(String json); - -JsonDocumentMutationResult - upsertOne(JsonDocument jsonDocument); -CompletableFuture - upsertOneAsync(JsonDocument jsonDocument); - -DocumentMutationResult - upsertOne(Document bean); -CompletableFuture> - upsertOneAsync(Document bean); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `json` -| `String` -| The Json String representing the document to insert. - -| `jsonDocument` -| `JsonDocument` -| The JSON document to insert. - -| `bean` -| `Document` -| The bean representing the document to insert. - -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `JsonDocumentMutationResult` -| Key-Value Object containing the `JsonDocument` amended with a generated id and a status `DocumentMutationStatus`. - -| `DocumentMutationResult` -| An object containing the `Document` amended with a generated id and a status `DocumentMutationStatus`. - -|=== - -=== Insert many documents - -Insert many documents with the `AstraDBCollection.insertMany` method. -The system generates IDs automatically as needed. - -[source,java] ----- -List - insertMany(String json); -CompletableFuture> - insertManyASync(String json); - -List - insertManyJsonDocuments(List jsonDocuments); -CompletableFuture> - insertManyJsonDocumentsASync(List jsonDocuments); - -List> - insertMany(List documents); -CompletableFuture>> - insertManyASync(List> documents); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `json` -| `String` -| The Json String representing the document to insert. - -| `jsonDocument` -| `JsonDocument` -| The JSON document to insert. - -| `bean` -| `Document` -| The bean representing the document to insert. - -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `JsonDocumentMutationResult` -| Key-Value Object containing the `JsonDocument` amended with a generated id and a status `DocumentMutationStatus`. - -| `DocumentMutationResult` -| An object containing the `Document` amended with a generated id and a status `DocumentMutationStatus`. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/InsertMany.java[] ----- - -NOTE: The insertMany methods are limited to a maximum number of 20 documents in the list. If you need to insert more documents, use the `insertManyChunked*` method. - - -=== Insert many documents in chunks - -Insert many documents with the `AstraDBCollection.insertManyChunked` method. -The system generates IDs automatically as needed. The input list is split into chunks of `X` documents (chunk Size, default is 20). The processing of the different chunks can be parallelized to improve the performance. - -NOTE: Each method is presented in synchronous and asynchronous mode. The asynchronous mode returns a `CompletableFuture` object. - -[source,java] ----- -// Working with Key_value (JsonDocument) -List - insertManyChunkedJsonDocuments(List jsonDocuments); -CompletableFuture> - insertManyChunkedJsonDocumentsASync(List jsonDocuments); -List - insertManyJsonDocuments(List documents, boolean ordered, boolean upsert); - -// Working with Pojo (Document) -List> - insertManyChunked(List> beans); -CompletableFuture>> - insertManyChunkedASync(List> beans); -List> - insertManyChunked(List> beans, int chunkSize, int concurrency); -CompletableFuture>> - insertManyChunkedASync(List> beans, int chunkSize, int concurrency); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `jsonDocuments` -| `List` -| The list of `JsonDocument` (key/value) to insert. - -| `ordered` -| `boolean` -| Enforce the processing of the documents in the order of the list. If an error occurs, the processing is stopped. Default is `false` - -| `concurrency` -| `int` -| Set the number of parallel threads to process the chunks. Default is `1` - -| `bean` -| `Document` -| The list of `Documents` to insert. - -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `JsonDocumentMutationResult` -| Key-Value Object containing the `JsonDocument` amended with a generated id and a status `DocumentMutationStatus`. - -| `DocumentMutationResult` -| An object containing the `Document` amended with a generated id and a status `DocumentMutationStatus`. - -|=== - -=== Find a single document by query - -Find one document by query, using the `AstraDBCollection.find` method. - -[source,java] ----- -Stream find(SelectQuery query); -Stream> find(SelectQuery query, Class bean); -Stream> find(SelectQuery query, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `query` -| `SelectQuery` -| The filter used to search records. - -| `bean` -| `Class` -| The class for the target POJO. This is used for object mapping of the results. - -| `mapper` -| `ResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/Find.java[] ----- - -Find one document by query, using the `AstraDBCollection.findOne` method. - -[source,java] ----- -Optional findOne(String rawJsonQuery); -Optional findOne(SelectQuery query); -Optional> findOne(SelectQuery query, Class bean); -Optional> findOne(String query, Class bean); -Optional> findOne(SelectQuery query, DocumentResultMapper mapper); -Optional> findOne(String query, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `rawJsonQuery` -| `String` -| The raw JSON query string used to find a document. - -| `query` -| `SelectQuery` -| The query object used to find a document. - -| `bean` -| `Class` -| The class for the target POJO for object mapping. - -| `mapper` -| `DocumentResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindOne.java[] ----- - -=== Find a single document by ID - -Find one document by ID with the `AstraDBCollection.findById` method. - -[source,java] ----- -Optional findById(String id); -Optional> findById(String id, Class bean); -Optional> findById(String id, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `id` -| `String` -| The identifier of the document to find. - -| `bean` -| `Class` -| The class for the target POJO for object mapping. - -| `mapper` -| `ResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindById.java[] ----- - -=== Find a single document by vector - -Find one document by vector with the `AstraDBCollection.findOneByVector` method. - -[source,java] ----- -Optional findOneByVector(float[] vector); -Optional> findOneByVector(float[] vector, Class bean); -Optional> findOneByVector(float[] vector, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `vector` -| `float[]` -| The vector of the document to find. - -| `bean` -| `Class` -| The class for the target POJO for object mapping. - -| `mapper` -| `ResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindByVector.java[] ----- - -=== Perform a similarity search - -Perform a similarity search with the `AstraDBCollection.findVector` method. -This method returns documents with vectors that are close to a given vector. - -[source,java] ----- -Stream findVector(SelectQuery query); -Stream> findVector(SelectQuery query, Class bean); -Stream> findVector(SelectQuery query, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `query` -| `SelectQuery` -| The query object used to search records. - -| `bean` -| `Class` -| The class for the target POJO for object mapping. - -| `mapper` -| `ResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindVector.java[] ----- - -=== Paginate the results from a search - -Get a page of search results with the `AstraDBCollection.findPage` method. - -[source,java] ----- -Page findPage(SelectQuery pagedQuery); -Page findPage(String pagedQuery); -Page> findPage(SelectQuery query, Class bean); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `pagedQuery` -| `SelectQuery` or `String` -| The paged query object or string used to find documents. - -| `query` -| `SelectQuery` -| The query object used for finding documents in pages. - -| `bean` -| `Class` -| The class for the target POJO for object mapping. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/FindPage.java[] ----- - -=== Update a document - -Update one document with the `AstraDBCollection.updateOne` method. - -[source,java] ----- -UpdateStatus updateOne(UpdateQuery query); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `query` -| `UpdateQuery` -| The query object used to find and update a single record. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateOne.java[] ----- - -=== Update many documents - -Update many documents with the `AstraDBCollection.updateMany` method. - -[source,java] ----- -UpdateStatus updateMany(UpdateQuery query); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `query` -| `UpdateQuery` -| The query object used to find and update multiple records. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/UpdateMany.java[] ----- - -=== Delete a document - -Delete one document with the `AstraDBCollection.deleteOne` method. - -[source,java] ----- -int deleteOne(DeleteQuery deleteQuery); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `deleteQuery` -| `DeleteQuery` -| The delete query object used to remove a single record. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteOne.java[] ----- - -=== Delete many documents - -Delete many documents with the `AstraDBCollection.deleteMany` method. - -[source,java] ----- -int deleteMany(DeleteQuery deleteQuery); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `deleteQuery` -| `DeleteQuery` -| The delete query object used to remove multiple records. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/DeleteMany.java[] ----- - -== Object mapping - -An alternative way to work with databases is to use the `AstraDB` and `AstraDBRepository` classes to map documents to objects. - -=== Create a collection - -Create a collection with the `AstraDB.createCollection` method. - -[source,java] ----- -AstraDBRepository createCollection(String name, Class bean); -AstraDBRepository createCollection(String name, int vectorDimension, Class bean); -AstraDBRepository createCollection(CollectionDefinition def, Class bean); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `name` -| `String` -| The name of the store to create. - -| `vectorDimension` -| `int` -| The dimension for the vector in the collection. - -| `def` -| `CollectionDefinition` -| The definition of the collection to create. - -| `bean` -| `Class` -| The class type of the document used in the collection. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingCreateCollection.java[] ----- - -=== Upsert a document - -Upsert one document with the `AstraDBRepository.save` method. -The system generates IDs automatically as needed. - -[source,java] ----- -DocumentMutationResult insert(Document current); -CompletableFuture> insertASync(Document current); - -DocumentMutationResult save(Document current); -CompletableFuture> saveASync(Document current); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `current` -| `Document` -| The object representing the document to save. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertOne.java[] ----- - -=== Upsert Many documents - -Upsert many documents with the `AstraDBCollection.upsertManyChunked` method. -The system generates IDs automatically as needed. The input list is split into chunks of `X` documents (chunk Size, default is 20). The processing of the different chunks can be parallelized to improve the performance. - -NOTE: Each method is presented in synchronous and asynchronous mode. The asynchronous mode returns a `CompletableFuture` object. - -[source,java] ----- -// Upsert less than 20 -List> - upsertMany(List> beans); -CompletableFuture>> - upsertManyASync(List> beans); - -// Upsert in chunks -List> - upsertManyChunked(List> documents, int chunkSize, int concurrency) ; -CompletableFuture>> - upsertManyChunkedASync(List> documents, int chunkSize, int concurrency); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `chunkSize` -| `int` -| The size of the chunk. Default is `20` - -| `concurrency` -| `int` -| The number of parallel threads to process the chunks. Default is `1` - -| `beans` -| `List>` -| The list of `Documents` to insert. - -|=== - -Returned Values: - -[cols="1,4", options="header"] -|=== -| Type | Description - -| `JsonDocumentMutationResult` -| Key-Value Object containing the `JsonDocument` amended with a generated id and a status `DocumentMutationStatus`. - -| `DocumentMutationResult` -| An object containing the `Document` amended with a generated id and a status `DocumentMutationStatus`. - -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertMany.java[] ----- - -=== Find a single document by query - -Find one document by query, using the `AstraDBCollection.find` method. - -[source,java] ----- -Stream find(SelectQuery query); -Stream> find(SelectQuery query, Class bean); -Stream> find(SelectQuery query, DocumentResultMapper mapper); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `query` -| `SelectQuery` -| The filter used to search records. - -| `bean` -| `Class` -| The class for the target POJO. This is used for object mapping of the results. - -| `mapper` -| `ResultMapper` -| The mapper to convert JSON into the expected POJO. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFind.java[] ----- - -=== Find a single document by ID or vector - -Find one document by ID or vector, using the `AstraDBRepository.findById` or `AstraDBRepository.findByVector` methods, respectively. - -[source,java] ----- -Optional> findById(String id); -Optional> findByVector(float[] vector); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `id` -| `String` -| The identifier of the document to find. - -| `vector` -| `float[]` -| The vector associated with the document to find. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindOne.java[] ----- - -=== Perform a similarity search - -Perform a similarity search with the `AstraDBRepository.findVector` method. -This method returns documents with vectors that are close to a given vector. - -[source,java] ----- -Page> findVector(float[] vector, Filter metadataFilter); -List> findVector(float[] vector, Integer limit); -List> findVector(float[] vector, Filter metadataFilter, Integer limit); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `vector` -| `float[]` -| The vector for similarity search. - -| `metadataFilter` -| `Filter` -| The metadata filter for refining the search. - -| `limit` -| `Integer` -| The limit for the number of results to return. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindVector.java[] ----- - -=== Paginate the results from a search - -Get a page of search results with the `AstraDBRepository.findVector` method. - -[source,java] ----- -Page> findVector(float[] vector, Filter metadataFilter); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `vector` -| `float[]` -| The vector for the similarity search - -| `metadataFilter` -| `Filter` -| The filter to apply to the search results -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingPaging.java[] ----- - -=== Update a document - -Update one document with the `AstraDBRepository.save` method. - -[source,java] ----- -DocumentMutationResult save(Document current); -CompletableFuture> saveASync(Document current); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `current` -| `Document` -| The object representing the document to save. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateOne.java[] ----- - -=== Update many documents - -Update many documents with the `AstraDBRepository.saveAll` method. - -[source,java] ----- -List> saveAll(List> documentList); -CompletableFuture>> saveAllASync(List> documentList); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `documentList` -| `List>` -| The list of documents to save. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingUpdateMany.java[] ----- - -=== Delete a document - -Delete one document with the `AstraDBRepository.delete` method. - -[source,java] ----- -boolean delete(Document document); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `document` -| `Document` -| The document to delete. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteOne.java[] ----- - -=== Delete many documents - -Delete many documents with the `AstraDBRepository.deleteAll` method. - -[source,java] ----- -int deleteAll(); -int deleteAll(List> documents); -int deleteAll(DeleteQuery deleteQuery); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `documents` -| `List>` -| The list of documents to delete. - -| `deleteQuery` -| `DeleteQuery` -| The delete query object used to remove multiple records. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingDeleteMany.java[] ----- - -=== Delete all documents in a collection - -Delete all documents in a collection with the `AstraDBRepository.deleteAll` method. - -[source,java] ----- -int deleteAll(); -int deleteAll(List> documents); -int deleteAll(DeleteQuery deleteQuery); ----- - -Parameters: - -[cols="1,1,3", options="header"] -|=== -| Name | Type | Description - -| `documents` -| `List>` -| The list of documents to delete. - -| `deleteQuery` -| `DeleteQuery` -| The delete query object used to remove multiple records. -|=== - -Example: - -[source,java] ----- -include::https://raw.githubusercontent.com/datastax/astra-sdk-java/main/astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingClearCollection.java[] ----- \ No newline at end of file diff --git a/astra-db-client/src/test/resources/johnny.pdf b/astra-db-client/src/test/resources/johnny.pdf deleted file mode 100644 index d139c372..00000000 Binary files a/astra-db-client/src/test/resources/johnny.pdf and /dev/null differ diff --git a/astra-db-client/src/test/resources/logback-test.xml b/astra-db-client/src/test/resources/logback-test.xml index 4d383586..a35e5f5f 100644 --- a/astra-db-client/src/test/resources/logback-test.xml +++ b/astra-db-client/src/test/resources/logback-test.xml @@ -20,6 +20,10 @@ + + + + diff --git a/astra-db-client/src/test/resources/philo_quotes.json b/astra-db-client/src/test/resources/philo_quotes.json deleted file mode 100644 index 124aa8ed..00000000 --- a/astra-db-client/src/test/resources/philo_quotes.json +++ /dev/null @@ -1,2590 +0,0 @@ -{ - "source": "Adapted from this Kaggle dataset: https://www.kaggle.com/datasets/mertbozkurt5/quotes-by-philosophers (License: CC BY-NC-SA 4.0)", - "quotes": { - "aristotle": [ - { - "body": "True happiness comes from gaining insight and growing into your best possible self. Otherwise all you're having is immediate gratification pleasure, which is fleeting and doesn't grow you as a person.", - "tags": [ - "knowledge" - ] - }, - { - "body": "The roots of education are bitter, but the fruit is sweet.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "Before you heal the body you must first heal the mind", - "tags": [ - "ethics" - ] - }, - { - "body": "The proof that you know something is that you are able to teach it", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "Those who are not angry at the things they should be angry at are thought to be fools, and so are those who are not angry in the right way, at the right time, or with the right persons.", - "tags": [] - }, - { - "body": "Whatever we learn to do, we learn by actually doing it; men come to be builders, for instance, by building, and harp players by playing the harp. In the same way, by doing just acts we come to be just; by doing self-controlled acts, we come to be self-controlled ; and by doing brave acts, we become brave.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "The greatest thing by far is to be a master of metaphor; it is the one thing that cannot be learned from others; and it is also a sign of genius, since a good metaphor implies an intuitive perception of the similarity of the dissimilar.", - "tags": [] - }, - { - "body": "The society that loses its grip on the past is in danger, for it produces men who know nothing but the present, and who are not aware that life had been, and could be, different from what it is.", - "tags": [ - "history", - "ethics", - "knowledge" - ] - }, - { - "body": "The man who is truly good and wise will bear with dignity whatever fortune sends, and will always make the best of his circumstances.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "The greatest of all pleasures is the pleasure of learning.", - "tags": [ - "knowledge", - "education", - "history" - ] - }, - { - "body": "Fortune favours the bold.", - "tags": [] - }, - { - "body": "You are what you repeatedly do", - "tags": [] - }, - { - "body": "The quality of life is determined by its activities.", - "tags": [] - }, - { - "body": "You are what you do repeatedly.", - "tags": [] - }, - { - "body": "Anyone who has no need of anybody but himself is either a beast or a God.", - "tags": [] - }, - { - "body": "Love is composed of a single soul inhabiting two bodies.", - "tags": [ - "love" - ] - }, - { - "body": "Love well, be loved and do something of value.", - "tags": [ - "love", - "ethics" - ] - }, - { - "body": "Philosophy begins with wonder.", - "tags": [] - }, - { - "body": "Plato is my friend, but truth is a better friend.", - "tags": [] - }, - { - "body": "At his best, man is the noblest of all animals; separated from law and justice he is the worst.", - "tags": [ - "ethics" - ] - }, - { - "body": "A promise made must be a promise kept.", - "tags": [ - "ethics" - ] - }, - { - "body": "It is better for a city to be governed by a good man than by good laws.", - "tags": [ - "politics", - "ethics" - ] - }, - { - "body": "Men become richer not only by increasing their existing wealth but also by decreasing their expenditure.", - "tags": [] - }, - { - "body": "Consider pleasures as they depart, not as they come.", - "tags": [ - "ethics" - ] - }, - { - "body": "Dignity does not consist in possessing honors, but in deserving them.", - "tags": [ - "ethics" - ] - }, - { - "body": "He who sees things grow from the beginning will have the best view of them.", - "tags": [ - "knowledge", - "history", - "ethics", - "education" - ] - }, - { - "body": "Happiness is the reward of virtue.", - "tags": [ - "ethics" - ] - }, - { - "body": "If you would understand anything, observe its beginning and its development", - "tags": [ - "history", - "knowledge" - ] - }, - { - "body": "A friend is another I.", - "tags": [] - }, - { - "body": "He who hath many friends hath none.", - "tags": [ - "ethics" - ] - }, - { - "body": "The hand is the tool of tools.", - "tags": [] - }, - { - "body": "Good moral character is not something that we can achieve on our own. We need a culture that supports the conditions under which self-love and friendship flourish.", - "tags": [ - "ethics" - ] - }, - { - "body": "We give up leisure in order that we may have leisure, just as we go to war in order that we may have peace.", - "tags": [ - "ethics" - ] - }, - { - "body": "We must be neither cowardly nor rash but courageous.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "The true nature of anything is what it becomes at its highest.", - "tags": [ - "knowledge" - ] - }, - { - "body": "To give away money is an easy matter and in any man's power. But to decide to whom to give it and how large and when, and for what purpose and how, is neither in every man's power nor an easy matter.", - "tags": [ - "knowledge", - "ethics", - "politics" - ] - }, - { - "body": "A man's happiness consists in the free exercise of his highest faculties.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "For what is the best choice for each individual is the highest it is possible for him to achieve.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "Those who act receive the prizes.", - "tags": [ - "ethics" - ] - }, - { - "body": "A man becomes a friend whenever being loved he loves in return.", - "tags": [ - "love", - "ethics" - ] - }, - { - "body": "Character is that which reveals moral purpose, exposing the class of things a man chooses and avoids.", - "tags": [] - }, - { - "body": "Bad men are full of repentance.", - "tags": [ - "ethics" - ] - }, - { - "body": "For we do not think that we know a thing until we are acquainted with its primary conditions or first principles, and have carried our analysis as far as its simplest elements.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Philosophy can make people sick.", - "tags": [ - "politics" - ] - }, - { - "body": "Democracy appears to be safer and less liable to revolution than oligarchy. For in oligarchies there is the double danger of the oligarchs falling out among themselves and also with the people; but in democracies there is only the danger of a quarrel with the oligarchs. No dissension worth mentioning arises among the people themselves. And we may further remark that a government which is composed of the middle class more nearly approximates to democracy than to oligarchy, and is the safest of the imperfect forms of government.", - "tags": [ - "politics", - "knowledge" - ] - }, - { - "body": "Civil confusions often spring from trifles but decide great issues.", - "tags": [ - "ethics", - "politics" - ] - }, - { - "body": "All men by nature desire knowledge.", - "tags": [ - "knowledge", - "education" - ] - }, - { - "body": "But is it just then that the few and the wealthy should be the rulers? And what if they, in like manner, rob and plunder the people, - is this just?", - "tags": [ - "politics", - "ethics" - ] - }, - { - "body": "Definition of tragedy: A hero destroyed by the excess of his virtues", - "tags": [] - }, - { - "body": "Every rascal is not a thief, but every thief is a rascal.", - "tags": [] - } - ], - "freud": [ - { - "body": "We are what we are because we have been what we have been.", - "tags": [ - "history" - ] - }, - { - "body": "From error to error one discovers the entire truth.", - "tags": [] - }, - { - "body": "Two hallmarks of a healthy life are the abilities to love and to work. Each requires imagination.", - "tags": [ - "love" - ] - }, - { - "body": "When someone abuses me I can defend myself, but against praise I am defenceless.", - "tags": [ - "ethics" - ] - }, - { - "body": "Not all men are worthy of love.", - "tags": [] - }, - { - "body": "The meager satisfaction that man can extract from reality leaves him starving.", - "tags": [] - }, - { - "body": "It is not attention that the child is seeking, but love.", - "tags": [ - "love" - ] - }, - { - "body": "The only unnatural sexual behavior is none at all.", - "tags": [] - }, - { - "body": "A woman should soften but not weaken a man.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "The psychoanalysis of individual human beings, however, teaches us with quite special insistence that the god of each of them is formed in the likeness of his father, that his personal relation to God depends on his relation to his father in the flesh and oscillates and changes along with that relation, and that at bottom God is nothing other than an exalted father.", - "tags": [ - "knowledge" - ] - }, - { - "body": "When a love-relationship is at its height there is no room left for any interest in the environment; a pair of lovers are sufficient to themselves", - "tags": [ - "love" - ] - }, - { - "body": "All giving is asking, and all asking is an asking for love.", - "tags": [ - "love" - ] - }, - { - "body": "The news that reaches your consciousness is incomplete and often not to be relied on.... Turn your eyes inward, look into your own depths, learn first to know yourself!", - "tags": [ - "education", - "ethics" - ] - }, - { - "body": "Perhaps the gods are kind to us, by making life more disagreeable as we grow older. In the end death seems less intolerable than the manifold burdens we carry", - "tags": [ - "religion" - ] - }, - { - "body": "Anxiety in children is originally nothing other than an expression of the fact they are feeling the loss of the person they love.", - "tags": [] - }, - { - "body": "I cannot think of any need in childhood as strong as the need for a father's protection.", - "tags": [] - }, - { - "body": "The virtuous man contents himself with dreaming that which the wicked man does in actual life.", - "tags": [ - "ethics" - ] - }, - { - "body": "The only shame in masturbation is the shame of not doing it well.", - "tags": [] - }, - { - "body": "Philosophers stretch the meaning of words until they retain scarcely anything of their original sense. They give the name of \"God\" to some vague abstraction which they have created for themselves; having done so they can pose before all the world as deists, as believers of God, and they can even boast that they have recognized a higher, purer concept of God, notwithstanding that their God is not nothing more than an insubstantial shadow and no longer the mighty personality of religious doctrines.", - "tags": [ - "religion", - "knowledge" - ] - }, - { - "body": "Religion originates in the child's and young mankind's fears and need for help. It cannot be otherwise.", - "tags": [ - "religion" - ] - }, - { - "body": "Whatever fosters the growth of civilization works at the same time against war.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "The doctor should be opaque to his patients and, like a mirror, should show them nothing but what is shown to him.", - "tags": [ - "ethics" - ] - }, - { - "body": "The first human who hurled an insult instead of a stone was the founder of civilization.", - "tags": [ - "history" - ] - }, - { - "body": "In mourning it is the world which has become poor and empty; in melancholia it is the ego itself.", - "tags": [] - }, - { - "body": "This transmissibility of taboo is a reflection of the tendency, on which we have already remarked, for the unconscious instinct in the neurosis to shift constantly along associative paths on to new objects.", - "tags": [] - }, - { - "body": "If a man has been his mother's undisputed darling he retains throughout life the triumphant feeling, the confidence in success, which not seldom brings actual success along with it.", - "tags": [ - "love" - ] - }, - { - "body": "Religion restricts the play of choice and adaptation, since it imposes equally on everyone its own path to the acquisition of happiness and protection from suffering. Its technique consists in depressing the value of life and distorting the picture of the real world in a delusional manner - which presupposes an intimidation of the intelligence. At this price, by forcibly fixing them in a state of psychical infantilism and by drawing them into a mass-delusion, religion succeeds in sparing many people an individual neurosis. But hardly anything more.", - "tags": [ - "religion" - ] - }, - { - "body": "Sometimes a cigar is just a cigar.", - "tags": [] - }, - { - "body": "Where questions of religion are concerned, people are guilty of every possible sort of dishonesty and intellectual misdemeanor.", - "tags": [ - "religion" - ] - }, - { - "body": "When we share - that is poetry in the prose of life.", - "tags": [ - "love" - ] - }, - { - "body": "Illusions commend themselves to us because they save us pain and allow us to enjoy pleasure instead. We must therefore accept it without complaint when they sometimes collide with a bit of reality against which they are dashed to pieces.", - "tags": [] - }, - { - "body": "The world is no nursery.", - "tags": [] - }, - { - "body": "At bottom God is nothing more than an exalted father.", - "tags": [ - "religion" - ] - }, - { - "body": "Analogies, it is true, decide nothing, but they can make one feel more at home.", - "tags": [] - }, - { - "body": "Man has, as it were, become a kind of prosthetic God. When he puts on all his auxiliary organs, he is truly magnificent; but those organs have not grown on him and they still give him much trouble at times.", - "tags": [] - }, - { - "body": "The effect of the consolations of religion may be compared to that of a narcotic.", - "tags": [ - "religion" - ] - }, - { - "body": "It is no wonder if, under the pressure of these possibilities of suffering, men are accustomed to moderate their claims to happiness - just as the pleasure principle itself, indeed, under the influence of the external world, changed into the more modest reality principle -, if a man thinks himself happy merely to have escaped unhappiness or to have survived his suffering, and if in general the task of avoiding suffering pushes that of obtaining pleasure into the background.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "One... gets an impression that civilization is something which was imposed on a resisting majority by a minority which understood how to obtain possession of the means to power and coercion. It is, of course, natural to assume that these difficulties are not inherent in the nature of civilization itself but are determined by the imperfections of the cultural forms which have so far been developed.", - "tags": [ - "politics" - ] - }, - { - "body": "[The child receives impressions like] a photographic exposure that can be developed after any interval of time and transformed into a picture.", - "tags": [] - }, - { - "body": "The dream unites the grossest contradictions, permits impossibilities, sets aside the knowledge that influences us by day, and exposes us as ethically and morally obtuse.", - "tags": [ - "ethics" - ] - }, - { - "body": "Where such men love they have no desire and where they desire they cannot love", - "tags": [ - "love", - "ethics" - ] - }, - { - "body": "I do not in the least underestimate bisexuality... I expect it to provide all further enlightenment.", - "tags": [ - "knowledge", - "education" - ] - }, - { - "body": "To endure life remains, when all is said, the first duty of all living being Illusion can have no value if it makes this more difficult for us.", - "tags": [] - }, - { - "body": "There is an intellectual function in us which demands unity, connection and intelligibility from any material, whether of perception or thought, that comes within its grasp; and if, as a result of special circumstances, it is unable to establish a true connection, it does not hesitate to fabricate a false one.", - "tags": [] - }, - { - "body": "A string of reproaches against other people leads one to suspect the existence of a string of self-reproaches with the same content.", - "tags": [] - }, - { - "body": "When a man has once brought himself to accept uncritically all the absurdities that religious doctrines put before him and even to overlook the contradictions between them, we need not be greatly suprised at the weakness of his intellect.", - "tags": [ - "religion" - ] - }, - { - "body": "The rest of our enquiry is made easy because this God-Creator is openly called Father. Psycho-analysis concludes that he really is the father, clothed in the grandeur in which he once appeared to the small child.", - "tags": [ - "knowledge" - ] - }, - { - "body": "The expectation that every neurotic phenomenon can be cured may, I suspect, be derived from the layman's belief that the neuroses are something quite unnecessary which have no right whatever to exist. Whereas in fact they are severe, constitutionally fixed illnesses, which rarely restrict themselves to only a few attacks but persist as a rule over long periods throughout life.", - "tags": [] - }, - { - "body": "Lead us, Heavenly Father, lead us O'er the world's tempestuous sea; Guard us, guide us, keep us, feed us, For we have no help but Thee.", - "tags": [ - "religion", - "love", - "knowledge", - "ethics" - ] - }, - { - "body": "Towards the outside, at any rate, the ego seems to maintain clear and sharp lines of demarcation. There is only one state -- admittedly an unusual state, but not one that can be stigmatized as pathological -- in which it does not do this. At the height of being in love the boundary between ego and object threatens to melt away. Against all the evidence of his senses, a man who is in love declares that \"I\" and \"you\" are one, and is prepared to behave as if it were a fact.", - "tags": [ - "love" - ] - } - ], - "hegel": [ - { - "body": "We learn from history that we do not learn from history", - "tags": [ - "history", - "knowledge" - ] - }, - { - "body": "To be independent of public opinion is the first formal condition of achieving anything great.", - "tags": [ - "ethics", - "education" - ] - }, - { - "body": "To be aware of limitations is already to be beyond them.", - "tags": [ - "ethics" - ] - }, - { - "body": "What history teaches us is that neither nations nor governments ever learn anything from it.", - "tags": [ - "history" - ] - }, - { - "body": "The valor that struggles is better than the weakness that endures.", - "tags": [ - "ethics", - "education" - ] - }, - { - "body": "The more certain our knowledge the less we know.", - "tags": [ - "knowledge", - "education", - "ethics", - "history" - ] - }, - { - "body": "In a true tragedy, both parties must be right.", - "tags": [ - "politics" - ] - }, - { - "body": "Before the end of Time will be the end of History. Before the end of History will be the end of Art.", - "tags": [ - "history" - ] - }, - { - "body": "Poverty in itself does not make men into a rabble; a rabble is created only when there is joined to poverty a disposition of mind, an inner indignation against the rich, against society, against the government.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "The learner always begins by finding fault, but the scholar sees the positive merit in everything.", - "tags": [ - "education", - "knowledge", - "history", - "ethics" - ] - }, - { - "body": "An idea is always a generalization, and generalization is a property of thinking. To generalize means to think.", - "tags": [] - }, - { - "body": "Genuine tragedy is a case not of right against wrong but of right against right - two equally justified ethical principles embodied in people of unchangeable will.", - "tags": [] - }, - { - "body": "America is therefore the land of the future, where, in the ages that lie before us, the burden of the World's History shall reveal itself.", - "tags": [ - "knowledge", - "history" - ] - }, - { - "body": "The history of the world is none other than the progress of the , consciousness of freedom.", - "tags": [ - "history" - ] - }, - { - "body": "Beauty is merely the Spiritual making itself known sensuously.", - "tags": [] - }, - { - "body": "All education is the art of making men ethical (sittlich), of transforming the old Adam into the new Adam.", - "tags": [ - "education", - "ethics", - "knowledge" - ] - }, - { - "body": "Impatience asks for the impossible, wants to reach the goal without the means of getting there. The length of the journey has to be borne with, for every moment is necessary.", - "tags": [ - "ethics" - ] - }, - { - "body": "It is solely by risking life that freedom is obtained; . . . the individual who has not staked his or her life may, no doubt, be recognized as a Person; but he or she has not attained the truth of this recognition as an independent self-consciousness.", - "tags": [ - "ethics" - ] - }, - { - "body": "To make abstractions hold in reality is to destroy reality.", - "tags": [] - }, - { - "body": "Philosophy is by its nature something esoteric, neither made for the mob nor capable of being prepared for the mob.", - "tags": [] - }, - { - "body": "We learn from history that man can never learn anything from history.", - "tags": [ - "history" - ] - }, - { - "body": "Freedom is the fundamental character of the will, as weight is of matter... That which is free is the will. Will without freedom is an empty word.", - "tags": [ - "ethics" - ] - }, - { - "body": "The people are that part of the state that does not know what it wants.", - "tags": [ - "politics" - ] - }, - { - "body": "We do not need to be shoemakers to know if our shoes fit, and just as little have we any need to be professionals to acquire knowledge of matters of universal interest.", - "tags": [ - "knowledge" - ] - }, - { - "body": "World history is a court of judgment.", - "tags": [ - "history" - ] - }, - { - "body": "The length of the journey has to be borne with, for every moment is necessary.", - "tags": [ - "ethics" - ] - }, - { - "body": "The True is the whole. But the whole is nothing other than the essence consummating itself through its development. Of the Absolute it must be said that it is essentially a result, that only in the end is it what it truly is; and that precisely in this consists its nature, viz. to be actual, subject, the spontaneous becoming of itself.", - "tags": [] - }, - { - "body": "Regarding History as the slaughter-bench at which the happiness of peoples, the wisdom of States, and the virtue of individuals have been victimized--the question involuntarily arises--to what principle, to what final aim these enormous sacrifices have been offered.", - "tags": [ - "history" - ] - }, - { - "body": "The proofs of the existence of God are to such an extent fallen into discredit that they pass for something antiquated, belonging to days gone by.", - "tags": [ - "history", - "religion" - ] - }, - { - "body": "The bud disappears when the blossom breaks through, and we might say that the former is refuted by the latter; in the same way when the fruit comes, the blossom may be explained to be a false form of the plant's existence, for the fruit appears as its true nature in place of the blossom.", - "tags": [] - }, - { - "body": "The true courage of civilized nations is readiness for sacrifice in the service of the state, so that the individual counts as only one amongst many. The important thing here is not personal mettle but aligning oneself with the universal.", - "tags": [ - "ethics", - "politics", - "knowledge" - ] - }, - { - "body": "The heart-throb for the welfare of humanity therefore passes into the ravings of an insane self-conceit, into the fury of consciousness to preserve itself from destruction; and it does this by expelling from itself the perversion which it is itself, and by striving to look on it and express it as something else.", - "tags": [] - }, - { - "body": "The Catholics had been in the position of oppressors, and the Protestants of the oppressed", - "tags": [ - "religion", - "politics", - "history", - "ethics" - ] - }, - { - "body": "To him who looks upon the world rationally, the world in its turn presents a rational aspect. The relation is mutual.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Propounding peace and love without practical or institutional engagement is delusion, not virtue.", - "tags": [] - }, - { - "body": "It strikes everyone in beginning to form an acquaintance with the treasures of Indian literature that a land so rich in intellectual products and those of the profoundest order of thought.", - "tags": [ - "knowledge" - ] - }, - { - "body": "The people will learn to feel the dignity of man. They will not merely demand their rights, which have been trampled in the dust, but themselves will take them - make them their own.", - "tags": [ - "knowledge", - "ethics", - "education", - "politics" - ] - }, - { - "body": "It is easier to discover a deficiency in individuals, in states, and in Providence, than to see their real import and value.", - "tags": [] - }, - { - "body": "Children are potentially free and their life directly embodies nothing save potential freedom. Consequently they are not things and cannot be the property either of their parents or others.", - "tags": [ - "ethics" - ] - }, - { - "body": "When liberty is mentioned, we must always be careful to observe whether it is not really the assertion of private interests which is thereby designated.", - "tags": [] - }, - { - "body": "It is because the method of physics does not satisfy the comprehension that we have to go on further.", - "tags": [] - }, - { - "body": "Consequently, the sensuous aspect of art is related only to the two theoretical sensesof sight and hearing, while smell, taste, and touch remain excluded.", - "tags": [] - }, - { - "body": "Once the state has been founded, there can no longer be any heroes. They come on the scene only in uncivilized conditions.", - "tags": [ - "politics" - ] - }, - { - "body": "The essence of the modern state is that the universal be bound up with the complete freedom of its particular members and with private well-being, that thus the interests of family and civil society must concentrate themselves on the state. It is only when both these moments subsist in their strength that the state can be regarded as articulated and genuinely organized.", - "tags": [] - }, - { - "body": "Animals are in possession of themselves; their soul is in possession of their body. But they have no right to their life, because they do not will it.", - "tags": [ - "ethics" - ] - }, - { - "body": "The State is the Divine idea as it exists on Earth.", - "tags": [] - }, - { - "body": "In the case of various kinds of knowledge, we find that what in former days occupied the energies of men of mature mental ability sinks to the level of information, exercises, and even pastimes for children; and in this educational progress we can see the history of the world's culture delineated in faint outline.", - "tags": [ - "knowledge", - "education", - "history" - ] - }, - { - "body": "Every philosophy is complete in itself and, like a genuine work of art, contains the totality. Just as the works of Apelles and Sophocles, if Raphael and Shakespeare had known them, should not have appeared to them as mere preliminary exercises for their own work, but rather as a kindred force of the spirit, so, too reason cannot find in its own earlier forms mere useful preliminary exercises for itself.", - "tags": [ - "knowledge" - ] - }, - { - "body": "We assert then that nothing has been accomplished without interest on the part of the actors; and if interest be called passion, inasmuch as the whole individuality, to the neglect of all other actual or possible interests and claims, is devoted to an object with every fibre of volition, concentrating all its desires and powers upon it we may affirm absolutely that nothing great in the World has been accomplished without passion.", - "tags": [ - "love" - ] - }, - { - "body": "The Few assume to be the deputies, but they are often only the despoilers of the Many.", - "tags": [ - "politics" - ] - } - ], - "kant": [ - { - "body": "Rules for Happiness: something to do, someone to love, something to hope for.", - "tags": [ - "love" - ] - }, - { - "body": "Do the right thing because it is right.", - "tags": [ - "ethics" - ] - }, - { - "body": "The only thing permanent is change.", - "tags": [] - }, - { - "body": "Give a man everything he wants and at that moment everything is not everything", - "tags": [ - "ethics" - ] - }, - { - "body": "Great minds think for themselves.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Perpetual Peace is only found in the graveyard.", - "tags": [] - }, - { - "body": "A single line in the Bible has consoled me more than all the books I ever read besides.", - "tags": [ - "religion", - "love" - ] - }, - { - "body": "All our knowledge begins with the senses, proceeds then to the understanding, and ends with reason. There is nothing higher than reason.", - "tags": [ - "knowledge", - "history", - "education" - ] - }, - { - "body": "If justice perishes, human life on Earth has lost its meaning.", - "tags": [] - }, - { - "body": "Morality is not properly the doctrine of how we may make ourselves happy, but how we may make ourselves worthy of happiness.", - "tags": [] - }, - { - "body": "Out of the crooked timber of humanity, no straight thing was ever made.", - "tags": [ - "ethics" - ] - }, - { - "body": "Thoughts without content are empty, intuitions without concepts are blind.", - "tags": [] - }, - { - "body": "Immaturity is the incapacity to use one's intelligence without the guidance of another.", - "tags": [] - }, - { - "body": "The nice thing about living in a small town is that when you don't know what you're doing, someone else does.", - "tags": [] - }, - { - "body": "Two things strike me dumb: the infinite starry heavens, and the sense of right and wrong in man.", - "tags": [ - "ethics" - ] - }, - { - "body": "Reason can never prove the existence of God.", - "tags": [ - "religion" - ] - }, - { - "body": "All the interests of my reason, speculative as well as practical, combine in the three following questions: 1. What can I know? 2. What ought I to do? 3. What may I hope?", - "tags": [ - "knowledge" - ] - }, - { - "body": "By a lie, a man... annihilates his dignity as a man.", - "tags": [ - "politics", - "ethics" - ] - }, - { - "body": "Religion is too important a matter to its devotees to be a subject of ridicule. If they indulge in absurdities, they are to be pitied rather than ridiculed.", - "tags": [ - "religion" - ] - }, - { - "body": "Enthusiasm is always connected with the senses, whatever be the object that excites it. The true strength of virtue is serenity of mind, combined with a deliberate and steadfast determination to execute her laws. That is the healthful condition of the moral life; on the other hand, enthusiasm, even when excited by representations of goodness, is a brilliant but feverish glow which leaves only exhaustion and languor behind.", - "tags": [ - "ethics" - ] - }, - { - "body": "Men will not understand ... that when they fulfil their duties to men, they fulfil thereby God's commandments; that they are consequently always in the service of God, as long as their actions are moral, and that it is absolutely impossible to serve God otherwise.", - "tags": [ - "ethics", - "religion" - ] - }, - { - "body": "[A ruler is merely] the trustee of the rights of other men and he must always stand in dread of having in some way violated these rights.", - "tags": [ - "ethics" - ] - }, - { - "body": "The death of dogma is the birth of morality.", - "tags": [ - "ethics" - ] - }, - { - "body": "Freedom is that faculty that enlarges the usefulness of all other faculties.", - "tags": [] - }, - { - "body": "The sum total of all possible knowledge of God is not possible for a human being, not even through a true revelation. But it is one of the worthiest inquiries to see how far our reason can go in the knowledge of God.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Philosophy stands in need of a science which shall determine the possibility, principles, and extent of human knowledge priori.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Thrift is care and scruple in the spending of one's means. It is not a virtue and it requires neither skill nor talent.", - "tags": [ - "ethics" - ] - }, - { - "body": "If a man is often the subject of conversation he soon becomes the subject of criticism.", - "tags": [ - "ethics" - ] - }, - { - "body": "Enlightenment is man's emergence from his self-incurred immaturity.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "Give me matter, and I will construct a world out of it!", - "tags": [] - }, - { - "body": "Even a man's exact imitation of the song of the nightingale displeases us when we discover that it is a mimicry, and not the nightingale.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "[R]eason is... given to us as a practical faculty, that is, as one that influences the will.", - "tags": [] - }, - { - "body": "The business of philosophy is not to give rules, but to analyze the private judgments of common reason.", - "tags": [] - }, - { - "body": "Moral Teleology supplies the deficiency in physical Teleology , and first establishes a Theology ; because the latter, if it did not borrow from the former without being observed, but were to proceed consistently, could only found a Demonology , which is incapable of any definite concept.", - "tags": [] - }, - { - "body": "There is nothing higher than reason.", - "tags": [] - }, - { - "body": "Time is not an empirical concept. For neither co-existence nor succession would be perceived by us, if the representation of time did not exist as a foundation a priori.", - "tags": [] - }, - { - "body": "Have patience awhile; slanders are not long-lived. Truth is the child of time; erelong she shall appear to vindicate thee.", - "tags": [ - "knowledge", - "ethics", - "history", - "education" - ] - }, - { - "body": "But only he who, himself enlightened, is not afraid of shadows.", - "tags": [ - "knowledge", - "education", - "ethics" - ] - }, - { - "body": "There is needed, no doubt, a body of servants (ministerium) of the invisible church, but not officials (officiales), in other words, teachers but not dignitaries, because in the rational religion of every individual there does not yet exist a church as a universal union (omnitudo collectiva).", - "tags": [ - "religion", - "education", - "knowledge" - ] - }, - { - "body": "Reason must approach nature in order to be taught by it. It must not, however, do so in the character of a pupil who listens to everything that the teacher chooses to say, but of an appointed judge who compels the witness to answer questions which he has himself formulated.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "But although all our knowledge begins with experience, it does not follow that it arises from experience.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "Enlightenment is the liberation of man from his self-caused state of minority... Supere aude! Dare to use your own understanding!is thus the motto of the Enlightenment.", - "tags": [ - "knowledge" - ] - }, - { - "body": "The history of the human race, viewed as a whole, may be regarded as the realization of a hidden plan of nature to bring about a political constitution, internally, and for this purpose, also externally perfect, as the only state in which all the capacities implanted by her in mankind can be fully developed.", - "tags": [ - "history", - "politics" - ] - }, - { - "body": "Standing armies shall in time be totally abolished.", - "tags": [ - "history" - ] - }, - { - "body": "Criticism alone can sever the root of materialism, fatalism, atheism, free-thinking, fanaticism, and superstition, which can be injurious universally; as well as of idealism and skepticism, which are dangerous chiefly to the Schools, and hardly allow of being handed on to the public.", - "tags": [ - "education" - ] - }, - { - "body": "Everything in nature acts in conformity with law.", - "tags": [] - }, - { - "body": "I freely admit that the remembrance of David Hume was the very thing that many years ago first interrupted my dogmatic slumber and gave a completely different direction to my researches in the field of speculative philosophy.", - "tags": [ - "knowledge", - "history" - ] - }, - { - "body": "All trades, arts, and handiworks have gained by division of labor... Where the different kinds of work are not distinguished and divided, where everyone is a jack-of-all-trades, there manufactures remain still in the greatest barbarism.", - "tags": [] - }, - { - "body": "Innocence is indeed a glorious thing; but, unfortunately, it does not keep very well and is easily led astray.", - "tags": [] - }, - { - "body": "The schematicism by which our understanding deals with the phenomenal world ... is a skill so deeply hidden in the human soul that we shall hardly guess the secret trick that Nature here employs.", - "tags": [ - "knowledge" - ] - } - ], - "nietzsche": [ - { - "body": "Sometimes people don't want to hear the truth because they don't want their illusions destroyed.", - "tags": [ - "ethics", - "education", - "politics" - ] - }, - { - "body": "To live is to suffer, to survive is to find some meaning in the suffering.", - "tags": [ - "ethics" - ] - }, - { - "body": "Whoever fights monsters should see to it that in the process he does not become a monster. And if you gaze long enough into an abyss, the abyss will gaze back into you.", - "tags": [ - "ethics" - ] - }, - { - "body": "No price is too high to pay for the privilege of owning yourself.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the rule.", - "tags": [ - "politics" - ] - }, - { - "body": "Everything the State says is a lie, and everything it has it has stolen.", - "tags": [ - "politics", - "knowledge" - ] - }, - { - "body": "The snake which cannot cast its skin has to die. As well the minds which are prevented from changing their opinions; they cease to be mind.", - "tags": [ - "ethics" - ] - }, - { - "body": "Man is the only animal that must be encouraged to live.", - "tags": [ - "ethics" - ] - }, - { - "body": "The secret of reaping the greatest fruitfulness and the greatest enjoyment from life is to live dangerously.", - "tags": [] - }, - { - "body": "It is not a lack of love, but a lack of friendship that makes unhappy marriages.", - "tags": [] - }, - { - "body": "To predict the behavior of ordinary people in advance, you only have to assume that they will always try to escape a disagreeable situation with the smallest possible expenditure of intelligence.", - "tags": [ - "knowledge" - ] - }, - { - "body": "The Great Man... is colder, harder, less hesitating, and without fear of 'opinion'; he lacks the virtues that accompany respect and 'respectability,' and altogether everything that is the 'virtue of the herd.' If he cannot lead, he goes alone... He knows he is incommunicable: he finds it tasteless to be familiar... When not speaking to himself, he wears a mask. There is a solitude within him that is inaccessible to praise or blame.", - "tags": [ - "knowledge", - "ethics", - "politics", - "education" - ] - }, - { - "body": "The world is beautiful, but has a disease called man.", - "tags": [] - }, - { - "body": "Solitude makes us tougher towards ourselves and tenderer towards others. In both ways it improves our character.", - "tags": [ - "ethics" - ] - }, - { - "body": "Young people love what is interesting and odd, no matter how true or false it is. More mature minds love what is interesting and odd about truth. Fully mature intellects, finally, love truth, even when it appears plain and simple, boring to the ordinary person; for they have noticed that truth tends to reveal its highest wisdom in the guise of simplicity.", - "tags": [ - "knowledge", - "love" - ] - }, - { - "body": "The real question is: How much truth can I stand?", - "tags": [ - "ethics" - ] - }, - { - "body": "The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.", - "tags": [] - }, - { - "body": "There are no beautiful surfaces without a terrible depth.", - "tags": [] - }, - { - "body": "There is always some madness in love. But there is also always some reason in madness.", - "tags": [ - "love" - ] - }, - { - "body": "There are horrible people who, instead of solving a problem, tangle it up and make it harder to solve for anyone who wants to deal with it. Whoever does not know how to hit the nail on the head should be asked not to hit it at all.", - "tags": [] - }, - { - "body": "What is the truth, but a lie agreed upon.", - "tags": [] - }, - { - "body": "You know a moment is important when it is making your mind go numb with beauty.", - "tags": [ - "knowledge", - "love" - ] - }, - { - "body": "Invisible threads are the strongest ties.", - "tags": [ - "ethics" - ] - }, - { - "body": "The most spiritual men, as the strongest, find their happiness where others would find their destruction: in the labyrinth, in hardness against themselves and others, in experiments. Their joy is self-conquest: asceticism becomes in them nature, need, and instinct. Difficult tasks are a privilege to them; to play with burdens that crush others, a recreation. Knowledge-a form of asceticism. They are the most venerable kind of man: that does not preclude their being the most cheerful and the kindliest.", - "tags": [ - "knowledge" - ] - }, - { - "body": "To learn to see- to accustom the eye to calmness, to patience, and to allow things to come up to it; to defer judgment, and to acquire the habit of approaching and grasping an individual case from all sides. This is the first preparatory schooling of intellectuality. One must not respond immediately to a stimulus; one must acquire a command of the obstructing and isolating instincts.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "For what purpose humanity is there should not even concern us: why you are here, that you should ask yourself: and if you have no ready answer, then set for yourself goals, high and noble goals, and perish in pursuit of them!", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "He who obeys, does not listen to himself!", - "tags": [ - "ethics" - ] - }, - { - "body": "No journey is too great,", - "tags": [ - "ethics" - ] - }, - { - "body": "In revenge and in love, woman is more barbarous than man.", - "tags": [] - }, - { - "body": "People are always angry at anyone who chooses very individual standards for his life; because of the extraordinary treatment which that man grants to himself, they feel degraded, like ordinary beings.", - "tags": [ - "ethics" - ] - }, - { - "body": "Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar.", - "tags": [ - "politics", - "knowledge", - "ethics" - ] - }, - { - "body": "Without music, life would be a mistake.", - "tags": [] - }, - { - "body": "All I need is a sheet of paper and something to write with, and then I can turn the world upside down.", - "tags": [] - }, - { - "body": "Ultimately, it is the desire, not the desired, that we love.", - "tags": [ - "love", - "ethics" - ] - }, - { - "body": "What is evil?-Whatever springs from weakness.", - "tags": [] - }, - { - "body": "Beware of spitting against the wind!", - "tags": [ - "ethics" - ] - }, - { - "body": "Deception, flattering, lying, deluding, talking behind the back, putting up a false front, living in borrowed splendor, wearing a mask, hiding behind convention, playing a role for others and for oneself -- in short, a continuous fluttering around the solitary flame of vanity -- is so much the rule and the law among men that there is almost nothing which is less comprehensible than how an honest and pure drive for truth could have arisen among them.", - "tags": [] - }, - { - "body": "the voice of beauty speaks softly; it creeps only into the most fully awakened souls", - "tags": [ - "love", - "education" - ] - }, - { - "body": "Everyone needs a sense of shame, but no one needs to feel ashamed.", - "tags": [ - "ethics" - ] - }, - { - "body": "There exists above the \"productive\" man a yet higher species.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "For a tree to become tall it must grow tough roots among the rocks.", - "tags": [] - }, - { - "body": "The man of knowledge must be able not only to love his enemies but also to hate his friends.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "The growth of wisdom may be gauged exactly by the diminution of ill-temper.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Most people are too stupid to act in their own interest", - "tags": [] - }, - { - "body": "The visionary lies to himself, the liar only to others.", - "tags": [] - }, - { - "body": "It is the business of the very few to be independent; it is a privilege of the strong.", - "tags": [ - "ethics", - "knowledge", - "politics" - ] - }, - { - "body": "A moral system valid for all is basically immoral.", - "tags": [] - }, - { - "body": "Marriage was contrived for ordinary people, for people who are capable of neither great love nor great friendship, which is to say, for most people--but also for those exceptionally rare ones who are capable of love as well as of friendship.", - "tags": [] - }, - { - "body": "Shared joys make a friend, not shared sufferings.", - "tags": [ - "ethics" - ] - }, - { - "body": "What makes us heroic?--Confronting simultaneously our supreme suffering and our supreme hope.", - "tags": [] - } - ], - "plato": [ - { - "body": "No one is more hated than he who speaks the truth.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "A wise man speaks because he has something to say; a fool because he has to say something.", - "tags": [ - "ethics" - ] - }, - { - "body": "Be kind. Every person you meet", - "tags": [ - "ethics" - ] - }, - { - "body": "Better to complete a small task well, than to do much imperfectly.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "The right question is usually more important than the right answer.", - "tags": [ - "ethics" - ] - }, - { - "body": "Ignorance is the root cause of all difficulties.", - "tags": [] - }, - { - "body": "Someday, in the distant future, our grand-children' s grand-children will develop a new equivalent of our classrooms. They will spend many hours in front of boxes with fires glowing within. May they have the wisdom to know the difference between light and knowledge.", - "tags": [] - }, - { - "body": "I am the wisest man alive, for I know one thing, and that is that I know nothing.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "The one who learns and learns and doesn't practice is like the one who plows and plows and never plants.", - "tags": [ - "ethics" - ] - }, - { - "body": "The measure of a man is what he does with power.", - "tags": [ - "politics" - ] - }, - { - "body": "Wisest is he who knows what he does not know.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "Enjoy life. There's plenty of time to be dead. Be kind, for everyone you meet is fighting a harder battle.", - "tags": [ - "ethics" - ] - }, - { - "body": "Those who tell the stories rule society.", - "tags": [ - "history" - ] - }, - { - "body": "The worst of all deceptions is self-deception.", - "tags": [] - }, - { - "body": "You should not honor men more than truth.", - "tags": [ - "ethics" - ] - }, - { - "body": "One cannot make a slave of a free person, for a free person is free even in a prison.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "False words are not only evil in themselves, but they infect the soul with evil.", - "tags": [ - "ethics" - ] - }, - { - "body": "There is nothing so delightful as the hearing, or the speaking of truth. For this reason, there is no conversation so agreeable as that of the man of integrity, who hears without any intention to betray, and speaks without any intention to deceive.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "Poverty doesn't come because of the decrease of wealth but because of the increase of desires.", - "tags": [] - }, - { - "body": "Never discourage anyone who continually makes progress, no matter how slow... even if that someone is yourself!", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "Every heart sings a song, incomplete, until another heart whispers back.", - "tags": [ - "love" - ] - }, - { - "body": "A true artist is someone who gives birth to a new reality.", - "tags": [] - }, - { - "body": "The souls of people, on their way to Earth-life, pass through a room full of lights; each takes a taper - often only a spark - to guide it in the dim country of this world. But some souls, by rare fortune, are detained longer - have time to grasp a handful of tapers, which they weave into a torch. These are the torch-bearers of humanity - its poets, seers and saints, who lead and lift the race out of darkness, toward the light. They are the law-givers and saviors, the light-bringers, way-showers and truth-tellers, and without them, humanity would lose its way in the dark.", - "tags": [] - }, - { - "body": "We become what we contemplate.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "He who does not desire power is fit to hold it.", - "tags": [ - "politics", - "ethics" - ] - }, - { - "body": "The three wishes of every man: to be healthy, to be rich by honest means, and to be beautiful.", - "tags": [] - }, - { - "body": "Do not train children to learning by force and harshness, but direct them to it by what amuses their minds.", - "tags": [ - "ethics" - ] - }, - { - "body": "How can you prove whether at this moment we are sleeping, and all our thoughts are a dream; or whether we are awake, and talking to one another in the waking state?", - "tags": [] - }, - { - "body": "The philosopher is in love with truth, that is, not with the changing world of sensation, which is the object of opinion, but with the unchanging reality which is the object of knowledge.", - "tags": [ - "knowledge" - ] - }, - { - "body": "He who is only an athlete is too crude, too vulgar, too much a savage. He who is a scholar only is too soft, to effeminate. The ideal citizen is the scholar athlete, the man of thought and the man of action.", - "tags": [ - "ethics" - ] - }, - { - "body": "I know not how I may seem to others, but to myself I am but a small child wandering upon the vast shores of knowledge, every now and then finding a small bright pebble to content myself with", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "He who love touches walks not in darkness.", - "tags": [ - "love", - "ethics", - "knowledge" - ] - }, - { - "body": "Pleasure is the bait of sin", - "tags": [] - }, - { - "body": "A good decision is based on knowledge, and not on numbers.", - "tags": [ - "knowledge", - "education" - ] - }, - { - "body": "When man is not properly trained, he is the most savage animal on the face of the globe.", - "tags": [ - "ethics" - ] - }, - { - "body": "Happiness springs from doing good and helping others.", - "tags": [ - "ethics" - ] - }, - { - "body": "One of the penalties for refusing to participate in politics is that you end up being governed by your inferiors.", - "tags": [ - "politics" - ] - }, - { - "body": "The blame is his who chooses: God is blameless.", - "tags": [ - "religion", - "ethics", - "knowledge" - ] - }, - { - "body": "Harmony sinks deep into the recesses of the soul and takes its strongest hold there, bringing grace also to the body & mind as well. Music is a moral law. It gives a soul to the universe, wings to the mind, flight to the imagination, a charm to sadness, and life to everything. It is the essence of order.", - "tags": [] - }, - { - "body": "Do not expect justice where might is right.", - "tags": [] - }, - { - "body": "When you feel grateful, you become great, and eventually attract great things.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "If we are to have any hope for the future, those who have lanterns must pass them on to others.", - "tags": [ - "ethics" - ] - }, - { - "body": "We see many instances of cities going down like sinking ships to their destruction. There have been such wrecks in the past and there surely will be others in the future, caused by the wickedness of captains and crews alike. For these are guilty men, whose sin is supreme ignorance of what matters most.", - "tags": [] - }, - { - "body": "Mankind will never see an end of trouble until lovers of wisdom come to hold political power, or the holders of power become lovers of wisdom", - "tags": [ - "politics", - "knowledge" - ] - }, - { - "body": "Those who are too smart to engage in politics are punished by being governed by those who are dumber.", - "tags": [ - "politics", - "knowledge" - ] - }, - { - "body": "A dog has the soul of a philosopher.", - "tags": [ - "ethics" - ] - }, - { - "body": "Thinking is the soul talking to itself.", - "tags": [] - }, - { - "body": "midwife to the awakening of the Soul in another person.", - "tags": [ - "love", - "knowledge" - ] - }, - { - "body": "All wars are fought for the sake of getting money.", - "tags": [] - } - ], - "sartre": [ - { - "body": "He who asks a question is a fool for a minute; he who does not remains a fool forever.", - "tags": [ - "ethics", - "education" - ] - }, - { - "body": "I can always choose, but I ought to know that if I do not choose, I", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "am still choosing.", - "tags": [ - "ethics" - ] - }, - { - "body": "I hate victims who respect their executioners.", - "tags": [] - }, - { - "body": "Everything has been figured out, except how to live.", - "tags": [ - "knowledge" - ] - }, - { - "body": "your judgement judges you and defines you", - "tags": [] - }, - { - "body": "slipped out of the world, somewhere else like the soul of a dead man. Perhaps he was only a dream...God is dead.", - "tags": [] - }, - { - "body": "Nothingness haunts Being.", - "tags": [] - }, - { - "body": "To choose not to choose is still to act.", - "tags": [ - "ethics" - ] - }, - { - "body": "Death is a continuation of my life without me.", - "tags": [ - "history" - ] - }, - { - "body": "In a word, man must create his own essence: it is in throwing himself into the world, suffering there, struggling there, that he gradually defines himself.", - "tags": [ - "ethics" - ] - }, - { - "body": "Imagination is not an empirical or superadded power of consciousness, it is the whole of consciousness as it realizes its freedom.", - "tags": [] - }, - { - "body": "I am no longer sure of anything. If I satiate my desires, I sin but I deliver myself from them; if I refuse to satisfy them, they infect the whole soul.", - "tags": [ - "ethics" - ] - }, - { - "body": "To believe is to know you believe, and to know you believe is not to believe.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "The more one is absorbed in fighting evil, the less one is tempted to place the good in question.", - "tags": [ - "ethics" - ] - }, - { - "body": "My thought is me: that's why I can't stop. I exist because I think", - "tags": [ - "ethics", - "knowledge", - "history" - ] - }, - { - "body": "Acting is a question of absorbing other people's personalities and adding some of your own experience.", - "tags": [] - }, - { - "body": "She believed in nothing; only her skepticism kept her from being an atheist.", - "tags": [] - }, - { - "body": "and without resignation either. He stares at death with passionate attention and this fascination liberates him. He experiences the divine irresponsibility of the condemned man.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "It disturbs me no more to find men base, unjust, or selfish than to see apes mischievous, wolves savage, or the vulture ravenous.", - "tags": [] - }, - { - "body": "Every human endeavor, however singular it seems, involves the whole human race.", - "tags": [] - }, - { - "body": "Thats what existence means: draining ones own self dry without the sense of thirst.", - "tags": [] - }, - { - "body": "If all I asked was not a great deal, that's my problem!", - "tags": [ - "ethics", - "education" - ] - }, - { - "body": "A madman's ravings are absurd in relation to the situation in which he finds himself, but not in relation to his madness.", - "tags": [] - }, - { - "body": "The viable jewels of life remain untouched when man forgets his vocation of searching for the truth of his existence.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Photographs are not ideas. They give us ideas.", - "tags": [] - }, - { - "body": "Smooth and smiling faces everywhere, but ruin in their eyes.", - "tags": [ - "politics" - ] - }, - { - "body": "Be quiet! Anyone can spit in my face, and call me a criminal and a prostitute. But no one has the right to judge my remorse.", - "tags": [ - "ethics", - "knowledge", - "politics" - ] - }, - { - "body": "I found the human heart empty and insipid everywhere except in books.", - "tags": [ - "knowledge" - ] - }, - { - "body": "I wanted pure love: foolishness; to love one another is to hate a common enemy: I will thus espouse your hatred. I wanted Good: nonsense; on this earth and in these times, Good and Bad are inseparable: I accept to be evil in order to become good.", - "tags": [ - "love", - "politics" - ] - }, - { - "body": "As for the square at Meknes, where I used to go every day, it's even simpler: I do not see it at all anymore. All that remains is the vague feeling that it was charming, and these five words that are indivisibly bound together: a charming square at Meknes. ... I don't see anything any more: I can search the past in vain, I can only find these scraps of images and I am not sure what they represent, whether they are memories or just fiction.", - "tags": [ - "history" - ] - }, - { - "body": "I think that is the big danger in keeping a diary: you exaggerate everything.", - "tags": [] - }, - { - "body": "To keep hope alive one must, in spite of all mistakes, horrors, and crimes, recognize the obvious superiority of the socialist camp.", - "tags": [ - "politics", - "knowledge" - ] - }, - { - "body": "I have such a desire to sleep and am so much behind my sleep. A good night, one good night and all this nonsense will be swept away.", - "tags": [] - }, - { - "body": "Acting is happy agony.", - "tags": [] - }, - { - "body": "Being is. Being is in-itself. Being is what it is.", - "tags": [ - "history", - "knowledge", - "ethics" - ] - }, - { - "body": "Generosity is nothing else than a craze to possess. All which I abandon, all which I give, I enjoy in a higher manner through the fact that I give it away. To give is to enjoy possessively the object which one gives.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "Take [Stphane] Mallarme. I hold him to be the greatest of French poets, and I have taken some time to understand him !", - "tags": [ - "knowledge" - ] - }, - { - "body": "I am neither virgin nor priest enough to play with the inner life.", - "tags": [ - "ethics" - ] - }, - { - "body": "To think new thoughts you have to break the bones in your head", - "tags": [] - }, - { - "body": "I needed to justify my existence, and I had made an absolute of literature. It took me thirty years to get rid of this state of mind.", - "tags": [] - }, - { - "body": "Fear? If I have gained anything by damning myself, it is that I no longer have anything to fear.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "as not-bound to life.", - "tags": [] - }, - { - "body": "One could only damage oneself through the harm one did to others. One could never get directly at oneself.", - "tags": [ - "ethics" - ] - }, - { - "body": "Absurd, irreducible; nothing not even a profound and secret delirium of nature could explain it. Obviously I did not know everything, I had not seen the seeds sprout, or the tree grow. But faced with this great wrinkled paw, neither ignorance nor knowledge was important: the world of explanations and reasons is not the world of existence. A circle is not absurd, it is clearly explained by the rotation of a straight segment around one of its extremities. But neither does a circle exist. This root, on the other hand, existed in such a way that I could not explain it.", - "tags": [] - }, - { - "body": "I am not recommending \"popular\" literature which aims at the lowest.", - "tags": [] - }, - { - "body": "Men equally honest, equally devoted to their fatherland, are momentarily separated by different conceptions of their duty.", - "tags": [ - "ethics" - ] - }, - { - "body": "Better to have beasts that let themselves be killed than men who run away.", - "tags": [ - "ethics" - ] - }, - { - "body": "Render a kiss or blow", - "tags": [ - "love" - ] - }, - { - "body": "Offer all the hatred in your heart", - "tags": [] - } - ], - "schopenhauer": [ - { - "body": "It is difficult to find happiness within oneself, but it is impossible to find it anywhere else.", - "tags": [] - }, - { - "body": "A high degree of intellect tends to make a man unsocial.", - "tags": [ - "knowledge" - ] - }, - { - "body": "It is difficult to keep quiet if you have nothing to do", - "tags": [ - "ethics" - ] - }, - { - "body": "The assumption that animals are without rights, and the illusion that our treatment of them has no moral significance, is a positively outrageous example of Western crudity and barbarity. Universal compassion is the only guarantee of morality.", - "tags": [] - }, - { - "body": "I observed once to Goethe that when a friend is with us we do not think the same of him as when he is away. He replied, \"Yes! because the absent friend is yourself, and he exists only in your head; whereas the friend who is present has an individuality of his own, and moves according to laws of his own, which cannot always be in accordance with those which you form for yourself.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Every man takes the limits of his own field of vision for the limits of the world.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "Thus, the task is not so much to see what no one yet has seen, but to think what nobody yet has thought about that which everybody sees.", - "tags": [ - "knowledge" - ] - }, - { - "body": "Pleasure is never as pleasant as we expected it to be and pain is always more painful. The pain in the world always outweighs the pleasure. If you don't believe it, compare the respective feelings of two animals, one of which is eating the other.", - "tags": [] - }, - { - "body": "at the death of every friendly soul", - "tags": [ - "history" - ] - }, - { - "body": "arises from the feeling that there is", - "tags": [] - }, - { - "body": "To be alone is the fate of all great mindsa fate deplored at times, but still always chosen as the less grievous of two evils.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "However, for the man who studies to gain insight, books and studies are merely rungs of the ladder on which he climbs to the summit of knowledge. As soon as a rung has raised him up one step, he leaves it behind. On the other hand, the many who study in order to fill their memory do not use the rungs of the ladder for climbing, but take them off and load themselves with them to take away, rejoicing at the increasing weight of the burden. They remain below forever, because they bear what should have bourne them.", - "tags": [ - "knowledge", - "education" - ] - }, - { - "body": "There is not a grain of dust, not an atom that can become nothing, yet man believes that death is the annhilation of his being.", - "tags": [ - "ethics", - "religion" - ] - }, - { - "body": "Human life, like all inferior goods, is covered on the outside with a false glitter; what suffers always conceals itself.", - "tags": [ - "ethics" - ] - }, - { - "body": "Just as one spoils the stomach by overfeeding and thereby impairs the whole body, so can one overload and choke the mind by giving it too much nourishment. For the more one reads the fewer are the traces left of what one has read; the mind is like a tablet that has been written over and over. Hence it is impossible to reflect; and it is only by reflection that one can assimilate what one has read. If one reads straight ahead without pondering over it later, what has been read does not take root, but is for the most part lost.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "The highest, most varied and lasting pleasures are those of the mind.", - "tags": [] - }, - { - "body": "We seldom speak of what we have but often of what we lack.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Patriotism is the passion of fools and the most foolish of passions.", - "tags": [] - }, - { - "body": "Truth that is naked is the most beautiful, and the simpler its expression the deeper is the impression it makes.", - "tags": [ - "ethics", - "education" - ] - }, - { - "body": "Restlessness is the hallmark of existence.", - "tags": [] - }, - { - "body": "Men best show their character in trifles, where they are not on their guard. It is in the simplest habits, that we often see the boundless egotism which pays no regard to the feelings of others and denies nothing to itself.", - "tags": [] - }, - { - "body": "Because Christian morality leaves animals out of account, they are at once outlawed in philosophical morals; they are mere 'things,' mere means to any ends whatsoever. They can therefore be used for vivisection, hunting, coursing, bullfights, and horse racing, and can be whipped to death as they struggle along with heavy carts of stone. Shame on such a morality that is worthy of pariahs, and that fails to recognize the eternal essence that exists in every living thing, and shines forth with inscrutable significance from all eyes that see the sun!", - "tags": [] - }, - { - "body": "Whoever wants his judgment to be believed, should express it coolly and dispassionately; for all vehemence springs from the will. And so the judgment might be attributed to the will and not to knowledge, which by its nature is cold.", - "tags": [ - "ethics" - ] - }, - { - "body": "Our moral virtues benefit mainly other people; intellectual virtues, on the other hand, benefit primarily ourselves; therefore the former make us universally popular, the latter unpopular.", - "tags": [ - "ethics" - ] - }, - { - "body": "The difficulty is to try and teach the multitude that something can be true and untrue at the same time.", - "tags": [ - "education", - "ethics" - ] - }, - { - "body": "Life to the great majority is only a constant struggle for mere existence, with the certainty of losing it at last.", - "tags": [] - }, - { - "body": "The scenes and events of long ago, and the persons who took part in them, wear a charming aspect to the eye of memory, which sees only the outlines and takes no note of disagreeable details. The present enjoys no such advantage, and so it always seems defective.", - "tags": [ - "history", - "knowledge" - ] - }, - { - "body": "The effect of music is so very much more powerful and penetrating than is that of the other arts, for these others speak only of the shadow, but music of the essence.", - "tags": [] - }, - { - "body": "To become indignant at [people's] conduct is as foolish as to be angry with a stone because it rolls into your path. And with many people the wisest thing you can do, is to resolve to make use of those whom you cannot alter.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Necessity is the constant scourge of the lower classes, ennui of the higher ones.", - "tags": [] - }, - { - "body": "It is most important to allow the brain the full measure of sleep which is required to restore it; for sleep is to a man's whole nature what winding up is to a clock.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "It is with trifles, and when he is off guard, that a man best reveals his character.", - "tags": [] - }, - { - "body": "A man of business will often deceive you without the slightest scruple, but he will absolutely refuse to commit a theft.", - "tags": [] - }, - { - "body": "The ultimate foundation of honor is the conviction that moral character is unalterable: a single bad action implies that future actions of the same kind will, under similar circumstances, also be bad.", - "tags": [ - "ethics" - ] - }, - { - "body": "I've never known any trouble than an hour's reading didn't assuage.", - "tags": [] - }, - { - "body": "What makes people hard-hearted is this, that each man has, or fancies he has, as much as he can bear in his own troubles.", - "tags": [ - "ethics" - ] - }, - { - "body": "A good supply of resignation is of the first importance in providing for the journey of life.", - "tags": [ - "ethics" - ] - }, - { - "body": "To desire immortality for the individual is really the same as wanting to perpetuate an error forever.", - "tags": [ - "ethics" - ] - }, - { - "body": "The cause of laughter is simply the sudden perception of the incongruity between a concept and the real project.", - "tags": [] - }, - { - "body": "He who can see truly in the midst of general infatuation is like a man whose watch keeps good time, when all clocks in the town in which he lives are wrong. He alone knows the right time; what use is that to him?", - "tags": [ - "knowledge", - "love" - ] - }, - { - "body": "If a person is stupid, we excuse him by saying that he cannot help it; but if we attempted to excuse in precisely the same way the person who is bad, we should be laughed at.", - "tags": [ - "ethics" - ] - }, - { - "body": "My body and my will are one.", - "tags": [] - }, - { - "body": "The ordinary method of education is to imprint ideas and opinions, in the strict sense of the word, prejudices, on the mind of the child, before it has had any but a very few particular observations. It is thus that he afterwards comes to view the world and gather experience through the medium of those ready-made ideas, rather than to let his ideas be formed for him out of his own experience of life, as they ought to be.", - "tags": [ - "education" - ] - }, - { - "body": "One can never read too little of bad, or too much of good books: bad books are intellectual poison; they destroy the mind. In order to read what is good one must make it a condition never to read what is bad; for life is short, and both time and strength limited.", - "tags": [ - "knowledge", - "ethics", - "education" - ] - }, - { - "body": "Many undoubtedly owe their good fortune to the circumstance that they possess a pleasing smile with which they win hearts. Yet these hearts would do better to beware and to learn from Hamlet's tables that one may smile, and smile, and be a villain.", - "tags": [ - "knowledge", - "education", - "ethics" - ] - }, - { - "body": "In the blessings as well as in the ills of life, less depends upon what befalls us than upon the way in which it is met.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "It is only a man's own fundamental thoughts that have truth and life in them. For it is these that he really and completely understands. To read the thoughts of others is like taking the remains of someone else's meal, like putting on the discarded clothes of a stranger.", - "tags": [ - "knowledge", - "ethics", - "education", - "history", - "love" - ] - }, - { - "body": "There is no absurdity so palpable but that it may be firmly planted in the human head if you only begin to inculcate it before the age of five, by constantly repeating it with an air of great solemnity.", - "tags": [] - }, - { - "body": "Thus also every keen pleasure is an error and an illusion, for no attained wish can give lasting satisfaction.", - "tags": [ - "ethics" - ] - }, - { - "body": "It is a clumsy experiment to make; for it involves the destruction of the very consciousness which puts the question and awaits the answer.", - "tags": [] - } - ], - "spinoza": [ - { - "body": "Nothing in nature is by chance... Something appears to be chance only because of our lack of knowledge.", - "tags": [] - }, - { - "body": "When a man is prey to his emotions, he is not his own master.", - "tags": [ - "ethics" - ] - }, - { - "body": "The more clearly you understand yourself and your emotions, the more you become a lover of what is.", - "tags": [ - "love", - "knowledge", - "education" - ] - }, - { - "body": "He who seeks equality between unequals seeks an absurdity.", - "tags": [ - "politics" - ] - }, - { - "body": "Academies that are founded at public expense are instituted not so much to cultivate men's natural abilities as to restrain them.", - "tags": [ - "education", - "knowledge" - ] - }, - { - "body": "Hatred is increased by being reciprocated, and can on the other hand be destroyed by love.", - "tags": [ - "love" - ] - }, - { - "body": "Big fish eat small fish with as much right as they have power.", - "tags": [ - "politics" - ] - }, - { - "body": "Indulge yourself in pleasures only in so far as they are necessary for the preservation of health.", - "tags": [ - "ethics" - ] - }, - { - "body": "[Believers] are but triflers who, when they cannot explain a thing, run back to the will of God; this is, truly, a ridiculous way of expressing ignorance.", - "tags": [ - "religion" - ] - }, - { - "body": "Let unswerving integrity be your watchword.", - "tags": [ - "ethics" - ] - }, - { - "body": "I have made a ceaseless effort not to ridicule, not to bewail, not to scorn human actions, but to understand them.", - "tags": [ - "knowledge", - "education", - "ethics" - ] - }, - { - "body": "Sadness diminishes a man's powers", - "tags": [] - }, - { - "body": "What everyone wants from life is continuous and genuine happiness.", - "tags": [] - }, - { - "body": "Nature is satisfied with little; and if she is, I am also.", - "tags": [ - "ethics" - ] - }, - { - "body": "He who loves God cannot endeavor that God should love him in return.", - "tags": [ - "ethics", - "religion", - "love", - "knowledge" - ] - }, - { - "body": "Laws which prescribe what everyone must believe, and forbid men to say or write anything against this or that opinion, are often passed to gratify, or rather to appease the anger of those who cannot abide independent minds.", - "tags": [ - "politics" - ] - }, - { - "body": "Further conceive, I beg, that a stone, while continuing in motion, should be capable of thinking and knowing, that it is endeavoring, as far as it can, to continue to move. Such a stone, being conscious merely of its own endeavor and not at all indifferent, would believe itself to be completely free, and would think that it continued in motion solely because of its own wish. This is that human freedom, which all boast that they possess, and which consists solely in the fact, that men are conscious of their own desire, but are ignorant of the causes whereby that desire has been determined.", - "tags": [] - }, - { - "body": "The supreme mystery of despotism, its prop and stay, is to keep men in a state of deception, and with the specious title of religion to cloak the fear by which they must be held in check, so that they will fight for their servitude as if for salvation.", - "tags": [ - "religion" - ] - }, - { - "body": "the ultimate aim of government is not to rule, or restrain by fear, nor to exact obedience, but to free every man from fear that he may live in all possible security... In fact the true aim of government is liberty.", - "tags": [ - "ethics", - "knowledge" - ] - }, - { - "body": "Everything excellent is as difficult as it is rare.", - "tags": [] - }, - { - "body": "Everything in nature is a cause from which there flows some effect.", - "tags": [] - }, - { - "body": "Blessed are the weak who think that they are good because they have no claws.", - "tags": [] - }, - { - "body": "God is the indwelling and not the transient cause of all things.", - "tags": [ - "religion" - ] - }, - { - "body": "The greatest secret of monarchic rule...is to keep men deceived and to cloak in the specious name of religion the fear by which they must be checked, so that they will fight for slavery as they would for salvation, and will think it not shameful, but a most honorable achievement, to give their life and blood that one man may have a ground for boasting.", - "tags": [ - "politics" - ] - }, - { - "body": "All is One (Nature, God)", - "tags": [] - }, - { - "body": "Faith is nothing but obedience and piety.", - "tags": [ - "religion" - ] - }, - { - "body": "The more intelligible a thing is, the more easily it is retained in the memory, and counterwise, the less intelligible it is, the more easily we forget it.", - "tags": [ - "knowledge", - "education", - "history", - "ethics" - ] - }, - { - "body": "Those who wish to seek out the cause of miracles and to understand the things of nature as philosophers, and not to stare at them in astonishment like fools, are soon considered heretical and impious, and proclaimed as such by those whom the mob adores as the interpreters of nature and the gods.", - "tags": [] - }, - { - "body": "It is usually the case with most men that their nature is so constituted that they pity those who fare badly and envy those who fare well.", - "tags": [] - }, - { - "body": "Fame has also this great drawback, that if we pursue it, we must direct our lives so as to please the fancy of men.", - "tags": [] - }, - { - "body": "In the mind there is no absolute or free will.", - "tags": [] - }, - { - "body": "None are more taken in by flattery than the proud, who wish to be the first and are not.", - "tags": [] - }, - { - "body": "I have tried sedulously not to laugh at the acts of man, nor to lament them, nor to detest them, but to understand them.", - "tags": [ - "knowledge", - "education", - "ethics" - ] - }, - { - "body": "Nothing in the universe is contingent, but all things are conditioned to exist and operate in a particular manner by the necessity of the divine nature.", - "tags": [ - "religion", - "knowledge", - "ethics" - ] - }, - { - "body": "If men were born free, they would, so long as they remained free, form no conception of good and evil.", - "tags": [ - "ethics" - ] - }, - { - "body": "In so far as the mind sees things in their eternal aspect, it participates in eternity.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "them.", - "tags": [ - "knowledge", - "ethics" - ] - }, - { - "body": "Many errors, of a truth, consist merely in the application of the wrong names of things.", - "tags": [] - }, - { - "body": ".... we are a part of nature as a whole, whose order we follow.", - "tags": [] - }, - { - "body": "Men will find that they can ... avoid far more easily the perils which beset them on all sides by united action.", - "tags": [ - "ethics", - "politics", - "knowledge" - ] - }, - { - "body": "The order and connection of ideas is the same as the order and connection of things.", - "tags": [] - }, - { - "body": "Desire is the essence of a man.", - "tags": [] - }, - { - "body": "Love is pleasure accompanied by the idea of an external cause, and hatred pain accompanied by the idea of an external cause.", - "tags": [ - "love" - ] - }, - { - "body": "He that can carp in the most eloquent or acute manner at the weakness of the human mind is held by his fellows as almost divine.", - "tags": [] - }, - { - "body": "Emotion, which is suffering, ceases to be suffering as soon as we form a clear and precise picture of it.", - "tags": [] - }, - { - "body": "Better that right counsels be known to enemies than that the evil secrets of tyrants should be concealed from the citizens. They who can treat secretly of the affairs of a nation have it absolutely under their authority; and as they plot against the enemy in time of war, so do they against the citizens in time of peace.", - "tags": [ - "knowledge", - "ethics", - "politics" - ] - }, - { - "body": "A man is as much affected pleasurably or painfully by the image of a thing past or future as by the image of a thing present.", - "tags": [ - "history" - ] - }, - { - "body": "Love or hatred towards a thing, which we conceive to be free, must, other things being similar, be greater than if it were felt towards a thing acting by necessity.", - "tags": [ - "ethics" - ] - }, - { - "body": "Only that thing is free which exists by the necessities of its own nature, and is determined in its actions by itself alone.", - "tags": [ - "ethics" - ] - }, - { - "body": "Men would never be superstitious, if they could govern all their circumstances by set rules, or if they were always favoured by fortune: but being frequently driven into straits where rules are useless, and being often kept fluctuating pitiably between hope and fear by the uncertainty of fortune's greedily coveted favours, they are consequently for the most part, very prone to credulity.", - "tags": [] - } - ] - } -} diff --git a/astra-db-client/src/test/resources/philosopher-quotes.csv b/astra-db-client/src/test/resources/philosopher-quotes.csv deleted file mode 100644 index 22d903a2..00000000 --- a/astra-db-client/src/test/resources/philosopher-quotes.csv +++ /dev/null @@ -1,452 +0,0 @@ -/Users/cedricklunven/.sdkman/candidates/java/22.3.1.r17-grl/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=53151:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/cedricklunven/.m2/repository/org/junit/platform/junit-platform-launcher/1.10.0/junit-platform-launcher-1.10.0.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-test/target/test-classes:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-test/target/classes:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk/target/classes:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-document/target/classes:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-commons/target/classes:/Users/cedricklunven/.m2/repository/com/evanlennick/retry4j/0.15.0/retry4j-0.15.0.jar:/Users/cedricklunven/.m2/repository/org/apache/httpcomponents/client5/httpclient5/5.2.1/httpclient5-5.2.1.jar:/Users/cedricklunven/.m2/repository/org/apache/httpcomponents/core5/httpcore5/5.2/httpcore5-5.2.jar:/Users/cedricklunven/.m2/repository/org/apache/httpcomponents/core5/httpcore5-h2/5.2/httpcore5-h2-5.2.jar:/Users/cedricklunven/.m2/repository/org/apache/httpcomponents/client5/httpclient5-fluent/5.2.1/httpclient5-fluent-5.2.1.jar:/Users/cedricklunven/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar:/Users/cedricklunven/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar:/Users/cedricklunven/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.2/jackson-datatype-jsr310-2.15.2.jar:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-grpc/target/classes:/Users/cedricklunven/.m2/repository/io/stargate/grpc/grpc-proto/2.0.17/grpc-proto-2.0.17.jar:/Users/cedricklunven/.m2/repository/io/projectreactor/reactor-core/3.4.13/reactor-core-3.4.13.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-protobuf/1.55.1/grpc-protobuf-1.55.1.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-api/1.55.1/grpc-api-1.55.1.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-context/1.55.1/grpc-context-1.55.1.jar:/Users/cedricklunven/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/cedricklunven/.m2/repository/com/google/protobuf/protobuf-java/3.22.3/protobuf-java-3.22.3.jar:/Users/cedricklunven/.m2/repository/com/google/api/grpc/proto-google-common-protos/2.9.0/proto-google-common-protos-2.9.0.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-protobuf-lite/1.55.1/grpc-protobuf-lite-1.55.1.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-stub/1.55.1/grpc-stub-1.55.1.jar:/Users/cedricklunven/.m2/repository/com/salesforce/servicelibs/reactor-grpc-stub/1.2.3/reactor-grpc-stub-1.2.3.jar:/Users/cedricklunven/.m2/repository/com/salesforce/servicelibs/reactive-grpc-common/1.2.3/reactive-grpc-common-1.2.3.jar:/Users/cedricklunven/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-netty-shaded/1.56.1/grpc-netty-shaded-1.56.1.jar:/Users/cedricklunven/.m2/repository/com/google/guava/guava/31.1-android/guava-31.1-android.jar:/Users/cedricklunven/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/Users/cedricklunven/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/cedricklunven/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar:/Users/cedricklunven/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/Users/cedricklunven/.m2/repository/com/google/errorprone/error_prone_annotations/2.18.0/error_prone_annotations-2.18.0.jar:/Users/cedricklunven/.m2/repository/io/perfmark/perfmark-api/0.26.0/perfmark-api-0.26.0.jar:/Users/cedricklunven/.m2/repository/io/grpc/grpc-core/1.56.1/grpc-core-1.56.1.jar:/Users/cedricklunven/.m2/repository/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar:/Users/cedricklunven/.m2/repository/com/google/android/annotations/4.1.1.4/annotations-4.1.1.4.jar:/Users/cedricklunven/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.23/animal-sniffer-annotations-1.23.jar:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-rest/target/classes:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-graphql/target/classes:/Users/cedricklunven/.m2/repository/com/netflix/graphql/dgs/codegen/graphql-dgs-codegen-client-core/5.1.17/graphql-dgs-codegen-client-core-5.1.17.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.31/kotlin-stdlib-jdk8-1.5.31.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.5.31/kotlin-stdlib-1.5.31.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.31/kotlin-stdlib-common-1.5.31.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.31/kotlin-stdlib-jdk7-1.5.31.jar:/Users/cedricklunven/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.5.31/kotlin-reflect-1.5.31.jar:/Users/cedricklunven/.m2/repository/org/reflections/reflections/0.10.2/reflections-0.10.2.jar:/Users/cedricklunven/.m2/repository/org/javassist/javassist/3.28.0-GA/javassist-3.28.0-GA.jar:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-cql/target/classes:/Users/cedricklunven/.m2/repository/com/datastax/oss/java-driver-core/4.17.0/java-driver-core-4.17.0.jar:/Users/cedricklunven/.m2/repository/com/datastax/oss/native-protocol/1.5.1/native-protocol-1.5.1.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-handler/4.1.94.Final/netty-handler-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-common/4.1.94.Final/netty-common-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-resolver/4.1.94.Final/netty-resolver-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-buffer/4.1.94.Final/netty-buffer-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-transport/4.1.94.Final/netty-transport-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.94.Final/netty-transport-native-unix-common-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/io/netty/netty-codec/4.1.94.Final/netty-codec-4.1.94.Final.jar:/Users/cedricklunven/.m2/repository/com/datastax/oss/java-driver-shaded-guava/25.1-jre-graal-sub-1/java-driver-shaded-guava-25.1-jre-graal-sub-1.jar:/Users/cedricklunven/.m2/repository/com/typesafe/config/1.4.1/config-1.4.1.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jnr-posix/3.1.15/jnr-posix-3.1.15.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jnr-ffi/2.2.11/jnr-ffi-2.2.11.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jffi/1.3.9/jffi-1.3.9.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jffi/1.3.9/jffi-1.3.9-native.jar:/Users/cedricklunven/.m2/repository/org/ow2/asm/asm/9.2/asm-9.2.jar:/Users/cedricklunven/.m2/repository/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar:/Users/cedricklunven/.m2/repository/org/ow2/asm/asm-analysis/9.2/asm-analysis-9.2.jar:/Users/cedricklunven/.m2/repository/org/ow2/asm/asm-tree/9.2/asm-tree-9.2.jar:/Users/cedricklunven/.m2/repository/org/ow2/asm/asm-util/9.2/asm-util-9.2.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jnr-a64asm/1.0.0/jnr-a64asm-1.0.0.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar:/Users/cedricklunven/.m2/repository/com/github/jnr/jnr-constants/0.10.3/jnr-constants-0.10.3.jar:/Users/cedricklunven/.m2/repository/io/dropwizard/metrics/metrics-core/4.1.18/metrics-core-4.1.18.jar:/Users/cedricklunven/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar:/Users/cedricklunven/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar:/Users/cedricklunven/.m2/repository/com/github/stephenc/jcip/jcip-annotations/1.0-1/jcip-annotations-1.0-1.jar:/Users/cedricklunven/.m2/repository/com/github/spotbugs/spotbugs-annotations/3.1.12/spotbugs-annotations-3.1.12.jar:/Users/cedricklunven/dev/datastax/sdk/stargate-sdk-java/stargate-sdk-json/target/classes:/Users/cedricklunven/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar:/Users/cedricklunven/.m2/repository/org/junit/jupiter/junit-jupiter/5.10.0/junit-jupiter-5.10.0.jar:/Users/cedricklunven/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.10.0/junit-jupiter-params-5.10.0.jar:/Users/cedricklunven/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.10.0/junit-jupiter-engine-5.10.0.jar:/Users/cedricklunven/.m2/repository/org/junit/platform/junit-platform-engine/1.10.0/junit-platform-engine-1.10.0.jar:/Users/cedricklunven/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/cedricklunven/.m2/repository/org/junit/platform/junit-platform-commons/1.10.0/junit-platform-commons-1.10.0.jar:/Users/cedricklunven/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.10.0/junit-jupiter-api-5.10.0.jar:/Users/cedricklunven/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/cedricklunven/.m2/repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar:/Users/cedricklunven/.m2/repository/ch/qos/logback/logback-classic/1.4.11/logback-classic-1.4.11.jar:/Users/cedricklunven/.m2/repository/ch/qos/logback/logback-core/1.4.11/logback-core-1.4.11.jar:/Users/cedricklunven/.m2/repository/org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar:/Users/cedricklunven/.m2/repository/org/json/json/20210307/json-20210307.jar:/Users/cedricklunven/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 io.stargate.test.json.HugginFace,shoudConvertCsv -author,quote,tags -aristotle,"True happiness comes from gaining insight and growing into your best possible self. Otherwise all you're having is immediate gratification pleasure, which is fleeting and doesn't grow you as a person.",knowledge -aristotle,"The roots of education are bitter, but the fruit is sweet.",education;knowledge -aristotle,"Before you heal the body you must first heal the mind",ethics -aristotle,"The proof that you know something is that you are able to teach it",education;knowledge -aristotle,"Those who are not angry at the things they should be angry at are thought to be fools, and so are those who are not angry in the right way, at the right time, or with the right persons.", -aristotle,"Whatever we learn to do, we learn by actually doing it; men come to be builders, for instance, by building, and harp players by playing the harp. In the same way, by doing just acts we come to be just; by doing self-controlled acts, we come to be self-controlled ; and by doing brave acts, we become brave.",education;knowledge -aristotle,"The greatest thing by far is to be a master of metaphor; it is the one thing that cannot be learned from others; and it is also a sign of genius, since a good metaphor implies an intuitive perception of the similarity of the dissimilar.", -aristotle,"The society that loses its grip on the past is in danger, for it produces men who know nothing but the present, and who are not aware that life had been, and could be, different from what it is.",history;ethics;knowledge -aristotle,"The man who is truly good and wise will bear with dignity whatever fortune sends, and will always make the best of his circumstances.",knowledge;ethics -aristotle,"The greatest of all pleasures is the pleasure of learning.",knowledge;education;history -aristotle,"Fortune favours the bold.", -aristotle,"You are what you repeatedly do", -aristotle,"The quality of life is determined by its activities.", -aristotle,"You are what you do repeatedly.", -aristotle,"Anyone who has no need of anybody but himself is either a beast or a God.", -aristotle,"Love is composed of a single soul inhabiting two bodies.",love -aristotle,"Love well, be loved and do something of value.",love;ethics -aristotle,"Philosophy begins with wonder.", -aristotle,"Plato is my friend, but truth is a better friend.", -aristotle,"At his best, man is the noblest of all animals; separated from law and justice he is the worst.",ethics -aristotle,"A promise made must be a promise kept.",ethics -aristotle,"It is better for a city to be governed by a good man than by good laws.",politics;ethics -aristotle,"Men become richer not only by increasing their existing wealth but also by decreasing their expenditure.", -aristotle,"Consider pleasures as they depart, not as they come.",ethics -aristotle,"Dignity does not consist in possessing honors, but in deserving them.",ethics -aristotle,"He who sees things grow from the beginning will have the best view of them.",knowledge;history;ethics;education -aristotle,"Happiness is the reward of virtue.",ethics -aristotle,"If you would understand anything, observe its beginning and its development",history;knowledge -aristotle,"A friend is another I.", -aristotle,"He who hath many friends hath none.",ethics -aristotle,"The hand is the tool of tools.", -aristotle,"Good moral character is not something that we can achieve on our own. We need a culture that supports the conditions under which self-love and friendship flourish.",ethics -aristotle,"We give up leisure in order that we may have leisure, just as we go to war in order that we may have peace.",ethics -aristotle,"We must be neither cowardly nor rash but courageous.",ethics;knowledge -aristotle,"The true nature of anything is what it becomes at its highest.",knowledge -aristotle,"To give away money is an easy matter and in any man's power. But to decide to whom to give it and how large and when, and for what purpose and how, is neither in every man's power nor an easy matter.",knowledge;ethics;politics -aristotle,"A man's happiness consists in the free exercise of his highest faculties.",knowledge;ethics;education -aristotle,"For what is the best choice for each individual is the highest it is possible for him to achieve.",knowledge;ethics;education -aristotle,"Those who act receive the prizes.",ethics -aristotle,"A man becomes a friend whenever being loved he loves in return.",love;ethics -aristotle,"Character is that which reveals moral purpose, exposing the class of things a man chooses and avoids.", -aristotle,"Bad men are full of repentance.",ethics -aristotle,"For we do not think that we know a thing until we are acquainted with its primary conditions or first principles, and have carried our analysis as far as its simplest elements.",knowledge -aristotle,"Philosophy can make people sick.",politics -aristotle,"Democracy appears to be safer and less liable to revolution than oligarchy. For in oligarchies there is the double danger of the oligarchs falling out among themselves and also with the people; but in democracies there is only the danger of a quarrel with the oligarchs. No dissension worth mentioning arises among the people themselves. And we may further remark that a government which is composed of the middle class more nearly approximates to democracy than to oligarchy, and is the safest of the imperfect forms of government.",politics;knowledge -aristotle,"Civil confusions often spring from trifles but decide great issues.",ethics;politics -aristotle,"All men by nature desire knowledge.",knowledge;education -aristotle,"But is it just then that the few and the wealthy should be the rulers? And what if they, in like manner, rob and plunder the people, - is this just?",politics;ethics -aristotle,"Definition of tragedy: A hero destroyed by the excess of his virtues", -aristotle,"Every rascal is not a thief, but every thief is a rascal.", -schopenhauer,"It is difficult to find happiness within oneself, but it is impossible to find it anywhere else.", -schopenhauer,"A high degree of intellect tends to make a man unsocial.",knowledge -schopenhauer,"It is difficult to keep quiet if you have nothing to do",ethics -schopenhauer,"The assumption that animals are without rights, and the illusion that our treatment of them has no moral significance, is a positively outrageous example of Western crudity and barbarity. Universal compassion is the only guarantee of morality.", -schopenhauer,"I observed once to Goethe that when a friend is with us we do not think the same of him as when he is away. He replied, ""Yes! because the absent friend is yourself, and he exists only in your head; whereas the friend who is present has an individuality of his own, and moves according to laws of his own, which cannot always be in accordance with those which you form for yourself.",knowledge;ethics -schopenhauer,"Every man takes the limits of his own field of vision for the limits of the world.",ethics;knowledge -schopenhauer,"Thus, the task is not so much to see what no one yet has seen, but to think what nobody yet has thought about that which everybody sees.",knowledge -schopenhauer,"Pleasure is never as pleasant as we expected it to be and pain is always more painful. The pain in the world always outweighs the pleasure. If you don't believe it, compare the respective feelings of two animals, one of which is eating the other.", -schopenhauer,"at the death of every friendly soul",history -schopenhauer,"arises from the feeling that there is", -schopenhauer,"To be alone is the fate of all great mindsa fate deplored at times, but still always chosen as the less grievous of two evils.",knowledge;ethics -schopenhauer,"However, for the man who studies to gain insight, books and studies are merely rungs of the ladder on which he climbs to the summit of knowledge. As soon as a rung has raised him up one step, he leaves it behind. On the other hand, the many who study in order to fill their memory do not use the rungs of the ladder for climbing, but take them off and load themselves with them to take away, rejoicing at the increasing weight of the burden. They remain below forever, because they bear what should have bourne them.",knowledge;education -schopenhauer,"There is not a grain of dust, not an atom that can become nothing, yet man believes that death is the annhilation of his being.",ethics;religion -schopenhauer,"Human life, like all inferior goods, is covered on the outside with a false glitter; what suffers always conceals itself.",ethics -schopenhauer,"Just as one spoils the stomach by overfeeding and thereby impairs the whole body, so can one overload and choke the mind by giving it too much nourishment. For the more one reads the fewer are the traces left of what one has read; the mind is like a tablet that has been written over and over. Hence it is impossible to reflect; and it is only by reflection that one can assimilate what one has read. If one reads straight ahead without pondering over it later, what has been read does not take root, but is for the most part lost.",knowledge;ethics -schopenhauer,"The highest, most varied and lasting pleasures are those of the mind.", -schopenhauer,"We seldom speak of what we have but often of what we lack.",knowledge;ethics -schopenhauer,"Patriotism is the passion of fools and the most foolish of passions.", -schopenhauer,"Truth that is naked is the most beautiful, and the simpler its expression the deeper is the impression it makes.",ethics;education -schopenhauer,"Restlessness is the hallmark of existence.", -schopenhauer,"Men best show their character in trifles, where they are not on their guard. It is in the simplest habits, that we often see the boundless egotism which pays no regard to the feelings of others and denies nothing to itself.", -schopenhauer,"Because Christian morality leaves animals out of account, they are at once outlawed in philosophical morals; they are mere 'things,' mere means to any ends whatsoever. They can therefore be used for vivisection, hunting, coursing, bullfights, and horse racing, and can be whipped to death as they struggle along with heavy carts of stone. Shame on such a morality that is worthy of pariahs, and that fails to recognize the eternal essence that exists in every living thing, and shines forth with inscrutable significance from all eyes that see the sun!", -schopenhauer,"Whoever wants his judgment to be believed, should express it coolly and dispassionately; for all vehemence springs from the will. And so the judgment might be attributed to the will and not to knowledge, which by its nature is cold.",ethics -schopenhauer,"Our moral virtues benefit mainly other people; intellectual virtues, on the other hand, benefit primarily ourselves; therefore the former make us universally popular, the latter unpopular.",ethics -schopenhauer,"The difficulty is to try and teach the multitude that something can be true and untrue at the same time.",education;ethics -schopenhauer,"Life to the great majority is only a constant struggle for mere existence, with the certainty of losing it at last.", -schopenhauer,"The scenes and events of long ago, and the persons who took part in them, wear a charming aspect to the eye of memory, which sees only the outlines and takes no note of disagreeable details. The present enjoys no such advantage, and so it always seems defective.",history;knowledge -schopenhauer,"The effect of music is so very much more powerful and penetrating than is that of the other arts, for these others speak only of the shadow, but music of the essence.", -schopenhauer,"To become indignant at [people's] conduct is as foolish as to be angry with a stone because it rolls into your path. And with many people the wisest thing you can do, is to resolve to make use of those whom you cannot alter.",knowledge;ethics -schopenhauer,"Necessity is the constant scourge of the lower classes, ennui of the higher ones.", -schopenhauer,"It is most important to allow the brain the full measure of sleep which is required to restore it; for sleep is to a man's whole nature what winding up is to a clock.",ethics;knowledge -schopenhauer,"It is with trifles, and when he is off guard, that a man best reveals his character.", -schopenhauer,"A man of business will often deceive you without the slightest scruple, but he will absolutely refuse to commit a theft.", -schopenhauer,"The ultimate foundation of honor is the conviction that moral character is unalterable: a single bad action implies that future actions of the same kind will, under similar circumstances, also be bad.",ethics -schopenhauer,"I've never known any trouble than an hour's reading didn't assuage.", -schopenhauer,"What makes people hard-hearted is this, that each man has, or fancies he has, as much as he can bear in his own troubles.",ethics -schopenhauer,"A good supply of resignation is of the first importance in providing for the journey of life.",ethics -schopenhauer,"To desire immortality for the individual is really the same as wanting to perpetuate an error forever.",ethics -schopenhauer,"The cause of laughter is simply the sudden perception of the incongruity between a concept and the real project.", -schopenhauer,"He who can see truly in the midst of general infatuation is like a man whose watch keeps good time, when all clocks in the town in which he lives are wrong. He alone knows the right time; what use is that to him?",knowledge;love -schopenhauer,"If a person is stupid, we excuse him by saying that he cannot help it; but if we attempted to excuse in precisely the same way the person who is bad, we should be laughed at.",ethics -schopenhauer,"My body and my will are one.", -schopenhauer,"The ordinary method of education is to imprint ideas and opinions, in the strict sense of the word, prejudices, on the mind of the child, before it has had any but a very few particular observations. It is thus that he afterwards comes to view the world and gather experience through the medium of those ready-made ideas, rather than to let his ideas be formed for him out of his own experience of life, as they ought to be.",education -schopenhauer,"One can never read too little of bad, or too much of good books: bad books are intellectual poison; they destroy the mind. In order to read what is good one must make it a condition never to read what is bad; for life is short, and both time and strength limited.",knowledge;ethics;education -schopenhauer,"Many undoubtedly owe their good fortune to the circumstance that they possess a pleasing smile with which they win hearts. Yet these hearts would do better to beware and to learn from Hamlet's tables that one may smile, and smile, and be a villain.",knowledge;education;ethics -schopenhauer,"In the blessings as well as in the ills of life, less depends upon what befalls us than upon the way in which it is met.",knowledge;ethics -schopenhauer,"It is only a man's own fundamental thoughts that have truth and life in them. For it is these that he really and completely understands. To read the thoughts of others is like taking the remains of someone else's meal, like putting on the discarded clothes of a stranger.",knowledge;ethics;education;history;love -schopenhauer,"There is no absurdity so palpable but that it may be firmly planted in the human head if you only begin to inculcate it before the age of five, by constantly repeating it with an air of great solemnity.", -schopenhauer,"Thus also every keen pleasure is an error and an illusion, for no attained wish can give lasting satisfaction.",ethics -schopenhauer,"It is a clumsy experiment to make; for it involves the destruction of the very consciousness which puts the question and awaits the answer.", -spinoza,"Nothing in nature is by chance... Something appears to be chance only because of our lack of knowledge.", -spinoza,"When a man is prey to his emotions, he is not his own master.",ethics -spinoza,"The more clearly you understand yourself and your emotions, the more you become a lover of what is.",love;knowledge;education -spinoza,"He who seeks equality between unequals seeks an absurdity.",politics -spinoza,"Academies that are founded at public expense are instituted not so much to cultivate men's natural abilities as to restrain them.",education;knowledge -spinoza,"Hatred is increased by being reciprocated, and can on the other hand be destroyed by love.",love -spinoza,"Big fish eat small fish with as much right as they have power.",politics -spinoza,"Indulge yourself in pleasures only in so far as they are necessary for the preservation of health.",ethics -spinoza,"[Believers] are but triflers who, when they cannot explain a thing, run back to the will of God; this is, truly, a ridiculous way of expressing ignorance.",religion -spinoza,"Let unswerving integrity be your watchword.",ethics -spinoza,"I have made a ceaseless effort not to ridicule, not to bewail, not to scorn human actions, but to understand them.",knowledge;education;ethics -spinoza,"Sadness diminishes a man's powers", -spinoza,"What everyone wants from life is continuous and genuine happiness.", -spinoza,"Nature is satisfied with little; and if she is, I am also.",ethics -spinoza,"He who loves God cannot endeavor that God should love him in return.",ethics;religion;love;knowledge -spinoza,"Laws which prescribe what everyone must believe, and forbid men to say or write anything against this or that opinion, are often passed to gratify, or rather to appease the anger of those who cannot abide independent minds.",politics -spinoza,"Further conceive, I beg, that a stone, while continuing in motion, should be capable of thinking and knowing, that it is endeavoring, as far as it can, to continue to move. Such a stone, being conscious merely of its own endeavor and not at all indifferent, would believe itself to be completely free, and would think that it continued in motion solely because of its own wish. This is that human freedom, which all boast that they possess, and which consists solely in the fact, that men are conscious of their own desire, but are ignorant of the causes whereby that desire has been determined.", -spinoza,"The supreme mystery of despotism, its prop and stay, is to keep men in a state of deception, and with the specious title of religion to cloak the fear by which they must be held in check, so that they will fight for their servitude as if for salvation.",religion -spinoza,"the ultimate aim of government is not to rule, or restrain by fear, nor to exact obedience, but to free every man from fear that he may live in all possible security... In fact the true aim of government is liberty.",ethics;knowledge -spinoza,"Everything excellent is as difficult as it is rare.", -spinoza,"Everything in nature is a cause from which there flows some effect.", -spinoza,"Blessed are the weak who think that they are good because they have no claws.", -spinoza,"God is the indwelling and not the transient cause of all things.",religion -spinoza,"The greatest secret of monarchic rule...is to keep men deceived and to cloak in the specious name of religion the fear by which they must be checked, so that they will fight for slavery as they would for salvation, and will think it not shameful, but a most honorable achievement, to give their life and blood that one man may have a ground for boasting.",politics -spinoza,"All is One (Nature, God)", -spinoza,"Faith is nothing but obedience and piety.",religion -spinoza,"The more intelligible a thing is, the more easily it is retained in the memory, and counterwise, the less intelligible it is, the more easily we forget it.",knowledge;education;history;ethics -spinoza,"Those who wish to seek out the cause of miracles and to understand the things of nature as philosophers, and not to stare at them in astonishment like fools, are soon considered heretical and impious, and proclaimed as such by those whom the mob adores as the interpreters of nature and the gods.", -spinoza,"It is usually the case with most men that their nature is so constituted that they pity those who fare badly and envy those who fare well.", -spinoza,"Fame has also this great drawback, that if we pursue it, we must direct our lives so as to please the fancy of men.", -spinoza,"In the mind there is no absolute or free will.", -spinoza,"None are more taken in by flattery than the proud, who wish to be the first and are not.", -spinoza,"I have tried sedulously not to laugh at the acts of man, nor to lament them, nor to detest them, but to understand them.",knowledge;education;ethics -spinoza,"Nothing in the universe is contingent, but all things are conditioned to exist and operate in a particular manner by the necessity of the divine nature.",religion;knowledge;ethics -spinoza,"If men were born free, they would, so long as they remained free, form no conception of good and evil.",ethics -spinoza,"In so far as the mind sees things in their eternal aspect, it participates in eternity.",knowledge;ethics -spinoza,"them.",knowledge;ethics -spinoza,"Many errors, of a truth, consist merely in the application of the wrong names of things.", -spinoza,".... we are a part of nature as a whole, whose order we follow.", -spinoza,"Men will find that they can ... avoid far more easily the perils which beset them on all sides by united action.",ethics;politics;knowledge -spinoza,"The order and connection of ideas is the same as the order and connection of things.", -spinoza,"Desire is the essence of a man.", -spinoza,"Love is pleasure accompanied by the idea of an external cause, and hatred pain accompanied by the idea of an external cause.",love -spinoza,"He that can carp in the most eloquent or acute manner at the weakness of the human mind is held by his fellows as almost divine.", -spinoza,"Emotion, which is suffering, ceases to be suffering as soon as we form a clear and precise picture of it.", -spinoza,"Better that right counsels be known to enemies than that the evil secrets of tyrants should be concealed from the citizens. They who can treat secretly of the affairs of a nation have it absolutely under their authority; and as they plot against the enemy in time of war, so do they against the citizens in time of peace.",knowledge;ethics;politics -spinoza,"A man is as much affected pleasurably or painfully by the image of a thing past or future as by the image of a thing present.",history -spinoza,"Love or hatred towards a thing, which we conceive to be free, must, other things being similar, be greater than if it were felt towards a thing acting by necessity.",ethics -spinoza,"Only that thing is free which exists by the necessities of its own nature, and is determined in its actions by itself alone.",ethics -spinoza,"Men would never be superstitious, if they could govern all their circumstances by set rules, or if they were always favoured by fortune: but being frequently driven into straits where rules are useless, and being often kept fluctuating pitiably between hope and fear by the uncertainty of fortune's greedily coveted favours, they are consequently for the most part, very prone to credulity.", -hegel,"We learn from history that we do not learn from history",history;knowledge -hegel,"To be independent of public opinion is the first formal condition of achieving anything great.",ethics;education -hegel,"To be aware of limitations is already to be beyond them.",ethics -hegel,"What history teaches us is that neither nations nor governments ever learn anything from it.",history -hegel,"The valor that struggles is better than the weakness that endures.",ethics;education -hegel,"The more certain our knowledge the less we know.",knowledge;education;ethics;history -hegel,"In a true tragedy, both parties must be right.",politics -hegel,"Before the end of Time will be the end of History. Before the end of History will be the end of Art.",history -hegel,"Poverty in itself does not make men into a rabble; a rabble is created only when there is joined to poverty a disposition of mind, an inner indignation against the rich, against society, against the government.",ethics;knowledge -hegel,"The learner always begins by finding fault, but the scholar sees the positive merit in everything.",education;knowledge;history;ethics -hegel,"An idea is always a generalization, and generalization is a property of thinking. To generalize means to think.", -hegel,"Genuine tragedy is a case not of right against wrong but of right against right - two equally justified ethical principles embodied in people of unchangeable will.", -hegel,"America is therefore the land of the future, where, in the ages that lie before us, the burden of the World's History shall reveal itself.",knowledge;history -hegel,"The history of the world is none other than the progress of the , consciousness of freedom.",history -hegel,"Beauty is merely the Spiritual making itself known sensuously.", -hegel,"All education is the art of making men ethical (sittlich), of transforming the old Adam into the new Adam.",education;ethics;knowledge -hegel,"Impatience asks for the impossible, wants to reach the goal without the means of getting there. The length of the journey has to be borne with, for every moment is necessary.",ethics -hegel,"It is solely by risking life that freedom is obtained; . . . the individual who has not staked his or her life may, no doubt, be recognized as a Person; but he or she has not attained the truth of this recognition as an independent self-consciousness.",ethics -hegel,"To make abstractions hold in reality is to destroy reality.", -hegel,"Philosophy is by its nature something esoteric, neither made for the mob nor capable of being prepared for the mob.", -hegel,"We learn from history that man can never learn anything from history.",history -hegel,"Freedom is the fundamental character of the will, as weight is of matter... That which is free is the will. Will without freedom is an empty word.",ethics -hegel,"The people are that part of the state that does not know what it wants.",politics -hegel,"We do not need to be shoemakers to know if our shoes fit, and just as little have we any need to be professionals to acquire knowledge of matters of universal interest.",knowledge -hegel,"World history is a court of judgment.",history -hegel,"The length of the journey has to be borne with, for every moment is necessary.",ethics -hegel,"The True is the whole. But the whole is nothing other than the essence consummating itself through its development. Of the Absolute it must be said that it is essentially a result, that only in the end is it what it truly is; and that precisely in this consists its nature, viz. to be actual, subject, the spontaneous becoming of itself.", -hegel,"Regarding History as the slaughter-bench at which the happiness of peoples, the wisdom of States, and the virtue of individuals have been victimized--the question involuntarily arises--to what principle, to what final aim these enormous sacrifices have been offered.",history -hegel,"The proofs of the existence of God are to such an extent fallen into discredit that they pass for something antiquated, belonging to days gone by.",history;religion -hegel,"The bud disappears when the blossom breaks through, and we might say that the former is refuted by the latter; in the same way when the fruit comes, the blossom may be explained to be a false form of the plant's existence, for the fruit appears as its true nature in place of the blossom.", -hegel,"The true courage of civilized nations is readiness for sacrifice in the service of the state, so that the individual counts as only one amongst many. The important thing here is not personal mettle but aligning oneself with the universal.",ethics;politics;knowledge -hegel,"The heart-throb for the welfare of humanity therefore passes into the ravings of an insane self-conceit, into the fury of consciousness to preserve itself from destruction; and it does this by expelling from itself the perversion which it is itself, and by striving to look on it and express it as something else.", -hegel,"The Catholics had been in the position of oppressors, and the Protestants of the oppressed",religion;politics;history;ethics -hegel,"To him who looks upon the world rationally, the world in its turn presents a rational aspect. The relation is mutual.",knowledge;ethics -hegel,"Propounding peace and love without practical or institutional engagement is delusion, not virtue.", -hegel,"It strikes everyone in beginning to form an acquaintance with the treasures of Indian literature that a land so rich in intellectual products and those of the profoundest order of thought.",knowledge -hegel,"The people will learn to feel the dignity of man. They will not merely demand their rights, which have been trampled in the dust, but themselves will take them - make them their own.",knowledge;ethics;education;politics -hegel,"It is easier to discover a deficiency in individuals, in states, and in Providence, than to see their real import and value.", -hegel,"Children are potentially free and their life directly embodies nothing save potential freedom. Consequently they are not things and cannot be the property either of their parents or others.",ethics -hegel,"When liberty is mentioned, we must always be careful to observe whether it is not really the assertion of private interests which is thereby designated.", -hegel,"It is because the method of physics does not satisfy the comprehension that we have to go on further.", -hegel,"Consequently, the sensuous aspect of art is related only to the two theoretical sensesof sight and hearing, while smell, taste, and touch remain excluded.", -hegel,"Once the state has been founded, there can no longer be any heroes. They come on the scene only in uncivilized conditions.",politics -hegel,"The essence of the modern state is that the universal be bound up with the complete freedom of its particular members and with private well-being, that thus the interests of family and civil society must concentrate themselves on the state. It is only when both these moments subsist in their strength that the state can be regarded as articulated and genuinely organized.", -hegel,"Animals are in possession of themselves; their soul is in possession of their body. But they have no right to their life, because they do not will it.",ethics -hegel,"The State is the Divine idea as it exists on Earth.", -hegel,"In the case of various kinds of knowledge, we find that what in former days occupied the energies of men of mature mental ability sinks to the level of information, exercises, and even pastimes for children; and in this educational progress we can see the history of the world's culture delineated in faint outline.",knowledge;education;history -hegel,"Every philosophy is complete in itself and, like a genuine work of art, contains the totality. Just as the works of Apelles and Sophocles, if Raphael and Shakespeare had known them, should not have appeared to them as mere preliminary exercises for their own work, but rather as a kindred force of the spirit, so, too reason cannot find in its own earlier forms mere useful preliminary exercises for itself.",knowledge -hegel,"We assert then that nothing has been accomplished without interest on the part of the actors; and if interest be called passion, inasmuch as the whole individuality, to the neglect of all other actual or possible interests and claims, is devoted to an object with every fibre of volition, concentrating all its desires and powers upon it we may affirm absolutely that nothing great in the World has been accomplished without passion.",love -hegel,"The Few assume to be the deputies, but they are often only the despoilers of the Many.",politics -freud,"We are what we are because we have been what we have been.",history -freud,"From error to error one discovers the entire truth.", -freud,"Two hallmarks of a healthy life are the abilities to love and to work. Each requires imagination.",love -freud,"When someone abuses me I can defend myself, but against praise I am defenceless.",ethics -freud,"Not all men are worthy of love.", -freud,"The meager satisfaction that man can extract from reality leaves him starving.", -freud,"It is not attention that the child is seeking, but love.",love -freud,"The only unnatural sexual behavior is none at all.", -freud,"A woman should soften but not weaken a man.",ethics;knowledge -freud,"The psychoanalysis of individual human beings, however, teaches us with quite special insistence that the god of each of them is formed in the likeness of his father, that his personal relation to God depends on his relation to his father in the flesh and oscillates and changes along with that relation, and that at bottom God is nothing other than an exalted father.",knowledge -freud,"When a love-relationship is at its height there is no room left for any interest in the environment; a pair of lovers are sufficient to themselves",love -freud,"All giving is asking, and all asking is an asking for love.",love -freud,"The news that reaches your consciousness is incomplete and often not to be relied on.... Turn your eyes inward, look into your own depths, learn first to know yourself!",education;ethics -freud,"Perhaps the gods are kind to us, by making life more disagreeable as we grow older. In the end death seems less intolerable than the manifold burdens we carry",religion -freud,"Anxiety in children is originally nothing other than an expression of the fact they are feeling the loss of the person they love.", -freud,"I cannot think of any need in childhood as strong as the need for a father's protection.", -freud,"The virtuous man contents himself with dreaming that which the wicked man does in actual life.",ethics -freud,"The only shame in masturbation is the shame of not doing it well.", -freud,"Philosophers stretch the meaning of words until they retain scarcely anything of their original sense. They give the name of ""God"" to some vague abstraction which they have created for themselves; having done so they can pose before all the world as deists, as believers of God, and they can even boast that they have recognized a higher, purer concept of God, notwithstanding that their God is not nothing more than an insubstantial shadow and no longer the mighty personality of religious doctrines.",religion;knowledge -freud,"Religion originates in the child's and young mankind's fears and need for help. It cannot be otherwise.",religion -freud,"Whatever fosters the growth of civilization works at the same time against war.",knowledge;ethics -freud,"The doctor should be opaque to his patients and, like a mirror, should show them nothing but what is shown to him.",ethics -freud,"The first human who hurled an insult instead of a stone was the founder of civilization.",history -freud,"In mourning it is the world which has become poor and empty; in melancholia it is the ego itself.", -freud,"This transmissibility of taboo is a reflection of the tendency, on which we have already remarked, for the unconscious instinct in the neurosis to shift constantly along associative paths on to new objects.", -freud,"If a man has been his mother's undisputed darling he retains throughout life the triumphant feeling, the confidence in success, which not seldom brings actual success along with it.",love -freud,"Religion restricts the play of choice and adaptation, since it imposes equally on everyone its own path to the acquisition of happiness and protection from suffering. Its technique consists in depressing the value of life and distorting the picture of the real world in a delusional manner - which presupposes an intimidation of the intelligence. At this price, by forcibly fixing them in a state of psychical infantilism and by drawing them into a mass-delusion, religion succeeds in sparing many people an individual neurosis. But hardly anything more.",religion -freud,"Sometimes a cigar is just a cigar.", -freud,"Where questions of religion are concerned, people are guilty of every possible sort of dishonesty and intellectual misdemeanor.",religion -freud,"When we share - that is poetry in the prose of life.",love -freud,"Illusions commend themselves to us because they save us pain and allow us to enjoy pleasure instead. We must therefore accept it without complaint when they sometimes collide with a bit of reality against which they are dashed to pieces.", -freud,"The world is no nursery.", -freud,"At bottom God is nothing more than an exalted father.",religion -freud,"Analogies, it is true, decide nothing, but they can make one feel more at home.", -freud,"Man has, as it were, become a kind of prosthetic God. When he puts on all his auxiliary organs, he is truly magnificent; but those organs have not grown on him and they still give him much trouble at times.", -freud,"The effect of the consolations of religion may be compared to that of a narcotic.",religion -freud,"It is no wonder if, under the pressure of these possibilities of suffering, men are accustomed to moderate their claims to happiness - just as the pleasure principle itself, indeed, under the influence of the external world, changed into the more modest reality principle -, if a man thinks himself happy merely to have escaped unhappiness or to have survived his suffering, and if in general the task of avoiding suffering pushes that of obtaining pleasure into the background.",knowledge;ethics -freud,"One... gets an impression that civilization is something which was imposed on a resisting majority by a minority which understood how to obtain possession of the means to power and coercion. It is, of course, natural to assume that these difficulties are not inherent in the nature of civilization itself but are determined by the imperfections of the cultural forms which have so far been developed.",politics -freud,"[The child receives impressions like] a photographic exposure that can be developed after any interval of time and transformed into a picture.", -freud,"The dream unites the grossest contradictions, permits impossibilities, sets aside the knowledge that influences us by day, and exposes us as ethically and morally obtuse.",ethics -freud,"Where such men love they have no desire and where they desire they cannot love",love;ethics -freud,"I do not in the least underestimate bisexuality... I expect it to provide all further enlightenment.",knowledge;education -freud,"To endure life remains, when all is said, the first duty of all living being Illusion can have no value if it makes this more difficult for us.", -freud,"There is an intellectual function in us which demands unity, connection and intelligibility from any material, whether of perception or thought, that comes within its grasp; and if, as a result of special circumstances, it is unable to establish a true connection, it does not hesitate to fabricate a false one.", -freud,"A string of reproaches against other people leads one to suspect the existence of a string of self-reproaches with the same content.", -freud,"When a man has once brought himself to accept uncritically all the absurdities that religious doctrines put before him and even to overlook the contradictions between them, we need not be greatly suprised at the weakness of his intellect.",religion -freud,"The rest of our enquiry is made easy because this God-Creator is openly called Father. Psycho-analysis concludes that he really is the father, clothed in the grandeur in which he once appeared to the small child.",knowledge -freud,"The expectation that every neurotic phenomenon can be cured may, I suspect, be derived from the layman's belief that the neuroses are something quite unnecessary which have no right whatever to exist. Whereas in fact they are severe, constitutionally fixed illnesses, which rarely restrict themselves to only a few attacks but persist as a rule over long periods throughout life.", -freud,"Lead us, Heavenly Father, lead us O'er the world's tempestuous sea; Guard us, guide us, keep us, feed us, For we have no help but Thee.",religion;love;knowledge;ethics -freud,"Towards the outside, at any rate, the ego seems to maintain clear and sharp lines of demarcation. There is only one state -- admittedly an unusual state, but not one that can be stigmatized as pathological -- in which it does not do this. At the height of being in love the boundary between ego and object threatens to melt away. Against all the evidence of his senses, a man who is in love declares that ""I"" and ""you"" are one, and is prepared to behave as if it were a fact.",love -nietzsche,"Sometimes people don't want to hear the truth because they don't want their illusions destroyed.",ethics;education;politics -nietzsche,"To live is to suffer, to survive is to find some meaning in the suffering.",ethics -nietzsche,"Whoever fights monsters should see to it that in the process he does not become a monster. And if you gaze long enough into an abyss, the abyss will gaze back into you.",ethics -nietzsche,"No price is too high to pay for the privilege of owning yourself.",knowledge;ethics -nietzsche,"Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the rule.",politics -nietzsche,"Everything the State says is a lie, and everything it has it has stolen.",politics;knowledge -nietzsche,"The snake which cannot cast its skin has to die. As well the minds which are prevented from changing their opinions; they cease to be mind.",ethics -nietzsche,"Man is the only animal that must be encouraged to live.",ethics -nietzsche,"The secret of reaping the greatest fruitfulness and the greatest enjoyment from life is to live dangerously.", -nietzsche,"It is not a lack of love, but a lack of friendship that makes unhappy marriages.", -nietzsche,"To predict the behavior of ordinary people in advance, you only have to assume that they will always try to escape a disagreeable situation with the smallest possible expenditure of intelligence.",knowledge -nietzsche,"The Great Man... is colder, harder, less hesitating, and without fear of 'opinion'; he lacks the virtues that accompany respect and 'respectability,' and altogether everything that is the 'virtue of the herd.' If he cannot lead, he goes alone... He knows he is incommunicable: he finds it tasteless to be familiar... When not speaking to himself, he wears a mask. There is a solitude within him that is inaccessible to praise or blame.",knowledge;ethics;politics;education -nietzsche,"The world is beautiful, but has a disease called man.", -nietzsche,"Solitude makes us tougher towards ourselves and tenderer towards others. In both ways it improves our character.",ethics -nietzsche,"Young people love what is interesting and odd, no matter how true or false it is. More mature minds love what is interesting and odd about truth. Fully mature intellects, finally, love truth, even when it appears plain and simple, boring to the ordinary person; for they have noticed that truth tends to reveal its highest wisdom in the guise of simplicity.",knowledge;love -nietzsche,"The real question is: How much truth can I stand?",ethics -nietzsche,"The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.", -nietzsche,"There are no beautiful surfaces without a terrible depth.", -nietzsche,"There is always some madness in love. But there is also always some reason in madness.",love -nietzsche,"There are horrible people who, instead of solving a problem, tangle it up and make it harder to solve for anyone who wants to deal with it. Whoever does not know how to hit the nail on the head should be asked not to hit it at all.", -nietzsche,"What is the truth, but a lie agreed upon.", -nietzsche,"You know a moment is important when it is making your mind go numb with beauty.",knowledge;love -nietzsche,"Invisible threads are the strongest ties.",ethics -nietzsche,"The most spiritual men, as the strongest, find their happiness where others would find their destruction: in the labyrinth, in hardness against themselves and others, in experiments. Their joy is self-conquest: asceticism becomes in them nature, need, and instinct. Difficult tasks are a privilege to them; to play with burdens that crush others, a recreation. Knowledge-a form of asceticism. They are the most venerable kind of man: that does not preclude their being the most cheerful and the kindliest.",knowledge -nietzsche,"To learn to see- to accustom the eye to calmness, to patience, and to allow things to come up to it; to defer judgment, and to acquire the habit of approaching and grasping an individual case from all sides. This is the first preparatory schooling of intellectuality. One must not respond immediately to a stimulus; one must acquire a command of the obstructing and isolating instincts.",education;knowledge -nietzsche,"For what purpose humanity is there should not even concern us: why you are here, that you should ask yourself: and if you have no ready answer, then set for yourself goals, high and noble goals, and perish in pursuit of them!",ethics;knowledge -nietzsche,"He who obeys, does not listen to himself!",ethics -nietzsche,"No journey is too great,",ethics -nietzsche,"In revenge and in love, woman is more barbarous than man.", -nietzsche,"People are always angry at anyone who chooses very individual standards for his life; because of the extraordinary treatment which that man grants to himself, they feel degraded, like ordinary beings.",ethics -nietzsche,"Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar.",politics;knowledge;ethics -nietzsche,"Without music, life would be a mistake.", -nietzsche,"All I need is a sheet of paper and something to write with, and then I can turn the world upside down.", -nietzsche,"Ultimately, it is the desire, not the desired, that we love.",love;ethics -nietzsche,"What is evil?-Whatever springs from weakness.", -nietzsche,"Beware of spitting against the wind!",ethics -nietzsche,"Deception, flattering, lying, deluding, talking behind the back, putting up a false front, living in borrowed splendor, wearing a mask, hiding behind convention, playing a role for others and for oneself -- in short, a continuous fluttering around the solitary flame of vanity -- is so much the rule and the law among men that there is almost nothing which is less comprehensible than how an honest and pure drive for truth could have arisen among them.", -nietzsche,"the voice of beauty speaks softly; it creeps only into the most fully awakened souls",love;education -nietzsche,"Everyone needs a sense of shame, but no one needs to feel ashamed.",ethics -nietzsche,"There exists above the ""productive"" man a yet higher species.",ethics;knowledge -nietzsche,"For a tree to become tall it must grow tough roots among the rocks.", -nietzsche,"The man of knowledge must be able not only to love his enemies but also to hate his friends.",knowledge;ethics;education -nietzsche,"The growth of wisdom may be gauged exactly by the diminution of ill-temper.",knowledge -nietzsche,"Most people are too stupid to act in their own interest", -nietzsche,"The visionary lies to himself, the liar only to others.", -nietzsche,"It is the business of the very few to be independent; it is a privilege of the strong.",ethics;knowledge;politics -nietzsche,"A moral system valid for all is basically immoral.", -nietzsche,"Marriage was contrived for ordinary people, for people who are capable of neither great love nor great friendship, which is to say, for most people--but also for those exceptionally rare ones who are capable of love as well as of friendship.", -nietzsche,"Shared joys make a friend, not shared sufferings.",ethics -nietzsche,"What makes us heroic?--Confronting simultaneously our supreme suffering and our supreme hope.", -sartre,"He who asks a question is a fool for a minute; he who does not remains a fool forever.",ethics;education -sartre,"I can always choose, but I ought to know that if I do not choose, I",knowledge;ethics;education -sartre,"am still choosing.",ethics -sartre,"I hate victims who respect their executioners.", -sartre,"Everything has been figured out, except how to live.",knowledge -sartre,"your judgement judges you and defines you", -sartre,"slipped out of the world, somewhere else like the soul of a dead man. Perhaps he was only a dream...God is dead.", -sartre,"Nothingness haunts Being.", -sartre,"To choose not to choose is still to act.",ethics -sartre,"Death is a continuation of my life without me.",history -sartre,"In a word, man must create his own essence: it is in throwing himself into the world, suffering there, struggling there, that he gradually defines himself.",ethics -sartre,"Imagination is not an empirical or superadded power of consciousness, it is the whole of consciousness as it realizes its freedom.", -sartre,"I am no longer sure of anything. If I satiate my desires, I sin but I deliver myself from them; if I refuse to satisfy them, they infect the whole soul.",ethics -sartre,"To believe is to know you believe, and to know you believe is not to believe.",knowledge;ethics -sartre,"The more one is absorbed in fighting evil, the less one is tempted to place the good in question.",ethics -sartre,"My thought is me: that's why I can't stop. I exist because I think",ethics;knowledge;history -sartre,"Acting is a question of absorbing other people's personalities and adding some of your own experience.", -sartre,"She believed in nothing; only her skepticism kept her from being an atheist.", -sartre,"and without resignation either. He stares at death with passionate attention and this fascination liberates him. He experiences the divine irresponsibility of the condemned man.",ethics;knowledge -sartre,"It disturbs me no more to find men base, unjust, or selfish than to see apes mischievous, wolves savage, or the vulture ravenous.", -sartre,"Every human endeavor, however singular it seems, involves the whole human race.", -sartre,"Thats what existence means: draining ones own self dry without the sense of thirst.", -sartre,"If all I asked was not a great deal, that's my problem!",ethics;education -sartre,"A madman's ravings are absurd in relation to the situation in which he finds himself, but not in relation to his madness.", -sartre,"The viable jewels of life remain untouched when man forgets his vocation of searching for the truth of his existence.",knowledge;ethics -sartre,"Photographs are not ideas. They give us ideas.", -sartre,"Smooth and smiling faces everywhere, but ruin in their eyes.",politics -sartre,"Be quiet! Anyone can spit in my face, and call me a criminal and a prostitute. But no one has the right to judge my remorse.",ethics;knowledge;politics -sartre,"I found the human heart empty and insipid everywhere except in books.",knowledge -sartre,"I wanted pure love: foolishness; to love one another is to hate a common enemy: I will thus espouse your hatred. I wanted Good: nonsense; on this earth and in these times, Good and Bad are inseparable: I accept to be evil in order to become good.",love;politics -sartre,"As for the square at Meknes, where I used to go every day, it's even simpler: I do not see it at all anymore. All that remains is the vague feeling that it was charming, and these five words that are indivisibly bound together: a charming square at Meknes. ... I don't see anything any more: I can search the past in vain, I can only find these scraps of images and I am not sure what they represent, whether they are memories or just fiction.",history -sartre,"I think that is the big danger in keeping a diary: you exaggerate everything.", -sartre,"To keep hope alive one must, in spite of all mistakes, horrors, and crimes, recognize the obvious superiority of the socialist camp.",politics;knowledge -sartre,"I have such a desire to sleep and am so much behind my sleep. A good night, one good night and all this nonsense will be swept away.", -sartre,"Acting is happy agony.", -sartre,"Being is. Being is in-itself. Being is what it is.",history;knowledge;ethics -sartre,"Generosity is nothing else than a craze to possess. All which I abandon, all which I give, I enjoy in a higher manner through the fact that I give it away. To give is to enjoy possessively the object which one gives.",ethics;knowledge -sartre,"Take [Stphane] Mallarme. I hold him to be the greatest of French poets, and I have taken some time to understand him !",knowledge -sartre,"I am neither virgin nor priest enough to play with the inner life.",ethics -sartre,"To think new thoughts you have to break the bones in your head", -sartre,"I needed to justify my existence, and I had made an absolute of literature. It took me thirty years to get rid of this state of mind.", -sartre,"Fear? If I have gained anything by damning myself, it is that I no longer have anything to fear.",knowledge;ethics -sartre,"as not-bound to life.", -sartre,"One could only damage oneself through the harm one did to others. One could never get directly at oneself.",ethics -sartre,"Absurd, irreducible; nothing not even a profound and secret delirium of nature could explain it. Obviously I did not know everything, I had not seen the seeds sprout, or the tree grow. But faced with this great wrinkled paw, neither ignorance nor knowledge was important: the world of explanations and reasons is not the world of existence. A circle is not absurd, it is clearly explained by the rotation of a straight segment around one of its extremities. But neither does a circle exist. This root, on the other hand, existed in such a way that I could not explain it.", -sartre,"I am not recommending ""popular"" literature which aims at the lowest.", -sartre,"Men equally honest, equally devoted to their fatherland, are momentarily separated by different conceptions of their duty.",ethics -sartre,"Better to have beasts that let themselves be killed than men who run away.",ethics -sartre,"Render a kiss or blow",love -sartre,"Offer all the hatred in your heart", -plato,"No one is more hated than he who speaks the truth.",ethics;knowledge -plato,"A wise man speaks because he has something to say; a fool because he has to say something.",ethics -plato,"Be kind. Every person you meet",ethics -plato,"Better to complete a small task well, than to do much imperfectly.",ethics;knowledge -plato,"The right question is usually more important than the right answer.",ethics -plato,"Ignorance is the root cause of all difficulties.", -plato,"Someday, in the distant future, our grand-children' s grand-children will develop a new equivalent of our classrooms. They will spend many hours in front of boxes with fires glowing within. May they have the wisdom to know the difference between light and knowledge.", -plato,"I am the wisest man alive, for I know one thing, and that is that I know nothing.",knowledge;ethics;education -plato,"Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws.",ethics;knowledge -plato,"The one who learns and learns and doesn't practice is like the one who plows and plows and never plants.",ethics -plato,"The measure of a man is what he does with power.",politics -plato,"Wisest is he who knows what he does not know.",knowledge;ethics;education -plato,"Enjoy life. There's plenty of time to be dead. Be kind, for everyone you meet is fighting a harder battle.",ethics -plato,"Those who tell the stories rule society.",history -plato,"The worst of all deceptions is self-deception.", -plato,"You should not honor men more than truth.",ethics -plato,"One cannot make a slave of a free person, for a free person is free even in a prison.",ethics;knowledge -plato,"False words are not only evil in themselves, but they infect the soul with evil.",ethics -plato,"There is nothing so delightful as the hearing, or the speaking of truth. For this reason, there is no conversation so agreeable as that of the man of integrity, who hears without any intention to betray, and speaks without any intention to deceive.",ethics;knowledge -plato,"Poverty doesn't come because of the decrease of wealth but because of the increase of desires.", -plato,"Never discourage anyone who continually makes progress, no matter how slow... even if that someone is yourself!",ethics;knowledge -plato,"Every heart sings a song, incomplete, until another heart whispers back.",love -plato,"A true artist is someone who gives birth to a new reality.", -plato,"The souls of people, on their way to Earth-life, pass through a room full of lights; each takes a taper - often only a spark - to guide it in the dim country of this world. But some souls, by rare fortune, are detained longer - have time to grasp a handful of tapers, which they weave into a torch. These are the torch-bearers of humanity - its poets, seers and saints, who lead and lift the race out of darkness, toward the light. They are the law-givers and saviors, the light-bringers, way-showers and truth-tellers, and without them, humanity would lose its way in the dark.", -plato,"We become what we contemplate.",knowledge;ethics -plato,"He who does not desire power is fit to hold it.",politics;ethics -plato,"The three wishes of every man: to be healthy, to be rich by honest means, and to be beautiful.", -plato,"Do not train children to learning by force and harshness, but direct them to it by what amuses their minds.",ethics -plato,"How can you prove whether at this moment we are sleeping, and all our thoughts are a dream; or whether we are awake, and talking to one another in the waking state?", -plato,"The philosopher is in love with truth, that is, not with the changing world of sensation, which is the object of opinion, but with the unchanging reality which is the object of knowledge.",knowledge -plato,"He who is only an athlete is too crude, too vulgar, too much a savage. He who is a scholar only is too soft, to effeminate. The ideal citizen is the scholar athlete, the man of thought and the man of action.",ethics -plato,"I know not how I may seem to others, but to myself I am but a small child wandering upon the vast shores of knowledge, every now and then finding a small bright pebble to content myself with",education;knowledge -plato,"He who love touches walks not in darkness.",love;ethics;knowledge -plato,"Pleasure is the bait of sin", -plato,"A good decision is based on knowledge, and not on numbers.",knowledge;education -plato,"When man is not properly trained, he is the most savage animal on the face of the globe.",ethics -plato,"Happiness springs from doing good and helping others.",ethics -plato,"One of the penalties for refusing to participate in politics is that you end up being governed by your inferiors.",politics -plato,"The blame is his who chooses: God is blameless.",religion;ethics;knowledge -plato,"Harmony sinks deep into the recesses of the soul and takes its strongest hold there, bringing grace also to the body & mind as well. Music is a moral law. It gives a soul to the universe, wings to the mind, flight to the imagination, a charm to sadness, and life to everything. It is the essence of order.", -plato,"Do not expect justice where might is right.", -plato,"When you feel grateful, you become great, and eventually attract great things.",ethics;knowledge -plato,"If we are to have any hope for the future, those who have lanterns must pass them on to others.",ethics -plato,"We see many instances of cities going down like sinking ships to their destruction. There have been such wrecks in the past and there surely will be others in the future, caused by the wickedness of captains and crews alike. For these are guilty men, whose sin is supreme ignorance of what matters most.", -plato,"Mankind will never see an end of trouble until lovers of wisdom come to hold political power, or the holders of power become lovers of wisdom",politics;knowledge -plato,"Those who are too smart to engage in politics are punished by being governed by those who are dumber.",politics;knowledge -plato,"A dog has the soul of a philosopher.",ethics -plato,"Thinking is the soul talking to itself.", -plato,"midwife to the awakening of the Soul in another person.",love;knowledge -plato,"All wars are fought for the sake of getting money.", -kant,"Rules for Happiness: something to do, someone to love, something to hope for.",love -kant,"Do the right thing because it is right.",ethics -kant,"The only thing permanent is change.", -kant,"Give a man everything he wants and at that moment everything is not everything",ethics -kant,"Great minds think for themselves.",knowledge -kant,"Perpetual Peace is only found in the graveyard.", -kant,"A single line in the Bible has consoled me more than all the books I ever read besides.",religion;love -kant,"All our knowledge begins with the senses, proceeds then to the understanding, and ends with reason. There is nothing higher than reason.",knowledge;history;education -kant,"If justice perishes, human life on Earth has lost its meaning.", -kant,"Morality is not properly the doctrine of how we may make ourselves happy, but how we may make ourselves worthy of happiness.", -kant,"Out of the crooked timber of humanity, no straight thing was ever made.",ethics -kant,"Thoughts without content are empty, intuitions without concepts are blind.", -kant,"Immaturity is the incapacity to use one's intelligence without the guidance of another.", -kant,"The nice thing about living in a small town is that when you don't know what you're doing, someone else does.", -kant,"Two things strike me dumb: the infinite starry heavens, and the sense of right and wrong in man.",ethics -kant,"Reason can never prove the existence of God.",religion -kant,"All the interests of my reason, speculative as well as practical, combine in the three following questions: 1. What can I know? 2. What ought I to do? 3. What may I hope?",knowledge -kant,"By a lie, a man... annihilates his dignity as a man.",politics;ethics -kant,"Religion is too important a matter to its devotees to be a subject of ridicule. If they indulge in absurdities, they are to be pitied rather than ridiculed.",religion -kant,"Enthusiasm is always connected with the senses, whatever be the object that excites it. The true strength of virtue is serenity of mind, combined with a deliberate and steadfast determination to execute her laws. That is the healthful condition of the moral life; on the other hand, enthusiasm, even when excited by representations of goodness, is a brilliant but feverish glow which leaves only exhaustion and languor behind.",ethics -kant,"Men will not understand ... that when they fulfil their duties to men, they fulfil thereby God's commandments; that they are consequently always in the service of God, as long as their actions are moral, and that it is absolutely impossible to serve God otherwise.",ethics;religion -kant,"[A ruler is merely] the trustee of the rights of other men and he must always stand in dread of having in some way violated these rights.",ethics -kant,"The death of dogma is the birth of morality.",ethics -kant,"Freedom is that faculty that enlarges the usefulness of all other faculties.", -kant,"The sum total of all possible knowledge of God is not possible for a human being, not even through a true revelation. But it is one of the worthiest inquiries to see how far our reason can go in the knowledge of God.",knowledge -kant,"Philosophy stands in need of a science which shall determine the possibility, principles, and extent of human knowledge priori.",knowledge -kant,"Thrift is care and scruple in the spending of one's means. It is not a virtue and it requires neither skill nor talent.",ethics -kant,"If a man is often the subject of conversation he soon becomes the subject of criticism.",ethics -kant,"Enlightenment is man's emergence from his self-incurred immaturity.",education;knowledge -kant,"Give me matter, and I will construct a world out of it!", -kant,"Even a man's exact imitation of the song of the nightingale displeases us when we discover that it is a mimicry, and not the nightingale.",ethics;knowledge -kant,"[R]eason is... given to us as a practical faculty, that is, as one that influences the will.", -kant,"The business of philosophy is not to give rules, but to analyze the private judgments of common reason.", -kant,"Moral Teleology supplies the deficiency in physical Teleology , and first establishes a Theology ; because the latter, if it did not borrow from the former without being observed, but were to proceed consistently, could only found a Demonology , which is incapable of any definite concept.", -kant,"There is nothing higher than reason.", -kant,"Time is not an empirical concept. For neither co-existence nor succession would be perceived by us, if the representation of time did not exist as a foundation a priori.", -kant,"Have patience awhile; slanders are not long-lived. Truth is the child of time; erelong she shall appear to vindicate thee.",knowledge;ethics;history;education -kant,"But only he who, himself enlightened, is not afraid of shadows.",knowledge;education;ethics -kant,"There is needed, no doubt, a body of servants (ministerium) of the invisible church, but not officials (officiales), in other words, teachers but not dignitaries, because in the rational religion of every individual there does not yet exist a church as a universal union (omnitudo collectiva).",religion;education;knowledge -kant,"Reason must approach nature in order to be taught by it. It must not, however, do so in the character of a pupil who listens to everything that the teacher chooses to say, but of an appointed judge who compels the witness to answer questions which he has himself formulated.",education;knowledge -kant,"But although all our knowledge begins with experience, it does not follow that it arises from experience.",knowledge;ethics;education -kant,"Enlightenment is the liberation of man from his self-caused state of minority... Supere aude! Dare to use your own understanding!is thus the motto of the Enlightenment.",knowledge -kant,"The history of the human race, viewed as a whole, may be regarded as the realization of a hidden plan of nature to bring about a political constitution, internally, and for this purpose, also externally perfect, as the only state in which all the capacities implanted by her in mankind can be fully developed.",history;politics -kant,"Standing armies shall in time be totally abolished.",history -kant,"Criticism alone can sever the root of materialism, fatalism, atheism, free-thinking, fanaticism, and superstition, which can be injurious universally; as well as of idealism and skepticism, which are dangerous chiefly to the Schools, and hardly allow of being handed on to the public.",education -kant,"Everything in nature acts in conformity with law.", -kant,"I freely admit that the remembrance of David Hume was the very thing that many years ago first interrupted my dogmatic slumber and gave a completely different direction to my researches in the field of speculative philosophy.",knowledge;history -kant,"All trades, arts, and handiworks have gained by division of labor... Where the different kinds of work are not distinguished and divided, where everyone is a jack-of-all-trades, there manufactures remain still in the greatest barbarism.", -kant,"Innocence is indeed a glorious thing; but, unfortunately, it does not keep very well and is easily led astray.", -kant,"The schematicism by which our understanding deals with the phenomenal world ... is a skill so deeply hidden in the human soul that we shall hardly guess the secret trick that Nature here employs.",knowledge \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AbstractApiClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/AbstractApiClient.java similarity index 92% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AbstractApiClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/AbstractApiClient.java index f40972a5..a174106e 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AbstractApiClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/AbstractApiClient.java @@ -1,9 +1,9 @@ -package com.dtsx.astra.sdk; +package com.datastax.astra.devops; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.AstraEnvironment; import lombok.Getter; import static java.net.HttpURLConnection.HTTP_ACCEPTED; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AstraOpsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/AstraDevopsClient.java similarity index 79% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AstraOpsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/AstraDevopsClient.java index 8e1bf11f..0b2e2b26 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AstraOpsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/AstraDevopsClient.java @@ -1,16 +1,17 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.org.KeysClient; -import com.dtsx.astra.sdk.org.RolesClient; -import com.dtsx.astra.sdk.org.TokensClient; -import com.dtsx.astra.sdk.org.UsersClient; -import com.dtsx.astra.sdk.org.domain.*; -import com.dtsx.astra.sdk.streaming.AstraStreamingClient; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops; + +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.org.KeysClient; +import com.datastax.astra.devops.org.RolesClient; +import com.datastax.astra.devops.org.TokensClient; +import com.datastax.astra.devops.org.UsersClient; +import com.datastax.astra.devops.org.domain.Organization; +import com.datastax.astra.devops.org.domain.ResponseAllUsers; +import com.datastax.astra.devops.streaming.AstraStreamingClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import java.util.Map; @@ -19,7 +20,7 @@ * *

This class uses

*/ -public class AstraOpsClient extends AbstractApiClient { +public class AstraDevopsClient extends AbstractApiClient { /** * Initialize the Devops API with a token @@ -27,7 +28,7 @@ public class AstraOpsClient extends AbstractApiClient { * @param token * bearerAuthToken token */ - public AstraOpsClient(String token) { + public AstraDevopsClient(String token) { this(token, AstraEnvironment.PROD); } @@ -39,7 +40,7 @@ public AstraOpsClient(String token) { * @param token * bearerAuthToken token */ - public AstraOpsClient(String token, AstraEnvironment env) { + public AstraDevopsClient(String token, AstraEnvironment env) { super(token, env); } @@ -85,8 +86,8 @@ public Organization getOrganization() { * @return * databases client */ - public AstraDBOpsClient db() { - return new AstraDBOpsClient(token, environment); + public AstraDBDevopsClient db() { + return new AstraDBDevopsClient(token, environment); } // ------------------------------------------------------ diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/AstraDBOpsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/AstraDBDevopsClient.java similarity index 88% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/AstraDBOpsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/AstraDBDevopsClient.java index 73e8e877..92ada105 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/AstraDBOpsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/AstraDBDevopsClient.java @@ -1,18 +1,20 @@ -package com.dtsx.astra.sdk.db; - - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.*; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponse; -import com.dtsx.astra.sdk.utils.ApiResponseError; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops.db; + + +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.domain.AccessList; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.db.domain.DatabaseFilter; +import com.datastax.astra.devops.db.domain.DatabaseFilter.Include; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseError; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; -import com.dtsx.astra.sdk.db.domain.DatabaseFilter.Include; -import com.fasterxml.jackson.databind.exc.MismatchedInputException; import java.net.HttpURLConnection; import java.util.List; @@ -23,10 +25,10 @@ /** * Devops API Client working with Databases. */ -public class AstraDBOpsClient extends AbstractApiClient { +public class AstraDBDevopsClient extends AbstractApiClient { /** Load Database responses. */ - private static final TypeReference> RESPONSE_DATABASES = + private static final TypeReference> RESPONSE_DATABASES = new TypeReference>(){}; /** Load Database responses. */ @@ -39,7 +41,7 @@ public class AstraDBOpsClient extends AbstractApiClient { * @param token * authenticated token */ - public AstraDBOpsClient(String token) { + public AstraDBDevopsClient(String token) { this(token, AstraEnvironment.PROD); } @@ -51,7 +53,7 @@ public AstraDBOpsClient(String token) { * @param token * authenticated token */ - public AstraDBOpsClient(String token, AstraEnvironment env) { + public AstraDBDevopsClient(String token, AstraEnvironment env) { super(token, env); } diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbAccessListsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbAccessListsClient.java similarity index 88% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbAccessListsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbAccessListsClient.java index de19184e..d04960cb 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbAccessListsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbAccessListsClient.java @@ -1,14 +1,14 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.AccessList; -import com.dtsx.astra.sdk.db.domain.AccessListAddressRequest; -import com.dtsx.astra.sdk.db.domain.AccessListRequest; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.db.domain.AccessList; +import com.datastax.astra.devops.db.domain.AccessListAddressRequest; +import com.datastax.astra.devops.db.domain.AccessListRequest; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import java.util.ArrayList; import java.util.Arrays; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbCdcsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbCdcsClient.java similarity index 87% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbCdcsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbCdcsClient.java index 044fec63..3083d0c6 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbCdcsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbCdcsClient.java @@ -1,16 +1,16 @@ -package com.dtsx.astra.sdk.db; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.exception.ChangeDataCaptureNotFoundException; -import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException; -import com.dtsx.astra.sdk.streaming.AstraStreamingClient; -import com.dtsx.astra.sdk.streaming.domain.CdcDefinition; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops.db; + +import com.datastax.astra.devops.db.exception.ChangeDataCaptureNotFoundException; +import com.datastax.astra.devops.db.exception.KeyspaceNotFoundException; +import com.datastax.astra.devops.streaming.AstraStreamingClient; +import com.datastax.astra.devops.streaming.domain.CdcDefinition; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import com.fasterxml.jackson.core.type.TypeReference; import java.net.HttpURLConnection; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbDatacentersClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbDatacentersClient.java similarity index 86% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbDatacentersClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbDatacentersClient.java index 3d02a911..2910a7f8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbDatacentersClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbDatacentersClient.java @@ -1,17 +1,17 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseRegionCreationRequest; -import com.dtsx.astra.sdk.db.domain.Datacenter; -import com.dtsx.astra.sdk.db.exception.RegionAlreadyExistException; -import com.dtsx.astra.sdk.db.exception.RegionNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Datacenter; +import com.datastax.astra.devops.db.exception.RegionAlreadyExistException; +import com.datastax.astra.devops.db.exception.RegionNotFoundException; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseRegionCreationRequest; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import com.fasterxml.jackson.core.type.TypeReference; import java.net.HttpURLConnection; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbKeyspacesClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbKeyspacesClient.java similarity index 85% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbKeyspacesClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbKeyspacesClient.java index 1a1d39c7..da539aa5 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbKeyspacesClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbKeyspacesClient.java @@ -1,12 +1,12 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.exception.KeyspaceAlreadyExistException; -import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; +import com.datastax.astra.devops.db.exception.KeyspaceAlreadyExistException; +import com.datastax.astra.devops.db.exception.KeyspaceNotFoundException; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import java.util.Set; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbOpsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbOpsClient.java similarity index 94% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbOpsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbOpsClient.java index c3183880..26f619d8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbOpsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbOpsClient.java @@ -1,17 +1,17 @@ -package com.dtsx.astra.sdk.db; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.db.domain.Datacenter; -import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException; -import com.dtsx.astra.sdk.db.exception.RegionNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; -import com.dtsx.astra.sdk.utils.Utils; +package com.datastax.astra.devops.db; + +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.db.domain.Datacenter; +import com.datastax.astra.devops.db.exception.DatabaseNotFoundException; +import com.datastax.astra.devops.db.exception.RegionNotFoundException; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.utils.Utils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbPrivateLinksClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbPrivateLinksClient.java similarity index 93% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbPrivateLinksClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbPrivateLinksClient.java index 1355719c..342be88f 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbPrivateLinksClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbPrivateLinksClient.java @@ -1,10 +1,10 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; -import com.dtsx.astra.sdk.db.domain.Database; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.AstraEnvironment; import java.util.Optional; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbRegionsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbRegionsClient.java similarity index 84% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbRegionsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbRegionsClient.java index dcc2c3c2..21792536 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbRegionsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbRegionsClient.java @@ -1,15 +1,15 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.RegionType; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.DatabaseRegion; -import com.dtsx.astra.sdk.db.domain.DatabaseRegionServerless; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.DatabaseRegionServerless; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.domain.RegionType; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.db.domain.DatabaseRegion; +import com.datastax.astra.devops.utils.ApiLocator; import com.fasterxml.jackson.core.type.TypeReference; import java.util.ArrayList; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbTelemetryClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbTelemetryClient.java similarity index 78% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbTelemetryClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbTelemetryClient.java index 98f86f1b..42dbf0ff 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbTelemetryClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/DbTelemetryClient.java @@ -1,18 +1,18 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.telemetry.CloudWatchTelemetryRequest; -import com.dtsx.astra.sdk.db.domain.telemetry.DatadogTelemetryRequest; -import com.dtsx.astra.sdk.db.domain.telemetry.KafkaTelemetryRequest; -import com.dtsx.astra.sdk.db.domain.telemetry.PrometheusTelemetryRequest; -import com.dtsx.astra.sdk.db.domain.telemetry.SpecializedTelemetryClient; -import com.dtsx.astra.sdk.db.domain.telemetry.SplunkTelemetryRequest; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.telemetry.CloudWatchTelemetryRequest; +import com.datastax.astra.devops.db.domain.telemetry.DatadogTelemetryRequest; +import com.datastax.astra.devops.db.domain.telemetry.KafkaTelemetryRequest; +import com.datastax.astra.devops.db.domain.telemetry.PrometheusTelemetryRequest; +import com.datastax.astra.devops.db.domain.telemetry.SpecializedTelemetryClient; +import com.datastax.astra.devops.db.domain.telemetry.SplunkTelemetryRequest; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; /** * Setup Database Telemetry. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessList.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessList.java similarity index 96% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessList.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessList.java index e65f55e7..5104daab 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessList.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessList.java @@ -1,8 +1,5 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; -import com.fasterxml.jackson.annotation.JsonFormat; - -import java.time.LocalDateTime; import java.util.List; /** diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddress.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddress.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddress.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddress.java index 9b358208..5f86853e 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddress.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddress.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddressRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddressRequest.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddressRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddressRequest.java index 9b283709..a4630cfd 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddressRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListAddressRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Create new Address. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListRequest.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListRequest.java index 56b36ad6..3e483ba6 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/AccessListRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/CloudProviderType.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/CloudProviderType.java similarity index 96% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/CloudProviderType.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/CloudProviderType.java index 2c61b311..85309e36 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/CloudProviderType.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/CloudProviderType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Encoded all values for 'cloudProvider' diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Database.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Database.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Database.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Database.java index 488bc049..dd593cc8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Database.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Database.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import java.util.Set; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCost.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCost.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCost.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCost.java index 56fee0a7..ea9eaf1f 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCost.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCost.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationBuilder.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationBuilder.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationBuilder.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationBuilder.java index 1251c888..fae9d590 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationBuilder.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationBuilder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Builder for database creation. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationRequest.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationRequest.java index 14d3beba..1746080a 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Database creation request diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationType.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationType.java similarity index 75% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationType.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationType.java index cbc8fd24..a512fd95 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationType.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseCreationType.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * List of type available for vector. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseFilter.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseFilter.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseFilter.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseFilter.java index 26239d38..56646c37 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseFilter.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import java.util.Optional; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseInfo.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseInfo.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseInfo.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseInfo.java index 013543f4..e0f50c16 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseInfo.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseInfo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import java.util.Set; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseMetrics.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseMetrics.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseMetrics.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseMetrics.java index b1d645cc..72829e17 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseMetrics.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseMetrics.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegion.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegion.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegion.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegion.java index d8af55a2..a1f020bb 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegion.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegion.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionCreationRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionCreationRequest.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionCreationRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionCreationRequest.java index d7acdf99..cda264d7 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionCreationRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionCreationRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Create a new region for a DB. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionServerless.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionServerless.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionServerless.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionServerless.java index 38bd320d..5f02120b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseRegionServerless.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseRegionServerless.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStatusType.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStatusType.java similarity index 96% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStatusType.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStatusType.java index 23dcfd0a..7c4eb92f 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStatusType.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStatusType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Encoded all values for 'tier' diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStorage.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStorage.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStorage.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStorage.java index a42273e7..ecc3ecc8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseStorage.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/DatabaseStorage.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Datacenter.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Datacenter.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Datacenter.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Datacenter.java index 49612981..373a0fe4 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/Datacenter.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/Datacenter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/RegionType.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/RegionType.java similarity index 93% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/RegionType.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/RegionType.java index 731b33e7..008d0843 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/RegionType.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/RegionType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.db.domain; +package com.datastax.astra.devops.db.domain; /** * Encoded all values for 'region-type' diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/package-info.java similarity index 51% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/package-info.java index 101095de..2c228bf7 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/package-info.java @@ -1,2 +1,2 @@ /** Entities and Pojo for Astra Db Service. */ -package com.dtsx.astra.sdk.db.domain; \ No newline at end of file +package com.datastax.astra.devops.db.domain; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/CloudWatchTelemetryRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/CloudWatchTelemetryRequest.java similarity index 93% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/CloudWatchTelemetryRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/CloudWatchTelemetryRequest.java index 9ec2e1dc..92131e4b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/CloudWatchTelemetryRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/CloudWatchTelemetryRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/DatadogTelemetryRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/DatadogTelemetryRequest.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/DatadogTelemetryRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/DatadogTelemetryRequest.java index cbc433ec..c803c795 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/DatadogTelemetryRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/DatadogTelemetryRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/KafkaTelemetryRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/KafkaTelemetryRequest.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/KafkaTelemetryRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/KafkaTelemetryRequest.java index ae6f1716..d7d77e26 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/KafkaTelemetryRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/KafkaTelemetryRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/PrometheusTelemetryRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/PrometheusTelemetryRequest.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/PrometheusTelemetryRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/PrometheusTelemetryRequest.java index ec03ee58..ebdece3a 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/PrometheusTelemetryRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/PrometheusTelemetryRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SpecializedTelemetryClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SpecializedTelemetryClient.java similarity index 90% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SpecializedTelemetryClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SpecializedTelemetryClient.java index 5657cf15..d49f2c37 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SpecializedTelemetryClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SpecializedTelemetryClient.java @@ -1,9 +1,9 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SplunkTelemetryRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SplunkTelemetryRequest.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SplunkTelemetryRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SplunkTelemetryRequest.java index 33c1640e..23c11449 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/SplunkTelemetryRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/SplunkTelemetryRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.domain.telemetry; +package com.datastax.astra.devops.db.domain.telemetry; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/package-info.java similarity index 51% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/package-info.java index b2f9d31b..343f9101 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/domain/telemetry/package-info.java @@ -1,2 +1,2 @@ /** Entities and Pojo for Astra Db Telemetry Service. */ -package com.dtsx.astra.sdk.db.domain.telemetry; \ No newline at end of file +package com.datastax.astra.devops.db.domain.telemetry; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/ChangeDataCaptureNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/ChangeDataCaptureNotFoundException.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/ChangeDataCaptureNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/ChangeDataCaptureNotFoundException.java index e741df79..31aa6255 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/ChangeDataCaptureNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/ChangeDataCaptureNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when accessing a region from its name, and it is not found. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/DatabaseNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/DatabaseNotFoundException.java similarity index 88% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/DatabaseNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/DatabaseNotFoundException.java index 183d0cc9..5d9efc97 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/DatabaseNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/DatabaseNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when accessing a database from name or id, and it is not found. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceAlreadyExistException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceAlreadyExistException.java similarity index 92% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceAlreadyExistException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceAlreadyExistException.java index a7dad705..6666738a 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceAlreadyExistException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceAlreadyExistException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when creating a keyspace with name already in use. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceNotFoundException.java similarity index 90% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceNotFoundException.java index 5ae00bb3..f5758495 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/KeyspaceNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when accessing a keyspace from its name, and it is not found. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionAlreadyExistException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionAlreadyExistException.java similarity index 92% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionAlreadyExistException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionAlreadyExistException.java index 2aeec526..430344a6 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionAlreadyExistException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionAlreadyExistException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when creating a region with name already in use. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionNotFoundException.java similarity index 89% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionNotFoundException.java index c49671f3..fb3054b9 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/RegionNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.db.exception; +package com.datastax.astra.devops.db.exception; /** * Exception thrown when accessing a region from its name, and it is not found. diff --git a/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/package-info.java new file mode 100644 index 00000000..d86d0c88 --- /dev/null +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/exception/package-info.java @@ -0,0 +1,2 @@ +/** Exceptions for Astra Db Service. */ +package com.datastax.astra.devops.db.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/package-info.java similarity index 56% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/package-info.java index be73bb01..fd14174d 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/db/package-info.java @@ -1,2 +1,2 @@ /** Sub Clients relative to Astra Db Service. */ -package com.dtsx.astra.sdk.db; \ No newline at end of file +package com.datastax.astra.devops.db; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/AuthenticationException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/AuthenticationException.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/AuthenticationException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/AuthenticationException.java index bcfbb6dc..879d62f1 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/AuthenticationException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/AuthenticationException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.exception; +package com.datastax.astra.devops.exception; /** * Specialized Error. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/package-info.java similarity index 54% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/package-info.java index c847da90..b556e817 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/exception/package-info.java @@ -1,2 +1,2 @@ /** Specialized Exceptions for Astra Devops API. */ -package com.dtsx.astra.sdk.exception; \ No newline at end of file +package com.datastax.astra.devops.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/KeysClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/KeysClient.java similarity index 76% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/KeysClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/KeysClient.java index 55ac98c7..e181783d 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/KeysClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/KeysClient.java @@ -1,13 +1,13 @@ -package com.dtsx.astra.sdk.org; +package com.datastax.astra.devops.org; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.org.domain.Key; -import com.dtsx.astra.sdk.org.domain.KeyDefinition; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.org.domain.KeyDefinition; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.org.domain.Key; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/RolesClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/RolesClient.java similarity index 88% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/RolesClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/RolesClient.java index 1e87bad4..278181d8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/RolesClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/RolesClient.java @@ -1,16 +1,16 @@ -package com.dtsx.astra.sdk.org; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.org.domain.CreateRoleResponse; -import com.dtsx.astra.sdk.org.domain.DefaultRoles; -import com.dtsx.astra.sdk.org.domain.Role; -import com.dtsx.astra.sdk.org.domain.RoleDefinition; -import com.dtsx.astra.sdk.org.exception.RoleNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops.org; + +import com.datastax.astra.devops.org.domain.CreateRoleResponse; +import com.datastax.astra.devops.org.domain.DefaultRoles; +import com.datastax.astra.devops.org.domain.Role; +import com.datastax.astra.devops.org.domain.RoleDefinition; +import com.datastax.astra.devops.org.exception.RoleNotFoundException; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import com.fasterxml.jackson.core.type.TypeReference; import java.net.HttpURLConnection; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/TokensClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/TokensClient.java similarity index 85% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/TokensClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/TokensClient.java index a3067d95..65a85cfc 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/TokensClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/TokensClient.java @@ -1,16 +1,16 @@ -package com.dtsx.astra.sdk.org; +package com.datastax.astra.devops.org; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.org.domain.CreateTokenResponse; -import com.dtsx.astra.sdk.org.domain.DefaultRoles; -import com.dtsx.astra.sdk.org.domain.IamToken; -import com.dtsx.astra.sdk.org.domain.ResponseAllIamTokens; -import com.dtsx.astra.sdk.org.domain.Role; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.org.domain.ResponseAllIamTokens; +import com.datastax.astra.devops.org.domain.Role; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.org.domain.CreateTokenResponse; +import com.datastax.astra.devops.org.domain.DefaultRoles; +import com.datastax.astra.devops.org.domain.IamToken; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; import java.util.Optional; import java.util.stream.Stream; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/UsersClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/UsersClient.java similarity index 86% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/UsersClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/UsersClient.java index c4beb3c8..6c6ba6b4 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/UsersClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/UsersClient.java @@ -1,16 +1,26 @@ -package com.dtsx.astra.sdk.org; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.AstraOpsClient; -import com.dtsx.astra.sdk.org.domain.InviteUserRequest; -import com.dtsx.astra.sdk.org.domain.ResponseAllUsers; -import com.dtsx.astra.sdk.org.domain.Role; -import com.dtsx.astra.sdk.org.domain.User; -import com.dtsx.astra.sdk.org.exception.UserNotFoundException; -import com.dtsx.astra.sdk.utils.*; +package com.datastax.astra.devops.org; + +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.AstraDevopsClient; +import com.datastax.astra.devops.org.domain.InviteUserRequest; +import com.datastax.astra.devops.org.domain.ResponseAllUsers; +import com.datastax.astra.devops.org.domain.Role; +import com.datastax.astra.devops.org.domain.User; +import com.datastax.astra.devops.org.exception.UserNotFoundException; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.IdUtils; +import com.datastax.astra.devops.utils.JsonUtils; import java.net.HttpURLConnection; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Stream; /** @@ -146,7 +156,7 @@ public void invite(String email, String... roles) { // Build the invite request with expected roles RolesClient rolesClient = new RolesClient(token); - AstraOpsClient devopsApiClient = new AstraOpsClient(token); + AstraDevopsClient devopsApiClient = new AstraDevopsClient(token); InviteUserRequest inviteRequest = new InviteUserRequest(devopsApiClient.getOrganizationId(), email); Arrays.asList(roles).forEach(currentRole -> { if (IdUtils.isUUID(currentRole)) { diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateRoleResponse.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateRoleResponse.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateRoleResponse.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateRoleResponse.java index 65456476..5cdc268c 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateRoleResponse.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateRoleResponse.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateTokenResponse.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateTokenResponse.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateTokenResponse.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateTokenResponse.java index 00962f39..6bd29e39 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/CreateTokenResponse.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/CreateTokenResponse.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/DefaultRoles.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/DefaultRoles.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/DefaultRoles.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/DefaultRoles.java index d44df5e6..6a925054 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/DefaultRoles.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/DefaultRoles.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; /** * Astra does provide some Ad Hoc roles with keys and labels. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/IamToken.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/IamToken.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/IamToken.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/IamToken.java index 19fd2273..c1a609e9 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/IamToken.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/IamToken.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/InviteUserRequest.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/InviteUserRequest.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/InviteUserRequest.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/InviteUserRequest.java index a1c07dc1..87fda7cb 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/InviteUserRequest.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/InviteUserRequest.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.ArrayList; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Key.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Key.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Key.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Key.java index 058e75eb..eb44ba8b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Key.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Key.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyDefinition.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyDefinition.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyDefinition.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyDefinition.java index 53fc9416..d2175e6f 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyDefinition.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyDefinition.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyRegionDefinition.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyRegionDefinition.java similarity index 96% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyRegionDefinition.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyRegionDefinition.java index 910946c8..3893aa19 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyRegionDefinition.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/KeyRegionDefinition.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Organization.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Organization.java similarity index 96% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Organization.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Organization.java index 5c0f9b50..26760c3d 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Organization.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Organization.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Permission.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Permission.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Permission.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Permission.java index 7688d8d9..85284be7 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Permission.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Permission.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; /** diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllIamTokens.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllIamTokens.java similarity index 93% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllIamTokens.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllIamTokens.java index 49596bed..c5dc4ea6 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllIamTokens.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllIamTokens.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllUsers.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllUsers.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllUsers.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllUsers.java index f6b09b21..05d8b567 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllUsers.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/ResponseAllUsers.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Role.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Role.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Role.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Role.java index 36eed7e1..a9b4bea2 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/Role.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/Role.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.ArrayList; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RoleDefinition.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RoleDefinition.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RoleDefinition.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RoleDefinition.java index 6f1b74fe..12a49219 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RoleDefinition.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RoleDefinition.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.util.ArrayList; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RolePolicy.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RolePolicy.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RolePolicy.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RolePolicy.java index 3a39e8d9..ff449146 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/RolePolicy.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/RolePolicy.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.ArrayList; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/User.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/User.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/User.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/User.java index 1561f06f..4934efea 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/User.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/User.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; import java.io.Serializable; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/UserStatus.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/UserStatus.java similarity index 77% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/UserStatus.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/UserStatus.java index 9f398cce..ee077c11 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/UserStatus.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/UserStatus.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.domain; +package com.datastax.astra.devops.org.domain; /** * User status in the db. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/package-info.java similarity index 60% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/package-info.java index 785f918a..bcab0da3 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/domain/package-info.java @@ -1,2 +1,2 @@ /** Entities and Pojo for Astra Core Service (IAM, Organization). */ -package com.dtsx.astra.sdk.org.domain; \ No newline at end of file +package com.datastax.astra.devops.org.domain; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/RoleNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/RoleNotFoundException.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/RoleNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/RoleNotFoundException.java index 1e2e0e3e..ac1f6620 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/RoleNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/RoleNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.exception; +package com.datastax.astra.devops.org.exception; /*- * #%L diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserAlreadyExistException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserAlreadyExistException.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserAlreadyExistException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserAlreadyExistException.java index 91e2fbc8..d2a9b844 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserAlreadyExistException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserAlreadyExistException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.exception; +package com.datastax.astra.devops.org.exception; /*- * #%L diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserNotFoundException.java similarity index 88% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserNotFoundException.java index da161751..334470c1 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/UserNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.org.exception; +package com.datastax.astra.devops.org.exception; /** * Exception thrown when accessing a user that does not exist. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/package-info.java similarity index 56% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/package-info.java index 3f47847e..3a5c81e2 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/exception/package-info.java @@ -1,2 +1,2 @@ /** Exceptions for Astra Core Service (IAM, Organization). */ -package com.dtsx.astra.sdk.org.exception; \ No newline at end of file +package com.datastax.astra.devops.org.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/package-info.java similarity index 65% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/package-info.java index 186f89e7..39ff08be 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/org/package-info.java @@ -1,2 +1,2 @@ /** Sub Clients relative to Astra Core Service (IAM, Organization). */ -package com.dtsx.astra.sdk.org; \ No newline at end of file +package com.datastax.astra.devops.org; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/package-info.java similarity index 52% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/package-info.java index 113b5176..e6a9f2a1 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/package-info.java @@ -1,2 +1,2 @@ /** Devops Api Client main class. */ -package com.dtsx.astra.sdk; \ No newline at end of file +package com.datastax.astra.devops; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/AstraStreamingClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/AstraStreamingClient.java similarity index 91% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/AstraStreamingClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/AstraStreamingClient.java index dab85994..f5ddcfdc 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/AstraStreamingClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/AstraStreamingClient.java @@ -1,14 +1,14 @@ -package com.dtsx.astra.sdk.streaming; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.streaming.exception.TenantNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops.streaming; + +import com.datastax.astra.devops.streaming.domain.CreateTenant; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.streaming.exception.TenantNotFoundException; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; -import com.dtsx.astra.sdk.streaming.domain.CreateTenant; -import com.dtsx.astra.sdk.streaming.domain.Tenant; import java.net.HttpURLConnection; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ClustersClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ClustersClient.java similarity index 87% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ClustersClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ClustersClient.java index ac397104..6fab0e7d 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ClustersClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ClustersClient.java @@ -1,14 +1,14 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; import java.util.List; import java.util.Optional; import java.util.stream.Stream; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.streaming.domain.Cluster; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.streaming.domain.Cluster; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; /** diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ProvidersClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ProvidersClient.java similarity index 83% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ProvidersClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ProvidersClient.java index 645c797f..353ec6bf 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/ProvidersClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/ProvidersClient.java @@ -1,9 +1,9 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import java.util.List; import java.util.Map; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/RegionsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/RegionsClient.java similarity index 85% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/RegionsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/RegionsClient.java index fd34b41b..c576a2c1 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/RegionsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/RegionsClient.java @@ -1,11 +1,11 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.streaming.domain.StreamingRegion; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponse; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.streaming.domain.StreamingRegion; +import com.datastax.astra.devops.utils.ApiResponse; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantCdcClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantCdcClient.java similarity index 83% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantCdcClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantCdcClient.java index 74e0ec8e..5b492336 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantCdcClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantCdcClient.java @@ -1,19 +1,19 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException; -import com.dtsx.astra.sdk.streaming.domain.CdcDefinition; -import com.dtsx.astra.sdk.streaming.domain.CreateCdc; -import com.dtsx.astra.sdk.streaming.domain.DeleteCdc; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.streaming.domain.CdcDefinition; +import com.datastax.astra.devops.streaming.domain.CreateCdc; +import com.datastax.astra.devops.streaming.domain.DeleteCdc; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.exception.KeyspaceNotFoundException; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -75,7 +75,7 @@ public void create(String databaseId, String keyspace, String table, int topicPa Assert.hasLength(keyspace, "keyspace"); Assert.hasLength(table, "table"); Assert.isTrue(topicPartition > 0, "topic partition should be positive"); - Database db = new AstraDBOpsClient(token, environment).database(databaseId).get(); + Database db = new AstraDBDevopsClient(token, environment).database(databaseId).get(); if (!db.getInfo().getKeyspaces().contains(keyspace)) { throw new KeyspaceNotFoundException(databaseId, keyspace); } @@ -106,7 +106,7 @@ public void create(String databaseId, String keyspace, String table, int topicPa public void delete(String databaseId, String keyspace, String table) { Assert.hasLength(keyspace, "keyspace"); Assert.hasLength(table, "table"); - Database db = new AstraDBOpsClient(token, environment).database(databaseId).get(); + Database db = new AstraDBDevopsClient(token, environment).database(databaseId).get(); DeleteCdc deleteCdc = new DeleteCdc(); deleteCdc.setOrgId(db.getOrgId()); deleteCdc.setDatabaseId(db.getId()); diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantClient.java similarity index 85% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantClient.java index 08d346a3..a0c86ef2 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantClient.java @@ -1,14 +1,14 @@ -package com.dtsx.astra.sdk.streaming; - -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.AstraOpsClient; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.streaming.exception.TenantNotFoundException; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +package com.datastax.astra.devops.streaming; + +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.streaming.exception.TenantNotFoundException; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.AstraDevopsClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import java.net.HttpURLConnection; import java.util.Optional; @@ -54,7 +54,7 @@ public TenantClient(String token, AstraEnvironment env, String tenantId) { super(token, env); Assert.hasLength(tenantId, "tenantId"); this.tenantId = tenantId; - this.organizationId = new AstraOpsClient(token,env).getOrganizationId(); + this.organizationId = new AstraDevopsClient(token,env).getOrganizationId(); } // --------------------------------- diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantLimitsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantLimitsClient.java similarity index 78% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantLimitsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantLimitsClient.java index 943d0861..4d4d7f3c 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantLimitsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantLimitsClient.java @@ -1,13 +1,13 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.streaming.domain.TenantLimit; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.ApiResponseHttp; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.streaming.domain.TenantLimit; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.ApiResponseHttp; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantStatsClient.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantStatsClient.java similarity index 90% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantStatsClient.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantStatsClient.java index 92b7a26c..0411bbbb 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/TenantStatsClient.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/TenantStatsClient.java @@ -1,13 +1,13 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractApiClient; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.Assert; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.HttpClientWrapper; -import com.dtsx.astra.sdk.streaming.domain.Statistics; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.utils.JsonUtils; +import com.datastax.astra.devops.streaming.domain.Statistics; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.AbstractApiClient; +import com.datastax.astra.devops.utils.ApiLocator; +import com.datastax.astra.devops.utils.Assert; +import com.datastax.astra.devops.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.HttpClientWrapper; +import com.datastax.astra.devops.utils.JsonUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.Map; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CdcDefinition.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CdcDefinition.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CdcDefinition.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CdcDefinition.java index 23437770..283913f7 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CdcDefinition.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CdcDefinition.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Cluster.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Cluster.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Cluster.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Cluster.java index f028adf1..4e445fcd 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Cluster.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Cluster.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import java.io.Serializable; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateCdc.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateCdc.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateCdc.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateCdc.java index f65e16b9..14783a72 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateCdc.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateCdc.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; /** * Cdc Creation Request. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenant.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenant.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenant.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenant.java index 278b0bff..aee7bae2 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenant.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenant.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; /** * Tenant Request Creation. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenantResponse.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenantResponse.java similarity index 84% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenantResponse.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenantResponse.java index 532198aa..eace8894 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenantResponse.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/CreateTenantResponse.java @@ -1,9 +1,8 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; /** * Represents the pojo for tenant creation. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/DeleteCdc.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/DeleteCdc.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/DeleteCdc.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/DeleteCdc.java index ff7869f5..7b0b6172 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/DeleteCdc.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/DeleteCdc.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; /** * Delete a tenant. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Statistics.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Statistics.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Statistics.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Statistics.java index 71e2b6d7..89fb7b63 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Statistics.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Statistics.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/StreamingRegion.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/StreamingRegion.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/StreamingRegion.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/StreamingRegion.java index 7336cd65..ba619879 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/StreamingRegion.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/StreamingRegion.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; /** * Bean to hold value for a Streaming region. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Tenant.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Tenant.java similarity index 94% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Tenant.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Tenant.java index b09f0dfc..1c376e2b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Tenant.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/Tenant.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import java.util.UUID; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/TenantLimit.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/TenantLimit.java similarity index 98% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/TenantLimit.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/TenantLimit.java index 0c97922d..675a4414 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/TenantLimit.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/TenantLimit.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.domain; +package com.datastax.astra.devops.streaming.domain; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/package-info.java similarity index 51% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/package-info.java index c9294068..bfa7898d 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/domain/package-info.java @@ -1,2 +1,2 @@ /** Entities and Pojo for Astra Streaming Service. */ -package com.dtsx.astra.sdk.streaming.domain; \ No newline at end of file +package com.datastax.astra.devops.streaming.domain; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantAlreadyExistException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantAlreadyExistException.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantAlreadyExistException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantAlreadyExistException.java index 9eb45873..cd7c586e 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantAlreadyExistException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantAlreadyExistException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.exception; +package com.datastax.astra.devops.streaming.exception; /*- * #%L diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantNotFoundException.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantNotFoundException.java similarity index 87% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantNotFoundException.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantNotFoundException.java index 29d4fb37..779b053c 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantNotFoundException.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/TenantNotFoundException.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.streaming.exception; +package com.datastax.astra.devops.streaming.exception; /** * Exception thrown when accessing a tenant that does not exist. diff --git a/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/package-info.java new file mode 100644 index 00000000..e2c82e3e --- /dev/null +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/exception/package-info.java @@ -0,0 +1,2 @@ +/** Exceptions for Astra Streaming Service. */ +package com.datastax.astra.devops.streaming.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/package-info.java similarity index 69% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/package-info.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/package-info.java index c47ac466..797a30b9 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/package-info.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/streaming/package-info.java @@ -1,2 +1,2 @@ /** Sub Clients relative to Astra Streaming Service and Providers for Pulsar admin and client. */ -package com.dtsx.astra.sdk.streaming; \ No newline at end of file +package com.datastax.astra.devops.streaming; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiError.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiError.java similarity index 95% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiError.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiError.java index da8f9036..e9ac1ac5 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiError.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiError.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiLocator.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiLocator.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiLocator.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiLocator.java index 56a267fc..286d4439 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiLocator.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiLocator.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; /** * Utility class to find endpoints of the Astra APIs. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponse.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponse.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponse.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponse.java index 3b555cf5..973826a4 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponse.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponse.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseError.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseError.java similarity index 89% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseError.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseError.java index f0646f6e..e7bcfd63 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseError.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseError.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import java.util.List; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseHttp.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseHttp.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseHttp.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseHttp.java index 78bbc833..9cbf5d4e 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseHttp.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/ApiResponseHttp.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import java.util.HashMap; import java.util.Map; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Assert.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Assert.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Assert.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Assert.java index 7e2158af..c14626a8 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Assert.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Assert.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; /** * Syntaxic sugar for common validations. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraEnvironment.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraEnvironment.java similarity index 97% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraEnvironment.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraEnvironment.java index b2cc899d..ff02607b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraEnvironment.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraEnvironment.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; /** * SDk to be used on multiple Astra Environment. diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraRc.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraRc.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraRc.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraRc.java index b5e2f353..70f9a250 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/AstraRc.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/AstraRc.java @@ -12,7 +12,7 @@ * governing permissions and limitations under the License. */ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import java.io.File; import java.io.FileNotFoundException; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/HttpClientWrapper.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/HttpClientWrapper.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/HttpClientWrapper.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/HttpClientWrapper.java index 18a8062e..2aa2a516 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/HttpClientWrapper.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/HttpClientWrapper.java @@ -1,6 +1,6 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; -import com.dtsx.astra.sdk.exception.AuthenticationException; +import com.datastax.astra.devops.exception.AuthenticationException; import org.apache.hc.client5.http.auth.StandardAuthScheme; import org.apache.hc.client5.http.classic.methods.*; import org.apache.hc.client5.http.config.RequestConfig; @@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory; import java.net.HttpURLConnection; -import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/IdUtils.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/IdUtils.java similarity index 92% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/IdUtils.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/IdUtils.java index 7448345a..b488a92b 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/IdUtils.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/IdUtils.java @@ -1,4 +1,4 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import java.util.UUID; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/JsonUtils.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/JsonUtils.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/JsonUtils.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/JsonUtils.java index 3127c2b0..7ff6e864 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/JsonUtils.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/JsonUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonParser; diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/TestUtils.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/TestUtils.java similarity index 91% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/TestUtils.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/TestUtils.java index 347a6fe3..e8d341cd 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/TestUtils.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/TestUtils.java @@ -1,12 +1,12 @@ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.DbOpsClient; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationBuilder; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationRequest; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.db.DbOpsClient; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseCreationBuilder; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClients; @@ -156,7 +156,7 @@ public static String setupDatabase(AstraEnvironment env, String dbName, String k * the database id */ public static String setupDatabase(String token, AstraEnvironment env, String dbName, String keyspace, boolean vector) { - AstraDBOpsClient devopsDbCli = new AstraDBOpsClient(getAstraToken(), env); + AstraDBDevopsClient devopsDbCli = new AstraDBDevopsClient(getAstraToken(), env); Optional optDb = devopsDbCli.findByName(dbName).findAny(); if (optDb.isPresent()) { // Db is present, should we resume it ? @@ -232,8 +232,8 @@ public static void waitForSeconds(int seconds) { * @param dbName * database name */ - public static void terminateDatabaseByName(AstraDBOpsClient devopsDbCli, String dbName) { - DbOpsClient dbc = new AstraDBOpsClient(devopsDbCli.getToken()).databaseByName(dbName); + public static void terminateDatabaseByName(AstraDBDevopsClient devopsDbCli, String dbName) { + DbOpsClient dbc = new AstraDBDevopsClient(devopsDbCli.getToken()).databaseByName(dbName); if(dbc.exist()) { dbc.delete(); waitForDbStatus(dbc, DatabaseStatusType.TERMINATED, 60); diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Utils.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Utils.java similarity index 99% rename from astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Utils.java rename to astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Utils.java index 0d1053dd..569f92b9 100644 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/Utils.java +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/Utils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.dtsx.astra.sdk.utils; +package com.datastax.astra.devops.utils; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; diff --git a/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/package-info.java b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/package-info.java new file mode 100644 index 00000000..387160cd --- /dev/null +++ b/astra-sdk-devops/src/main/java/com/datastax/astra/devops/utils/package-info.java @@ -0,0 +1,2 @@ +/** Utility Classes for devops. */ +package com.datastax.astra.devops.utils; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/package-info.java b/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/package-info.java deleted file mode 100644 index 8a6e53f9..00000000 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Exceptions for Astra Db Service. */ -package com.dtsx.astra.sdk.db.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/package-info.java b/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/package-info.java deleted file mode 100644 index f520589c..00000000 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Exceptions for Astra Streaming Service. */ -package com.dtsx.astra.sdk.streaming.exception; \ No newline at end of file diff --git a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/package-info.java b/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/package-info.java deleted file mode 100644 index c30a00e2..00000000 --- a/astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Utility Classes for devops. */ -package com.dtsx.astra.sdk.utils; \ No newline at end of file diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/AbstractDevopsApiTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/AbstractDevopsApiTest.java similarity index 80% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/AbstractDevopsApiTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/AbstractDevopsApiTest.java index 64607136..19c29805 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/AbstractDevopsApiTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/AbstractDevopsApiTest.java @@ -1,11 +1,11 @@ -package com.dtsx.astra.sdk; - -import com.dtsx.astra.sdk.db.DbOpsClient; -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationRequest; -import com.dtsx.astra.sdk.streaming.AstraStreamingClient; -import com.dtsx.astra.sdk.utils.AstraRc; -import com.dtsx.astra.sdk.utils.Utils; +package com.datastax.astra.devops; + +import com.datastax.astra.devops.db.DbOpsClient; +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.streaming.AstraStreamingClient; +import com.datastax.astra.devops.utils.AstraRc; +import com.datastax.astra.devops.utils.Utils; import org.junit.jupiter.api.Assertions; /** @@ -36,12 +36,12 @@ public abstract class AbstractDevopsApiTest { /** * Reference to Databases Client. */ - private static AstraDBOpsClient databasesClient; + private static AstraDBDevopsClient databasesClient; /** * Reference to organization client. */ - private static AstraOpsClient apiDevopsClient; + private static AstraDevopsClient apiDevopsClient; /** * Working db. @@ -59,9 +59,9 @@ public abstract class AbstractDevopsApiTest { * @return * client fot databases */ - protected AstraOpsClient getApiDevopsClient() { + protected AstraDevopsClient getApiDevopsClient() { if (apiDevopsClient == null) { - apiDevopsClient = new AstraOpsClient(getToken()); + apiDevopsClient = new AstraDevopsClient(getToken()); } return apiDevopsClient; } @@ -72,9 +72,9 @@ protected AstraOpsClient getApiDevopsClient() { * @return * client fot databases */ - protected AstraDBOpsClient getDatabasesClient() { + protected AstraDBDevopsClient getDatabasesClient() { if (databasesClient == null) { - databasesClient = new AstraDBOpsClient(getToken()); + databasesClient = new AstraDBDevopsClient(getToken()); } return databasesClient; } diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/ApiDevopsClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/ApiDevopsClientTest.java similarity index 84% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/ApiDevopsClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/ApiDevopsClientTest.java index 6d463bbb..7258c7e0 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/ApiDevopsClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/ApiDevopsClientTest.java @@ -1,9 +1,9 @@ -package com.dtsx.astra.sdk; +package com.datastax.astra.devops; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.DatabaseRegion; -import com.dtsx.astra.sdk.db.domain.RegionType; -import com.dtsx.astra.sdk.org.domain.Organization; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.DatabaseRegion; +import com.datastax.astra.devops.db.domain.RegionType; +import com.datastax.astra.devops.org.domain.Organization; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; @@ -68,16 +68,16 @@ public void shouldFindAwsRegionAvailable() { public void shouldFailOnInvalidParams() { LOGGER.info("Parameter validation"); Assertions.assertThrows(IllegalArgumentException.class, - () -> new AstraOpsClient("")); + () -> new AstraDevopsClient("")); Assertions.assertThrows(IllegalArgumentException.class, - () -> new AstraOpsClient((String)null)); + () -> new AstraDevopsClient((String)null)); } @Test @Order(5) @DisplayName("Listing serverless region for an organization") public void shouldListServerlessRegionTest() { - AstraOpsClient iamClient = new AstraOpsClient(getToken()); + AstraDevopsClient iamClient = new AstraDevopsClient(getToken()); Assertions.assertTrue(iamClient.db().regions().findAllServerless(RegionType.ALL).count() > 0); } diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/CdcClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/CdcClientTest.java similarity index 95% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/CdcClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/CdcClientTest.java index a3095e1c..097ca196 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/CdcClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/CdcClientTest.java @@ -1,11 +1,11 @@ -package com.dtsx.astra.sdk.db; - -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.streaming.domain.CdcDefinition; -import com.dtsx.astra.sdk.streaming.domain.CreateTenant; -import com.dtsx.astra.sdk.utils.TestUtils; +package com.datastax.astra.devops.db; + +import com.datastax.astra.devops.streaming.domain.CdcDefinition; +import com.datastax.astra.devops.streaming.domain.CreateTenant; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.utils.TestUtils; import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabaseClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabaseClientTest.java similarity index 93% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabaseClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabaseClientTest.java index 897a61ce..e0aced9e 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabaseClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabaseClientTest.java @@ -1,15 +1,15 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.db.domain.AccessListAddressRequest; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.db.domain.Datacenter; -import com.dtsx.astra.sdk.db.exception.KeyspaceAlreadyExistException; -import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException; -import com.dtsx.astra.sdk.db.exception.RegionAlreadyExistException; -import com.dtsx.astra.sdk.db.exception.RegionNotFoundException; -import com.dtsx.astra.sdk.utils.TestUtils; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.db.domain.AccessListAddressRequest; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.db.domain.Datacenter; +import com.datastax.astra.devops.db.exception.KeyspaceAlreadyExistException; +import com.datastax.astra.devops.db.exception.KeyspaceNotFoundException; +import com.datastax.astra.devops.db.exception.RegionAlreadyExistException; +import com.datastax.astra.devops.db.exception.RegionNotFoundException; +import com.datastax.astra.devops.utils.TestUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabasesClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabasesClientTest.java similarity index 93% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabasesClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabasesClientTest.java index 44496acd..b7346b90 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/DatabasesClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/DatabasesClientTest.java @@ -1,11 +1,11 @@ -package com.dtsx.astra.sdk.db; - -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationRequest; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.utils.TestUtils; +package com.datastax.astra.devops.db; + +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.db.domain.DatabaseStatusType; +import com.datastax.astra.devops.utils.TestUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; @@ -25,8 +25,8 @@ public class DatabasesClientTest extends AbstractDevopsApiTest { @Order(1) @DisplayName("Initialization with Invalid Parameters") public void failInitializationsWithInvalidParamsTest() { - Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraDBOpsClient("")); - Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraDBOpsClient(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraDBDevopsClient("")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraDBDevopsClient(null)); } @Test diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/NonProductionEnvironmentTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/NonProductionEnvironmentTest.java similarity index 66% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/NonProductionEnvironmentTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/NonProductionEnvironmentTest.java index 066e96eb..ea2fd45d 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/db/NonProductionEnvironmentTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/db/NonProductionEnvironmentTest.java @@ -1,17 +1,13 @@ -package com.dtsx.astra.sdk.db; +package com.datastax.astra.devops.db; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.db.domain.CloudProviderType; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.db.domain.DatabaseCreationRequest; -import com.dtsx.astra.sdk.db.domain.DatabaseInfo; -import com.dtsx.astra.sdk.db.domain.DatabaseStatusType; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.TestUtils; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.db.domain.CloudProviderType; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.db.domain.DatabaseCreationRequest; +import com.datastax.astra.devops.db.domain.DatabaseInfo; +import com.datastax.astra.devops.utils.AstraEnvironment; import org.junit.jupiter.api.Test; -import java.util.UUID; - public class NonProductionEnvironmentTest extends AbstractDevopsApiTest { static String tokenDev = System.getenv("ASTRA_DB_APPLICATION_TOKEN_DEV"); @@ -20,7 +16,7 @@ public class NonProductionEnvironmentTest extends AbstractDevopsApiTest { @Test public void shouldListDatabasesDev() { - AstraDBOpsClient opsClient = new AstraDBOpsClient(tokenDev2, AstraEnvironment.DEV); + AstraDBDevopsClient opsClient = new AstraDBDevopsClient(tokenDev2, AstraEnvironment.DEV); opsClient.findAllNonTerminated().map(Database::getInfo).map(DatabaseInfo::getName).forEach(System.out::println); //opsClient.databaseByName("sdk_java_test_vector").accessLists(); diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/RolesClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/RolesClientTest.java similarity index 90% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/RolesClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/RolesClientTest.java index f259377c..87061dd6 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/RolesClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/RolesClientTest.java @@ -1,13 +1,13 @@ -package com.dtsx.astra.sdk.iam; +package com.datastax.astra.devops.iam; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.ApiDevopsClientTest; -import com.dtsx.astra.sdk.org.RolesClient; -import com.dtsx.astra.sdk.org.domain.CreateRoleResponse; -import com.dtsx.astra.sdk.org.domain.DefaultRoles; -import com.dtsx.astra.sdk.org.domain.Permission; -import com.dtsx.astra.sdk.org.domain.Role; -import com.dtsx.astra.sdk.org.domain.RoleDefinition; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.ApiDevopsClientTest; +import com.datastax.astra.devops.org.RolesClient; +import com.datastax.astra.devops.org.domain.CreateRoleResponse; +import com.datastax.astra.devops.org.domain.DefaultRoles; +import com.datastax.astra.devops.org.domain.Permission; +import com.datastax.astra.devops.org.domain.Role; +import com.datastax.astra.devops.org.domain.RoleDefinition; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/TokensClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/TokensClientTest.java similarity index 85% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/TokensClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/TokensClientTest.java index cc0893a9..ec512f38 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/TokensClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/TokensClientTest.java @@ -1,8 +1,8 @@ -package com.dtsx.astra.sdk.iam; +package com.datastax.astra.devops.iam; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.org.domain.CreateTokenResponse; -import com.dtsx.astra.sdk.org.domain.DefaultRoles; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.org.domain.CreateTokenResponse; +import com.datastax.astra.devops.org.domain.DefaultRoles; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/UsersClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/UsersClientTest.java similarity index 86% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/UsersClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/UsersClientTest.java index 47e55c08..a7911582 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/iam/UsersClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/iam/UsersClientTest.java @@ -1,9 +1,9 @@ -package com.dtsx.astra.sdk.iam; +package com.datastax.astra.devops.iam; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.org.UsersClient; -import com.dtsx.astra.sdk.org.domain.DefaultRoles; -import com.dtsx.astra.sdk.org.domain.User; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.org.UsersClient; +import com.datastax.astra.devops.org.domain.DefaultRoles; +import com.datastax.astra.devops.org.domain.User; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/AstraStreamingClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/AstraStreamingClientTest.java similarity index 86% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/AstraStreamingClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/AstraStreamingClientTest.java index 364e0b1d..509cef33 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/AstraStreamingClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/AstraStreamingClientTest.java @@ -1,7 +1,7 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.streaming.domain.Tenant; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.streaming.domain.Tenant; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.Order; @@ -12,7 +12,7 @@ import java.util.stream.Collectors; @TestMethodOrder(OrderAnnotation.class) -public class AstraStreamingClientTest extends AbstractDevopsApiTest { +public class AstraStreamingClientTest extends AbstractDevopsApiTest { @Test @Order(1) diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ClustersClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ClustersClientTest.java similarity index 89% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ClustersClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ClustersClientTest.java index b971d879..94c11d1e 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ClustersClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ClustersClientTest.java @@ -1,7 +1,7 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.streaming.domain.Cluster; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.streaming.domain.Cluster; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ProvidersClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ProvidersClientTest.java similarity index 90% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ProvidersClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ProvidersClientTest.java index 0639a0af..e34672a7 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ProvidersClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/ProvidersClientTest.java @@ -1,6 +1,6 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; +import com.datastax.astra.devops.AbstractDevopsApiTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/RegionClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/RegionClientTest.java similarity index 84% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/RegionClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/RegionClientTest.java index 050fae55..e8422d89 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/RegionClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/RegionClientTest.java @@ -1,7 +1,7 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.streaming.domain.StreamingRegion; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.streaming.domain.StreamingRegion; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantClientTest.java similarity index 90% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantClientTest.java index 69fd56a2..0ae1e251 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantClientTest.java @@ -1,7 +1,7 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.streaming.domain.CreateTenant; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.streaming.domain.CreateTenant; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; diff --git a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantStatsClientTest.java b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantStatsClientTest.java similarity index 92% rename from astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantStatsClientTest.java rename to astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantStatsClientTest.java index 1afeac35..4e1ca3a5 100644 --- a/astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/TenantStatsClientTest.java +++ b/astra-sdk-devops/src/test/java/com/datastax/astra/devops/streaming/TenantStatsClientTest.java @@ -1,8 +1,8 @@ -package com.dtsx.astra.sdk.streaming; +package com.datastax.astra.devops.streaming; -import com.dtsx.astra.sdk.AbstractDevopsApiTest; -import com.dtsx.astra.sdk.streaming.domain.CreateTenant; -import com.dtsx.astra.sdk.streaming.domain.Statistics; +import com.datastax.astra.devops.AbstractDevopsApiTest; +import com.datastax.astra.devops.streaming.domain.CreateTenant; +import com.datastax.astra.devops.streaming.domain.Statistics; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; diff --git a/astra-sdk-pulsar/src/main/java/com/dtsx/astra/sdk/streaming/PulsarClientProvider.java b/astra-sdk-pulsar/src/main/java/com/dtsx/astra/sdk/streaming/PulsarClientProvider.java index 1301928c..0f3a9217 100644 --- a/astra-sdk-pulsar/src/main/java/com/dtsx/astra/sdk/streaming/PulsarClientProvider.java +++ b/astra-sdk-pulsar/src/main/java/com/dtsx/astra/sdk/streaming/PulsarClientProvider.java @@ -1,7 +1,8 @@ package com.dtsx.astra.sdk.streaming; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.utils.AstraEnvironment; +import com.datastax.astra.devops.streaming.TenantClient; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.utils.AstraEnvironment; import org.apache.pulsar.client.api.AuthenticationFactory; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; diff --git a/astra-sdk-pulsar/src/test/java/com/dtsx/astra/sdk/streaming/PulsarAdminAstraStreamingTest.java b/astra-sdk-pulsar/src/test/java/com/dtsx/astra/sdk/streaming/PulsarAdminAstraStreamingTest.java index 5c12e7c5..2ea8c84c 100644 --- a/astra-sdk-pulsar/src/test/java/com/dtsx/astra/sdk/streaming/PulsarAdminAstraStreamingTest.java +++ b/astra-sdk-pulsar/src/test/java/com/dtsx/astra/sdk/streaming/PulsarAdminAstraStreamingTest.java @@ -1,14 +1,14 @@ package com.dtsx.astra.sdk.streaming; -import com.dtsx.astra.sdk.streaming.domain.CreateTenant; -import com.dtsx.astra.sdk.streaming.domain.Tenant; -import com.dtsx.astra.sdk.utils.AstraRc; -import com.dtsx.astra.sdk.utils.Utils; +import com.datastax.astra.devops.streaming.AstraStreamingClient; +import com.datastax.astra.devops.streaming.domain.CreateTenant; +import com.datastax.astra.devops.streaming.domain.Tenant; +import com.datastax.astra.devops.utils.AstraRc; +import com.datastax.astra.devops.utils.Utils; import org.apache.pulsar.client.admin.PulsarAdmin; import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; -import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; diff --git a/astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java b/astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java index e8a927a3..34b9e2f6 100644 --- a/astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java +++ b/astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java @@ -16,17 +16,17 @@ package com.datastax.astra.sdk; +import com.datastax.astra.db.AstraDBClient; +import com.datastax.astra.db.AstraDBDatabase; +import com.datastax.astra.devops.AstraDevopsClient; +import com.datastax.astra.devops.db.AstraDBDevopsClient; +import com.datastax.astra.devops.db.domain.Database; +import com.datastax.astra.devops.streaming.AstraStreamingClient; +import com.datastax.astra.devops.utils.ApiLocator; import com.datastax.astra.sdk.config.AstraClientConfig; import com.datastax.oss.driver.api.core.CqlSession; -import com.dtsx.astra.sdk.AstraDB; -import com.dtsx.astra.sdk.AstraDBAdmin; -import com.dtsx.astra.sdk.AstraOpsClient; -import com.dtsx.astra.sdk.db.AstraDBOpsClient; -import com.dtsx.astra.sdk.db.domain.Database; -import com.dtsx.astra.sdk.streaming.AstraStreamingClient; -import com.dtsx.astra.sdk.utils.ApiLocator; import io.stargate.sdk.StargateClient; -import io.stargate.sdk.api.SimpleTokenProvider; +import io.stargate.sdk.auth.FixedTokenAuthenticationService; import io.stargate.sdk.doc.StargateDocumentApiClient; import io.stargate.sdk.gql.StargateGraphQLApiClient; import io.stargate.sdk.grpc.ServiceGrpc; @@ -62,10 +62,10 @@ public class AstraClient implements Closeable { // ----------------------------------------------------- /** Hold a reference for the Api Devops. */ - private AstraOpsClient apiDevops; + private AstraDevopsClient apiDevops; /** Hold a reference for the Api Devops. */ - private AstraDBOpsClient apiDevopsDatabases; + private AstraDBDevopsClient apiDevopsDatabases; /** Hold a reference for the Api Devops. */ private AstraStreamingClient apiDevopsStreaming; @@ -124,7 +124,7 @@ public AstraClient(AstraClientConfig config) { // Devops APIS // --------------------------------------------------- if (Utils.hasLength(config.getToken())) { - apiDevops = new AstraOpsClient(config.getToken(), config.getEnvironmnt()); + apiDevops = new AstraDevopsClient(config.getToken(), config.getEnvironmnt()); apiDevopsDatabases = apiDevops.db(); apiDevopsStreaming = apiDevops.streaming(); LOGGER.info("+ API Devops [" + AnsiUtils.green("ENABLED")+ "] on [" + config.getEnvironmnt() + "]"); @@ -146,8 +146,8 @@ public AstraClient(AstraClientConfig config) { this.currentDatabaseRegion = config.getDatabaseRegion(); // Set default region (not in the cql as SCB is there) - config.getStargateConfig().setLocalDatacenter(config.getDatabaseRegion()); - + config.getStargateConfig().withLocalDatacenter(config.getDatabaseRegion()); + // CqlSession should be initialized only if the flag is on. if (config.getStargateConfig().isEnabledCql()) { @@ -213,7 +213,7 @@ public AstraClient(AstraClientConfig config) { } config.getStargateConfig().withApiTokenProviderDC(dc.getRegion(), - new SimpleTokenProvider(config.getToken())); + new FixedTokenAuthenticationService(config.getToken())); }); @@ -222,7 +222,7 @@ public AstraClient(AstraClientConfig config) { LOGGER.info("+ Cross-region fallback is disabled."); // Authentication for the DB config.getStargateConfig().withApiTokenProviderDC(currentDatabaseRegion, - new SimpleTokenProvider(config.getToken())); + new FixedTokenAuthenticationService(config.getToken())); // Rest Api config.getStargateConfig().addServiceRest(currentDatabaseRegion, new ServiceHttp(currentDatabaseRegion+ "-rest", @@ -353,7 +353,7 @@ public StargateGrpcApiClient apiStargateGrpc() { * * @return ApiDevopsClient */ - public AstraOpsClient apiDevops() { + public AstraDevopsClient apiDevops() { if (apiDevops == null) { throw new IllegalStateException("Api Devops is not available " + "you need to provide a astra Token (AstraCS:...) at initialization."); @@ -366,7 +366,7 @@ public AstraOpsClient apiDevops() { * * @return ApiDevopsClient */ - public AstraDBOpsClient apiDevopsDatabases() { + public AstraDBDevopsClient apiDevopsDatabases() { if (apiDevopsDatabases == null) { throw new IllegalStateException("Api Devops is not available " + "you need to provide clientId/clientName/clientSecret at initialization."); @@ -458,8 +458,8 @@ public void close() { * @return * astra DbAdmin */ - public AstraDBAdmin getAstraDBAdmin() { - return new AstraDBAdmin(getToken().orElseThrow(() -> new IllegalStateException("No token provided."))); + public AstraDBClient getAstraDBAdmin() { + return new AstraDBClient(getToken().orElseThrow(() -> new IllegalStateException("No token provided."))); } /** @@ -468,7 +468,7 @@ public AstraDBAdmin getAstraDBAdmin() { * @return * astraDB instance */ - public AstraDB getAstraDB() { + public AstraDBDatabase getAstraDB() { if (null == astraClientConfig.getDatabaseId()) { throw new IllegalStateException("No databaseId provided."); } diff --git a/astra-sdk/src/main/java/com/datastax/astra/sdk/config/AstraClientConfig.java b/astra-sdk/src/main/java/com/datastax/astra/sdk/config/AstraClientConfig.java index 48a29e13..06f70a22 100644 --- a/astra-sdk/src/main/java/com/datastax/astra/sdk/config/AstraClientConfig.java +++ b/astra-sdk/src/main/java/com/datastax/astra/sdk/config/AstraClientConfig.java @@ -5,14 +5,13 @@ import com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder; import com.datastax.oss.driver.api.core.config.TypedDriverOption; import com.datastax.oss.driver.api.core.tracker.RequestTracker; -import com.dtsx.astra.sdk.utils.ApiLocator; -import com.dtsx.astra.sdk.utils.AstraEnvironment; +import com.datastax.astra.devops.utils.AstraEnvironment; import io.stargate.sdk.audit.ServiceCallObserver; import io.stargate.sdk.StargateClientBuilder; import io.stargate.sdk.utils.AnsiUtils; import com.evanlennick.retry4j.config.RetryConfig; import org.apache.hc.client5.http.config.RequestConfig; -import com.dtsx.astra.sdk.utils.AstraRc; +import com.datastax.astra.devops.utils.AstraRc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -242,61 +241,7 @@ public String getDatabaseRegion() { public StargateClientBuilder getStargateConfig() { return stargateConfig; } - - // ------------------------------------------------ - // ------------- HTTP Client ---------------------- - // ------------------------------------------------ - - /** - * Enable fine Grained configuration of the HTTP Client. - * - * @param reqConfig - * request configuration - * @return self reference - */ - public AstraClientConfig withHttpRequestConfig(RequestConfig reqConfig) { - stargateConfig.withHttpRequestConfig(reqConfig); - return this; - } - - /** - * Enable fine Grained configuration of the HTTP Retries. - * - * @param retryConfig - * retry configuration - * @return self reference - */ - public AstraClientConfig withHttpRetryConfig(RetryConfig retryConfig) { - stargateConfig.withHttpRetryConfig(retryConfig); - return this; - } - - /** - * Api Invocations trigger some events processed in observer. - * - * @param name - * unique identifier - * @param observer - * instance of your Observer - * @return self reference - */ - public AstraClientConfig addHttpObserver(String name, ServiceCallObserver observer) { - stargateConfig.addHttpObserver(name, observer); - return this; - } - - /** - * Api Invocations trigger some events processed in observer. - * - * @param observers - * observers lists - * @return self reference - */ - public AstraClientConfig withHttpObservers(Map observers) { - stargateConfig.withHttpObservers(observers); - return this; - } - + // ------------------------------------------------ // ----------------- Grpc ------------------------- // ------------------------------------------------ diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/AstraRcTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/AstraRcTest.java index 8cc3657e..d965f736 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/AstraRcTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/AstraRcTest.java @@ -16,8 +16,7 @@ package com.datastax.astra.sdk; -import com.dtsx.astra.sdk.utils.AstraEnvironment; -import com.dtsx.astra.sdk.utils.AstraRc; +import com.datastax.astra.devops.utils.AstraRc; import org.junit.jupiter.api.Assertions; import java.io.File; diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentCollectionsAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentCollectionsAstraTest.java index c56d334d..80beeea1 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentCollectionsAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentCollectionsAstraTest.java @@ -4,12 +4,9 @@ import com.datastax.astra.sdk.AstraSdkTest; import io.stargate.sdk.test.doc.AbstractDocClientCollectionsTest; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; /** * Execute some unit tests against collections. diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentDocumentAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentDocumentAstraTest.java index 2fefd855..4a7ed22e 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentDocumentAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentDocumentAstraTest.java @@ -5,8 +5,8 @@ import io.stargate.sdk.test.doc.AbstractDocClientDocumentsTest; import org.junit.jupiter.api.BeforeAll; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; /** * Execute some unit tests against collections. diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentNamespacesAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentNamespacesAstraTest.java index 3241f781..04234562 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentNamespacesAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentNamespacesAstraTest.java @@ -13,8 +13,8 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentRepositoryAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentRepositoryAstraTest.java index 2edb9f2f..c6aa01e2 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentRepositoryAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiDocumentRepositoryAstraTest.java @@ -10,8 +10,8 @@ import io.stargate.sdk.test.doc.domain.Person; import org.junit.jupiter.api.BeforeAll; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; /** * Execute some unit tests against collections. diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGraphQLAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGraphQLAstraTest.java index 6e2bf9c5..4636d3b7 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGraphQLAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGraphQLAstraTest.java @@ -6,8 +6,8 @@ import io.stargate.sdk.test.gql.AbstractGraphClientTest; import org.junit.jupiter.api.BeforeAll; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; public class ApiGraphQLAstraTest extends AbstractGraphClientTest implements AstraSdkTest { diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGrpcAstraTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGrpcAstraTest.java index c371e969..b8c7f4c3 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGrpcAstraTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/ApiGrpcAstraTest.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; /** * Test gRPC service against Astra. diff --git a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/AstraStargateInitializationTest.java b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/AstraStargateInitializationTest.java index d2d09e23..6f737ab0 100644 --- a/astra-sdk/src/test/java/com/datastax/astra/sdk/db/AstraStargateInitializationTest.java +++ b/astra-sdk/src/test/java/com/datastax/astra/sdk/db/AstraStargateInitializationTest.java @@ -28,8 +28,8 @@ import java.util.stream.Collectors; -import static com.dtsx.astra.sdk.utils.TestUtils.TEST_REGION; -import static com.dtsx.astra.sdk.utils.TestUtils.setupDatabase; +import static com.datastax.astra.devops.utils.TestUtils.TEST_REGION; +import static com.datastax.astra.devops.utils.TestUtils.setupDatabase; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/pom.xml b/pom.xml index 98d79a28..88122023 100644 --- a/pom.xml +++ b/pom.xml @@ -37,9 +37,10 @@ 5.3 2.11.1 1.18.30 + 3.25.3 - 2.3.7 + 2.3.8-SNAPSHOT 2.1.0-BETA-9 1.62.2 @@ -160,6 +161,11 @@ stargate-sdk-data ${stargate-sdk.version} + + com.datastax.stargate + stargate-sdk-java + ${stargate-sdk.version} + com.datastax.stargate stargate-sdk-test @@ -223,7 +229,11 @@ org.junit.jupiter junit-jupiter-engine ${junit-jupiter.version} - test + + + org.assertj + assertj-core + ${assertj.version} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy