├── .github ├── actions │ └── checkout-and-build │ │ └── action.yml ├── dependabot.yml └── workflows │ ├── ci-astra-col-db-dbadmin.yaml │ ├── ci-astra-dev-collection.yml │ ├── ci-astra-dev-database.yml │ ├── ci-astra-dev-databaseadmin.yml │ ├── ci-astra-dev-devops.yml │ ├── ci-astra-dev-new.yml │ ├── ci-astra-dev-vectorize-aws-bedrock.yml │ ├── ci-astra-dev-vectorize-hf-dedicated.yml │ ├── ci-astra-dev.yml │ ├── ci-astra-devops.yaml │ ├── ci-astra-prod-devops.yml │ └── ci-astra-vectorize-bedrock-hf.yaml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.MD ├── RELEASE.MD ├── TEST.MD ├── astra-db-java-tools ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── datastax │ │ │ └── astra │ │ │ └── tool │ │ │ └── loader │ │ │ ├── csv │ │ │ ├── CsvLoader.java │ │ │ ├── CsvLoaderSettings.java │ │ │ └── CsvRowMapper.java │ │ │ ├── json │ │ │ ├── JsonDocumentLoader.java │ │ │ ├── JsonLoaderSettings.java │ │ │ └── JsonRecordMapper.java │ │ │ ├── pdf │ │ │ └── PdfLoader.java │ │ │ └── rag │ │ │ ├── RagGenericTest.java │ │ │ ├── RagRepository.java │ │ │ ├── ingestion │ │ │ ├── RagEmbeddingsModels.java │ │ │ ├── RagIngestionConfig.java │ │ │ └── RagIngestionJob.java │ │ │ ├── sources │ │ │ ├── RagJobStatus.java │ │ │ ├── RagSource.java │ │ │ ├── RagSourceCreationRequest.java │ │ │ ├── RagSourceStatus.java │ │ │ └── RagSources.java │ │ │ └── stores │ │ │ └── RagStore.java │ └── resources │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── datastax │ │ └── astra │ │ └── samples │ │ ├── CsvCustomerSupport.java │ │ ├── CsvLoaderAnoop.java │ │ ├── CsvLoaderListing.java │ │ ├── CsvPhilosophers.java │ │ └── JsonLoaderMtgSets.java │ └── resources │ ├── customer_support_tickets.csv │ ├── demo-set-list.json │ └── philosopher-quotes.csv ├── astra-db-java ├── pom.xml └── src │ ├── license │ ├── apache2 │ │ ├── header.txt │ │ └── license.txt │ └── licenses.properties │ ├── main │ └── java │ │ ├── com │ │ └── datastax │ │ │ └── astra │ │ │ ├── client │ │ │ ├── DataAPIClient.java │ │ │ ├── DataAPIClients.java │ │ │ ├── DataAPIDestination.java │ │ │ ├── admin │ │ │ │ ├── AdminOptions.java │ │ │ │ ├── AstraDBAdmin.java │ │ │ │ ├── AstraDBDatabaseAdmin.java │ │ │ │ ├── DataAPIDatabaseAdmin.java │ │ │ │ ├── DatabaseAdmin.java │ │ │ │ └── package-info.java │ │ │ ├── collections │ │ │ │ ├── Collection.java │ │ │ │ ├── CollectionOptions.java │ │ │ │ ├── commands │ │ │ │ │ ├── ReturnDocument.java │ │ │ │ │ ├── Update.java │ │ │ │ │ ├── Updates.java │ │ │ │ │ ├── cursor │ │ │ │ │ │ ├── CollectionFindAndRerankCursor.java │ │ │ │ │ │ ├── CollectionFindCursor.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── options │ │ │ │ │ │ ├── CollectionDeleteManyOptions.java │ │ │ │ │ │ ├── CollectionDeleteOneOptions.java │ │ │ │ │ │ ├── CollectionFindAndRerankOptions.java │ │ │ │ │ │ ├── CollectionFindOneAndDeleteOptions.java │ │ │ │ │ │ ├── CollectionFindOneAndReplaceOptions.java │ │ │ │ │ │ ├── CollectionFindOneAndUpdateOptions.java │ │ │ │ │ │ ├── CollectionFindOneOptions.java │ │ │ │ │ │ ├── CollectionFindOptions.java │ │ │ │ │ │ ├── CollectionInsertManyOptions.java │ │ │ │ │ │ ├── CollectionInsertOneOptions.java │ │ │ │ │ │ ├── CollectionReplaceOneOptions.java │ │ │ │ │ │ ├── CollectionUpdateManyOptions.java │ │ │ │ │ │ ├── CollectionUpdateOneOptions.java │ │ │ │ │ │ ├── CountDocumentsOptions.java │ │ │ │ │ │ ├── CreateCollectionOptions.java │ │ │ │ │ │ ├── DropCollectionOptions.java │ │ │ │ │ │ ├── EstimatedCountDocumentsOptions.java │ │ │ │ │ │ ├── ListCollectionOptions.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── results │ │ │ │ │ │ ├── CollectionDeleteResult.java │ │ │ │ │ │ ├── CollectionInsertManyResult.java │ │ │ │ │ │ ├── CollectionInsertOneResult.java │ │ │ │ │ │ ├── CollectionUpdateResult.java │ │ │ │ │ │ ├── FindOneAndReplaceResult.java │ │ │ │ │ │ └── package-info.java │ │ │ │ ├── definition │ │ │ │ │ ├── CollectionDefaultIdTypes.java │ │ │ │ │ ├── CollectionDefinition.java │ │ │ │ │ ├── CollectionDescriptor.java │ │ │ │ │ ├── documents │ │ │ │ │ │ ├── Document.java │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ └── types │ │ │ │ │ │ │ ├── ObjectId.java │ │ │ │ │ │ │ ├── UUIDv6.java │ │ │ │ │ │ │ ├── UUIDv7.java │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── exceptions │ │ │ │ │ ├── TooManyDocumentsToCountException.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── core │ │ │ │ ├── DataAPIKeywords.java │ │ │ │ ├── auth │ │ │ │ │ ├── StaticTokenProvider.java │ │ │ │ │ ├── TokenProvider.java │ │ │ │ │ ├── UsernamePasswordTokenProvider.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── commands │ │ │ │ │ ├── Command.java │ │ │ │ │ ├── CommandRunner.java │ │ │ │ │ ├── CommandType.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── headers │ │ │ │ │ ├── AWSEmbeddingHeadersProvider.java │ │ │ │ │ ├── EmbeddingAPIKeyHeaderProvider.java │ │ │ │ │ ├── EmbeddingHeadersProvider.java │ │ │ │ │ ├── HeadersProvider.java │ │ │ │ │ ├── RerankingAPIKeyHeaderProvider.java │ │ │ │ │ └── RerankingHeadersProvider.java │ │ │ │ ├── http │ │ │ │ │ ├── Caller.java │ │ │ │ │ ├── HttpClientOptions.java │ │ │ │ │ ├── HttpProxy.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── hybrid │ │ │ │ │ ├── Hybrid.java │ │ │ │ │ └── HybridLimits.java │ │ │ │ ├── lexical │ │ │ │ │ ├── Analyzer.java │ │ │ │ │ ├── AnalyzerTypes.java │ │ │ │ │ ├── Lexical.java │ │ │ │ │ ├── LexicalFilters.java │ │ │ │ │ └── LexicalOptions.java │ │ │ │ ├── options │ │ │ │ │ ├── BaseOptions.java │ │ │ │ │ ├── DataAPIClientOptions.java │ │ │ │ │ ├── SerdesOptions.java │ │ │ │ │ ├── TimeoutOptions.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ ├── paging │ │ │ │ │ ├── CursorState.java │ │ │ │ │ ├── Page.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── query │ │ │ │ │ ├── Filter.java │ │ │ │ │ ├── FilterBuilder.java │ │ │ │ │ ├── FilterOperator.java │ │ │ │ │ ├── Filters.java │ │ │ │ │ ├── Projection.java │ │ │ │ │ ├── Sort.java │ │ │ │ │ ├── SortOrder.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── rerank │ │ │ │ │ ├── CollectionRerankOptions.java │ │ │ │ │ ├── RerankProvider.java │ │ │ │ │ ├── RerankProviderTypes.java │ │ │ │ │ ├── RerankServiceOptions.java │ │ │ │ │ └── RerankedResult.java │ │ │ │ ├── vector │ │ │ │ │ ├── DataAPIVector.java │ │ │ │ │ ├── SimilarityMetric.java │ │ │ │ │ ├── VectorOptions.java │ │ │ │ │ └── package-info.java │ │ │ │ └── vectorize │ │ │ │ │ ├── EmbeddingProvider.java │ │ │ │ │ ├── VectorServiceOptions.java │ │ │ │ │ ├── Vectorize.java │ │ │ │ │ └── package-info.java │ │ │ ├── databases │ │ │ │ ├── Database.java │ │ │ │ ├── DatabaseOptions.java │ │ │ │ ├── commands │ │ │ │ │ ├── options │ │ │ │ │ │ ├── CreateKeyspaceOptions.java │ │ │ │ │ │ └── DropKeyspaceOptions.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── results │ │ │ │ │ │ ├── FindEmbeddingProvidersResult.java │ │ │ │ │ │ ├── FindRerankingProvidersResult.java │ │ │ │ │ │ └── package-info.java │ │ │ │ ├── definition │ │ │ │ │ ├── DatabaseInfo.java │ │ │ │ │ ├── keyspaces │ │ │ │ │ │ ├── KeyspaceDefinition.java │ │ │ │ │ │ ├── KeyspaceInformation.java │ │ │ │ │ │ ├── KeyspaceOptions.java │ │ │ │ │ │ ├── KeyspaceReplicationStrategy.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── exceptions │ │ │ │ ├── CursorException.java │ │ │ │ ├── DataAPIClientException.java │ │ │ │ ├── DataAPIErrorDescriptor.java │ │ │ │ ├── DataAPIException.java │ │ │ │ ├── DataAPIHttpException.java │ │ │ │ ├── DataAPIResponseException.java │ │ │ │ ├── DataAPITimeoutException.java │ │ │ │ ├── ErrorCodesClient.java │ │ │ │ ├── ErrorCodesServer.java │ │ │ │ ├── InvalidConfigurationException.java │ │ │ │ ├── InvalidEnvironmentException.java │ │ │ │ ├── InvalidFieldExpressionException.java │ │ │ │ ├── UnexpectedDataAPIResponseException.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── tables │ │ │ │ ├── Table.java │ │ │ │ ├── TableOptions.java │ │ │ │ ├── commands │ │ │ │ ├── AlterTableAddColumns.java │ │ │ │ ├── AlterTableAddReranking.java │ │ │ │ ├── AlterTableAddVectorize.java │ │ │ │ ├── AlterTableDropColumns.java │ │ │ │ ├── AlterTableDropVectorize.java │ │ │ │ ├── AlterTableOperation.java │ │ │ │ ├── AlterTableRenameColumns.java │ │ │ │ ├── TableUpdateOperation.java │ │ │ │ ├── options │ │ │ │ │ ├── AlterTableOptions.java │ │ │ │ │ ├── CountRowsOptions.java │ │ │ │ │ ├── CreateIndexOptions.java │ │ │ │ │ ├── CreateTableOptions.java │ │ │ │ │ ├── CreateTextIndexOptions.java │ │ │ │ │ ├── CreateVectorIndexOptions.java │ │ │ │ │ ├── DropTableIndexOptions.java │ │ │ │ │ ├── DropTableOptions.java │ │ │ │ │ ├── EstimatedCountRowsOptions.java │ │ │ │ │ ├── ListIndexesOptions.java │ │ │ │ │ ├── ListTablesOptions.java │ │ │ │ │ ├── TableDeleteManyOptions.java │ │ │ │ │ ├── TableDeleteOneOptions.java │ │ │ │ │ ├── TableDistinctOptions.java │ │ │ │ │ ├── TableFindOneOptions.java │ │ │ │ │ ├── TableFindOptions.java │ │ │ │ │ ├── TableInsertManyOptions.java │ │ │ │ │ ├── TableInsertOneOptions.java │ │ │ │ │ ├── TableUpdateOneOptions.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── results │ │ │ │ │ ├── TableInsertManyResult.java │ │ │ │ │ ├── TableInsertOneResult.java │ │ │ │ │ ├── TableUpdateResult.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── cursor │ │ │ │ ├── TableFindCursor.java │ │ │ │ └── package-info.java │ │ │ │ ├── definition │ │ │ │ ├── TableDefinition.java │ │ │ │ ├── TableDescriptor.java │ │ │ │ ├── TableDuration.java │ │ │ │ ├── TablePrimaryKey.java │ │ │ │ ├── columns │ │ │ │ │ ├── ColumnDefinition.java │ │ │ │ │ ├── ColumnDefinitionApiSupport.java │ │ │ │ │ ├── ColumnDefinitionList.java │ │ │ │ │ ├── ColumnDefinitionMap.java │ │ │ │ │ ├── ColumnDefinitionSet.java │ │ │ │ │ ├── ColumnDefinitionVector.java │ │ │ │ │ ├── ColumnTypeMapper.java │ │ │ │ │ ├── ColumnTypes.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── indexes │ │ │ │ │ ├── TableIndexColumnDefinition.java │ │ │ │ │ ├── TableIndexDefinition.java │ │ │ │ │ ├── TableIndexDefinitionApiSupport.java │ │ │ │ │ ├── TableIndexDefinitionOptions.java │ │ │ │ │ ├── TableIndexDescriptor.java │ │ │ │ │ ├── TableIndexMapTypes.java │ │ │ │ │ ├── TableRegularIndexDefinition.java │ │ │ │ │ ├── TableRegularIndexDescriptor.java │ │ │ │ │ ├── TableTextIndexDefinition.java │ │ │ │ │ ├── TableTextIndexDefinitionOptions.java │ │ │ │ │ ├── TableTextIndexDescriptor.java │ │ │ │ │ ├── TableVectorIndexDefinition.java │ │ │ │ │ ├── TableVectorIndexDefinitionOptions.java │ │ │ │ │ ├── TableVectorIndexDescriptor.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── rows │ │ │ │ │ ├── Row.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── exceptions │ │ │ │ ├── TooManyRowsToCountException.java │ │ │ │ └── package-info.java │ │ │ │ ├── mapping │ │ │ │ ├── Column.java │ │ │ │ ├── ColumnVector.java │ │ │ │ ├── EntityTable.java │ │ │ │ ├── KeyValue.java │ │ │ │ ├── PartitionBy.java │ │ │ │ ├── PartitionSort.java │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ └── internal │ │ │ ├── api │ │ │ ├── ApiResponseHttp.java │ │ │ ├── AstraApiEndpoint.java │ │ │ ├── DataAPIData.java │ │ │ ├── DataAPIResponse.java │ │ │ ├── DataAPIStatus.java │ │ │ └── package-info.java │ │ │ ├── command │ │ │ ├── AbstractCommandRunner.java │ │ │ ├── AbstractCursor.java │ │ │ ├── CommandObserver.java │ │ │ ├── CursorError.java │ │ │ ├── ExecutionInfos.java │ │ │ ├── LoggingCommandObserver.java │ │ │ └── package-info.java │ │ │ ├── http │ │ │ ├── RetryHttpClient.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── reflection │ │ │ ├── EntityBeanDefinition.java │ │ │ ├── EntityFieldDefinition.java │ │ │ └── package-info.java │ │ │ ├── serdes │ │ │ ├── DataAPISerializer.java │ │ │ ├── DatabaseSerializer.java │ │ │ ├── collections │ │ │ │ ├── CollectionDefaultIdTypeDeserializer.java │ │ │ │ ├── CollectionDefaultIdTypeSerializer.java │ │ │ │ ├── DocumentSerializer.java │ │ │ │ ├── EJsonCalendarDeserializer.java │ │ │ │ ├── EJsonCalendarSerializer.java │ │ │ │ ├── EJsonDateDeserializer.java │ │ │ │ ├── EJsonDateSerializer.java │ │ │ │ ├── EJsonInstantDeserializer.java │ │ │ │ ├── EJsonInstantSerializer.java │ │ │ │ ├── HybridLimitsSerializer.java │ │ │ │ ├── ObjectIdDeserializer.java │ │ │ │ ├── ObjectIdSerializer.java │ │ │ │ ├── UUID6Serializer.java │ │ │ │ ├── UUID7Serializer.java │ │ │ │ ├── UUIDDeserializer.java │ │ │ │ ├── UUIDSerializer.java │ │ │ │ └── package-info.java │ │ │ ├── core │ │ │ │ ├── AnalyzerSerializer.java │ │ │ │ ├── HybridSerializer.java │ │ │ │ ├── LexicalSerializer.java │ │ │ │ └── VectorizeSerializer.java │ │ │ ├── package-info.java │ │ │ ├── shared │ │ │ │ ├── DataAPIVectorDeserializer.java │ │ │ │ ├── DataAPIVectorSerializer.java │ │ │ │ ├── SimilarityMetricDeserializer.java │ │ │ │ ├── SimilarityMetricSerializer.java │ │ │ │ └── package-info.java │ │ │ └── tables │ │ │ │ ├── ByteArrayDeserializer.java │ │ │ │ ├── ByteArraySerializer.java │ │ │ │ ├── ColumnTypeDeserializer.java │ │ │ │ ├── ColumnTypeSerializer.java │ │ │ │ ├── DoubleDeserializer.java │ │ │ │ ├── DoubleSerializer.java │ │ │ │ ├── DurationDeserializer.java │ │ │ │ ├── DurationSerializer.java │ │ │ │ ├── FloatDeserializer.java │ │ │ │ ├── FloatSerializer.java │ │ │ │ ├── RowMapper.java │ │ │ │ ├── RowSerializer.java │ │ │ │ ├── TableDurationDeserializer.java │ │ │ │ ├── TableDurationSerializer.java │ │ │ │ ├── TableIndexColumnDefinitionDeserializer.java │ │ │ │ ├── TableIndexColumnDefinitionSerializer.java │ │ │ │ └── package-info.java │ │ │ └── utils │ │ │ ├── AnsiUtils.java │ │ │ ├── Assert.java │ │ │ ├── BetaPreview.java │ │ │ ├── CompletableFutures.java │ │ │ ├── EscapeUtils.java │ │ │ ├── OptionsUtils.java │ │ │ └── package-info.java │ │ └── overview.html │ └── test │ ├── java │ └── com │ │ └── datastax │ │ └── astra │ │ └── test │ │ ├── integration │ │ ├── AbstractAstraDBAdminTest.java │ │ ├── AbstractCollectionITTest.java │ │ ├── AbstractDataAPITest.java │ │ ├── AbstractDatabaseAdminITTest.java │ │ ├── AbstractDatabaseTest.java │ │ ├── AbstractTableITTest.java │ │ ├── AbstractVectorizeApiHeaderITTest.java │ │ ├── AbstractVectorizeITTest.java │ │ ├── astra │ │ │ ├── Astra_01_AstraDBAdminITTest.java │ │ │ ├── Astra_02_DatabaseAdminITTest.java │ │ │ ├── Astra_03_DatabaseITTest.java │ │ │ ├── Astra_04_CollectionITTest.java │ │ │ ├── Astra_05_TableITTest.java │ │ │ ├── Astra_06_VectorizeITTest.java │ │ │ ├── Astra_07_VectorizeAwsBedRockITTest.java │ │ │ ├── Astra_08_VectorizeEmbeddingApiKeyITTest.java │ │ │ ├── Astra_09_VectorizeHuggingFaceDedicatedITTest.java │ │ │ └── DemoAstraDevFindAndRerank.java │ │ └── local │ │ │ ├── Local_01_DatabaseAdminITTest.java │ │ │ ├── Local_02_Database_ITTest.java │ │ │ ├── Local_10_Collection_ITTest.java │ │ │ ├── Local_11_Collection_Extended_ITTest.java │ │ │ ├── Local_12_Collection_FindAndRerank_ITTest.java │ │ │ ├── Local_13_Collection_Vectorize_AwsBedrock_ITTest.java │ │ │ ├── Local_13_Collection_Vectorize_HuggingFaceITest.java │ │ │ ├── Local_13_Collection_Vectorize_HuggingFace_Dedicated_ITest.java │ │ │ ├── Local_13_Collection_Vectorize_JinaAITest.java │ │ │ ├── Local_13_Collection_Vectorize_MistralAITest.java │ │ │ ├── Local_13_Collection_Vectorize_NVidiaTest.java │ │ │ ├── Local_13_Collection_Vectorize_OpenAIITest.java │ │ │ ├── Local_13_Collection_Vectorize_UpstageAITest.java │ │ │ ├── Local_13_Collection_Vectorize_VoyageAITest.java │ │ │ ├── Local_20_TableITTest.java │ │ │ └── Local_21_TableCollectionIndexTest.java │ │ ├── model │ │ ├── Product.java │ │ ├── ProductObjectUUID.java │ │ ├── ProductString.java │ │ ├── ProjectObjectId.java │ │ ├── TableCompositeAnnotatedRow.java │ │ ├── TableCompositeRow.java │ │ ├── TableCompositeRowGenerator.java │ │ ├── TableEntityGame.java │ │ ├── TableEntityGameWithAnnotation.java │ │ ├── TableEntityGameWithAnnotationAllHints.java │ │ ├── TableSimpleAnnotatedRow.java │ │ ├── TableSimpleRow.java │ │ └── TestDataset.java │ │ └── unit │ │ ├── AstraApiEndpointTest.java │ │ ├── DataAPIExceptionsTest.java │ │ ├── DataApiOptionsTest.java │ │ ├── DataApiVectorSerializationTest.java │ │ ├── DocumentSerializationTest.java │ │ ├── FiltersTest.java │ │ ├── FindAndRerankSerializationTest.java │ │ ├── MockCommandObserver.java │ │ ├── QuickStartTablesLocal.java │ │ ├── TableDefinitionSerializationTest.java │ │ ├── TokenProviderTest.java │ │ └── WorkWithOptions.java │ └── resources │ ├── create-tables.cql │ ├── logback-test.xml │ └── philosopher-quotes.csv ├── astra-sdk-devops ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── dtsx │ │ └── astra │ │ └── sdk │ │ ├── AbstractApiClient.java │ │ ├── AstraOpsClient.java │ │ ├── db │ │ ├── AstraDBOpsClient.java │ │ ├── DbAccessListsClient.java │ │ ├── DbCdcsClient.java │ │ ├── DbDatacentersClient.java │ │ ├── DbKeyspacesClient.java │ │ ├── DbOpsClient.java │ │ ├── DbPrivateLinksClient.java │ │ ├── DbRegionsClient.java │ │ ├── DbTelemetryClient.java │ │ ├── domain │ │ │ ├── AccessList.java │ │ │ ├── AccessListAddress.java │ │ │ ├── AccessListAddressRequest.java │ │ │ ├── AccessListRequest.java │ │ │ ├── CloudProviderType.java │ │ │ ├── Database.java │ │ │ ├── DatabaseCost.java │ │ │ ├── DatabaseCreationBuilder.java │ │ │ ├── DatabaseCreationRequest.java │ │ │ ├── DatabaseCreationType.java │ │ │ ├── DatabaseFilter.java │ │ │ ├── DatabaseInfo.java │ │ │ ├── DatabaseMetrics.java │ │ │ ├── DatabaseRegion.java │ │ │ ├── DatabaseRegionCreationRequest.java │ │ │ ├── DatabaseRegionServerless.java │ │ │ ├── DatabaseStatusType.java │ │ │ ├── DatabaseStorage.java │ │ │ ├── Datacenter.java │ │ │ ├── RegionType.java │ │ │ ├── package-info.java │ │ │ └── telemetry │ │ │ │ ├── CloudWatchTelemetryRequest.java │ │ │ │ ├── DatadogTelemetryRequest.java │ │ │ │ ├── KafkaTelemetryRequest.java │ │ │ │ ├── PrometheusTelemetryRequest.java │ │ │ │ ├── SpecializedTelemetryClient.java │ │ │ │ ├── SplunkTelemetryRequest.java │ │ │ │ └── package-info.java │ │ ├── exception │ │ │ ├── ChangeDataCaptureNotFoundException.java │ │ │ ├── DatabaseNotFoundException.java │ │ │ ├── KeyspaceAlreadyExistException.java │ │ │ ├── KeyspaceNotFoundException.java │ │ │ ├── RegionAlreadyExistException.java │ │ │ ├── RegionNotFoundException.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── exception │ │ ├── AuthenticationException.java │ │ └── package-info.java │ │ ├── org │ │ ├── KeysClient.java │ │ ├── RolesClient.java │ │ ├── TokensClient.java │ │ ├── UsersClient.java │ │ ├── domain │ │ │ ├── CreateRoleResponse.java │ │ │ ├── CreateTokenResponse.java │ │ │ ├── DefaultRoles.java │ │ │ ├── IamToken.java │ │ │ ├── InviteUserRequest.java │ │ │ ├── Key.java │ │ │ ├── KeyDefinition.java │ │ │ ├── KeyRegionDefinition.java │ │ │ ├── Organization.java │ │ │ ├── Permission.java │ │ │ ├── ResponseAllIamTokens.java │ │ │ ├── ResponseAllUsers.java │ │ │ ├── Role.java │ │ │ ├── RoleDefinition.java │ │ │ ├── RolePolicy.java │ │ │ ├── User.java │ │ │ ├── UserStatus.java │ │ │ └── package-info.java │ │ ├── exception │ │ │ ├── RoleNotFoundException.java │ │ │ ├── UserAlreadyExistException.java │ │ │ ├── UserNotFoundException.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── streaming │ │ ├── AstraStreamingClient.java │ │ ├── ClustersClient.java │ │ ├── ProvidersClient.java │ │ ├── RegionsClient.java │ │ ├── TenantCdcClient.java │ │ ├── TenantClient.java │ │ ├── TenantLimitsClient.java │ │ ├── TenantStatsClient.java │ │ ├── domain │ │ │ ├── CdcDefinition.java │ │ │ ├── Cluster.java │ │ │ ├── CreateCdc.java │ │ │ ├── CreateTenant.java │ │ │ ├── CreateTenantResponse.java │ │ │ ├── DeleteCdc.java │ │ │ ├── Statistics.java │ │ │ ├── StreamingRegion.java │ │ │ ├── Tenant.java │ │ │ ├── TenantLimit.java │ │ │ └── package-info.java │ │ ├── exception │ │ │ ├── TenantAlreadyExistException.java │ │ │ ├── TenantNotFoundException.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ └── utils │ │ ├── ApiError.java │ │ ├── ApiLocator.java │ │ ├── ApiResponse.java │ │ ├── ApiResponseError.java │ │ ├── ApiResponseHttp.java │ │ ├── Assert.java │ │ ├── AstraEnvironment.java │ │ ├── AstraRc.java │ │ ├── HttpClientWrapper.java │ │ ├── IdUtils.java │ │ ├── JsonUtils.java │ │ ├── TestUtils.java │ │ ├── Utils.java │ │ ├── observability │ │ ├── AnsiUtils.java │ │ ├── ApiExecutionInfos.java │ │ ├── ApiRequestObserver.java │ │ ├── CompletableFutures.java │ │ └── LoggingRequestObserver.java │ │ └── package-info.java │ └── test │ ├── java │ └── com │ │ └── dtsx │ │ └── astra │ │ └── sdk │ │ ├── AbstractDevopsApiTest.java │ │ ├── ApiDevopsClientTest.java │ │ ├── db │ │ ├── CdcClientTest.java │ │ ├── DatabaseClientTest.java │ │ ├── DatabasesClientTest.java │ │ └── NonProductionEnvironmentTest.java │ │ ├── iam │ │ ├── RolesClientTest.java │ │ ├── TokensClientTest.java │ │ └── UsersClientTest.java │ │ └── streaming │ │ ├── AstraStreamingClientTest.java │ │ ├── ClustersClientTest.java │ │ ├── ProvidersClientTest.java │ │ ├── RegionClientTest.java │ │ ├── TenantClientTest.java │ │ └── TenantStatsClientTest.java │ └── resources │ └── logback-test.xml ├── cassandra-hcd.yaml ├── docker-compose-hcd.yml ├── docker-compose.yml ├── dse.yaml ├── examples ├── pom.xml └── src │ └── main │ ├── java │ ├── QuickStartHCD.java │ ├── QuickStartLocal.java │ ├── QuickStartTraining.java │ ├── Quickstart.java │ └── com │ │ └── datastax │ │ └── astra │ │ ├── Book.java │ │ ├── client │ │ ├── Connecting.java │ │ ├── ConnectingAdmin.java │ │ ├── DataAPIVectorDemo.java │ │ ├── DataApiClientDemo.java │ │ ├── GettingStarted.java │ │ ├── admin │ │ │ ├── CreateDatabase.java │ │ │ ├── DropDatabase.java │ │ │ ├── GetDatabaseInformation.java │ │ │ └── ListDatabases.java │ │ ├── collections │ │ │ ├── ClearCollection.java │ │ │ ├── CountDocuments.java │ │ │ ├── DeleteAll.java │ │ │ ├── DeleteMany.java │ │ │ ├── DeleteOne.java │ │ │ ├── Distinct.java │ │ │ ├── EstimateCountDocuments.java │ │ │ ├── Find.java │ │ │ ├── FindOne.java │ │ │ ├── FindOneAndDelete.java │ │ │ ├── FindOneAndReplace.java │ │ │ ├── FindOneAndUpdate.java │ │ │ ├── InsertMany.java │ │ │ ├── InsertOne.java │ │ │ ├── ReplaceOne.java │ │ │ ├── UpdateMany.java │ │ │ ├── UpdateOne.java │ │ │ ├── WorkingWithDates.java │ │ │ ├── WorkingWithDocumentIds.java │ │ │ ├── WorkingWithSorts.java │ │ │ ├── findrerank │ │ │ │ ├── FindRerankerProvidesr.java │ │ │ │ ├── InsertMany.java │ │ │ │ ├── SampleWithVectorize.java │ │ │ │ └── SampleWithoutVectorize.java │ │ │ └── vectorize │ │ │ │ ├── EmbeddingModelType.java │ │ │ │ ├── QuickStartOpenAI.java │ │ │ │ └── WorkingWithVectorize.java │ │ ├── database │ │ │ ├── AlterTableAddColumn.java │ │ │ ├── AlterTableAddVectorizes.java │ │ │ ├── AlterTableDropColumn.java │ │ │ ├── AlterTableDropVectorizes.java │ │ │ ├── CreateCollection.java │ │ │ ├── CreateCollection2.java │ │ │ ├── CreateTable.java │ │ │ ├── CreateTableOM.java │ │ │ ├── DropCollection.java │ │ │ ├── DropTable.java │ │ │ ├── DropTableIndex.java │ │ │ ├── FindCollection.java │ │ │ ├── GetTable.java │ │ │ ├── InitializeDatabase.java │ │ │ ├── ListCollections.java │ │ │ ├── ListTables.java │ │ │ └── ListTablesNames.java │ │ ├── database_admin │ │ │ ├── CreateKeyspace.java │ │ │ ├── DropKeyspace.java │ │ │ ├── FindEmbeddingProviders.java │ │ │ ├── GetDatabaseAdmin.java │ │ │ └── ListKeyspaces.java │ │ └── tables │ │ │ ├── CreateIndex.java │ │ │ ├── CreateVectorIndex.java │ │ │ ├── DeleteMany.java │ │ │ ├── DeleteOne.java │ │ │ ├── Distinct.java │ │ │ ├── DropIndex.java │ │ │ ├── FindMany.java │ │ │ ├── FindOne.java │ │ │ ├── FindWithVectorize.java │ │ │ ├── Game.java │ │ │ ├── GameWithAnnotation.java │ │ │ ├── GameWithAnnotationAllHints.java │ │ │ ├── InsertManyRows.java │ │ │ ├── InsertOneWithVectorize.java │ │ │ ├── InsertRow.java │ │ │ ├── ListIndexes.java │ │ │ ├── ListIndexesNames.java │ │ │ ├── UpdateOne.java │ │ │ ├── WorkingWithRows.java │ │ │ └── WorkingWithSorts.java │ │ ├── docs │ │ ├── UpdateOneExample.java │ │ └── UpdateOneExample2.java │ │ └── genai │ │ ├── QuickStartAzureOpenAI.java │ │ ├── QuickStartHuggingFaceDedicated.java │ │ ├── QuickStartNvidia.java │ │ └── QuickStartOpenAI.java │ └── resources │ ├── logback.xml │ └── quickstart_dataset.json ├── langchain4j-astradb ├── pom.xml └── src │ ├── license │ ├── apache2 │ │ ├── header.txt │ │ └── license.txt │ └── licenses.properties │ ├── main │ └── java │ │ └── com │ │ └── datastax │ │ └── astra │ │ └── langchain4j │ │ ├── rag │ │ ├── AstraVectorizeContentRetriever.java │ │ └── AstraVectorizeIngestor.java │ │ └── store │ │ ├── embedding │ │ ├── AstraDbEmbeddingStore.java │ │ ├── AstraDbFilterMapper.java │ │ ├── EmbeddingSearchRequestAstra.java │ │ └── package-info.java │ │ └── memory │ │ ├── AstraDbChatMemory.java │ │ ├── AstraDbChatMemoryStore.java │ │ ├── AstraDbChatMessage.java │ │ ├── AstraDbContent.java │ │ ├── package-info.java │ │ └── tables │ │ ├── AstraDBTableChatMessage.java │ │ └── AstraDbTableChatMemory.java │ └── test │ ├── java │ ├── com │ │ └── datastax │ │ │ └── astra │ │ │ └── langchain4j │ │ │ ├── Assistant.java │ │ │ └── AstraDBTestSupport.java │ └── dev │ │ └── langchain4j │ │ └── store │ │ ├── embedding │ │ └── astradb │ │ │ ├── AstraDbEmbeddingStoreIT.java │ │ │ ├── GettingStartedGuideTestIT.java │ │ │ └── GettingStartedGuideVectorizedTestIT.java │ │ └── memory │ │ └── chat │ │ └── astradb │ │ └── AstraDbChatMemoryIT.java │ └── resources │ ├── johnny.txt │ ├── logback-test.xml │ └── shadow.txt └── pom.xml /.github/actions/checkout-and-build/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Checkout & Build with Java' 2 | description: 'Checkout code, set up JDK, and build with Maven' 3 | inputs: 4 | java_distribution: 5 | description: 'JDK distribution to use' 6 | required: true 7 | default: 'adopt' 8 | java_version: 9 | description: 'JDK version to use' 10 | required: true 11 | default: '11.0' 12 | cache_pkg_mgr_name: 13 | description: 'Cache package manager to be used' 14 | required: true 15 | default: 'maven' 16 | skip_tests_on_build: 17 | description: 'Skip tests during Maven build' 18 | required: false 19 | default: 'true' 20 | runs: 21 | using: 'composite' 22 | steps: 23 | - name: Checkout Code 24 | uses: actions/checkout@v4 25 | 26 | - name: Set up JDK ${{ inputs.java_version }} 27 | uses: actions/setup-java@v4 28 | with: 29 | distribution: ${{ inputs.java_distribution }} 30 | java-version: ${{ inputs.java_version }} 31 | cache: ${{ inputs.cache_pkg_mgr_name}} 32 | 33 | - name: Build with Maven 34 | shell: bash 35 | run: | 36 | mvn install -Dmaven.test.skip=${{ inputs.skip_tests_on_build }} -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Set update schedule for GitHub Actions 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "monthly" 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | astra-sdk-java.wiki/ 2 | .env 3 | .astrarc 4 | sec 5 | 6 | # eclipse conf file 7 | .settings 8 | .classpath 9 | .project 10 | .cache 11 | 12 | # idea conf files 13 | .idea 14 | *.ipr 15 | *.iws 16 | *.iml 17 | 18 | # building 19 | target 20 | build 21 | tmp 22 | dist 23 | 24 | # misc 25 | .DS_Store 26 | 27 | .factorypath 28 | .sts4-cache 29 | *.log 30 | 31 | release.properties 32 | pom.xml.releaseBackup -------------------------------------------------------------------------------- /RELEASE.MD: -------------------------------------------------------------------------------- 1 | 2 | [![License Apache2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0) 3 | 4 | This page is mean to help developer to release this the SDK. 5 | 6 | ## CQLSH 7 | 8 | ```console 9 | # Get the latest compose with DSE 10 | curl -o docker-compose-dse.yml https://raw.githubusercontent.com/datastax/astra-db-java/refs/heads/main/docker-compose.yml 11 | # Start docker 12 | docker-compose -f ./docker-compose-dse.yml up -d 13 | ``` 14 | ``` 15 | docker run -it --rm --network container:$(docker ps | grep dse | cut -b 1-12) cassandra:latest cqlsh -u cassandra -p cassandra 16 | ``` 17 | 18 | ## Run the Test 19 | 20 | ### Prerequisites 21 | 22 | To run the tests you need 3 different environments: Dev, PROD and a local installation. For Astra DEV and production you should have the following environment variables sets: `ASTRA_DB_APPLICATION_TOKEN_DEV` and `ASTRA_DB_APPLICATION_TOKEN`. 23 | 24 | - Generate Jacoco Report 25 | ```json 26 | mvn clean test jacoco:report 27 | ``` 28 | 29 | - Push to SONAR 30 | ```json 31 | mvn clean test jacoco:report verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=clun_astra-db-java 32 | ``` 33 | 34 | - [x] Start the `ssh-agent` 35 | 36 | ```console 37 | eval "$(ssh-agent -s)" 38 | ``` 39 | - [x] Add the ssh key to the agent 40 | 41 | ```console 42 | cd ~/.ssh 43 | ssh-add githubff4j 44 | ``` 45 | 46 | - [x] Deploy 47 | 48 | ```console 49 | mvn versions:set -DnewVersion=2.0.0-PREVIEW3 -DgenerateBackupPoms=false 50 | git tag 2.0.1 && git push origin 2.0.1 51 | ``` 52 | 53 | 54 | -------------------------------------------------------------------------------- /TEST.MD: -------------------------------------------------------------------------------- 1 | 2 | ## Run against Local HCD Instance 3 | (_to run locally your must have the data api running locally on op of HCD or DSE_) 4 | 5 | ```bash 6 | mvn clean test -Ptest_local 7 | ``` 8 | 9 | > **Why it works ?** 10 | > 11 | > - In `pom.xml` the environment variable `ASTRA_DB_JAVA_TEST_ENV` is set to `local` 12 | > - Tests are annotated with 13 | > 14 | > ```java 15 | > @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 16 | > @DisabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "(?!local)") 17 | > public class MyTest { 18 | > } 19 | > ``` 20 | 21 | - To run with IDE make sure to set the environment variable `ASTRA_DB_JAVA_TEST_ENV` to `local` in your Run configuration 22 | 23 | 24 | ## Run against Astra DEV 25 | 26 | - `ASTRA_DB_APPLICATION_TOKEN_DEV` should be defined in your environment variables, it is not in the different POM for privacy reasons. 27 | 28 | - To run with Maven (AWS,`eu-west-2`) 29 | 30 | ```bash 31 | mvn clean test -Ptest_astra_dev 32 | ``` 33 | 34 | - To run with Maven on One particular region 35 | 36 | ```java 37 | mvn clean test -Ptest_astra_dev \ 38 | -DASTRA_CLOUD_PROVIDER_DEV=GCP \ 39 | -DASTRA_CLOUD_REGION_DEV=us-central-1 40 | ``` 41 | 42 | - To run overriding also the token 43 | 44 | ```java 45 | mvn clean test \ 46 | -Ptest_astra_dev \ 47 | -DASTRA_CLOUD_PROVIDER_DEV=GCP \ 48 | -DASTRA_CLOUD_REGION_DEV=us-central-1 \ 49 | -ASTRA_DB_APPLICATION_TOKEN_DEV=AstraCS:... \ 50 | -Dtest="com.datastax.astra.test.integration.*.*Test" 51 | ``` 52 | 53 | -------------------------------------------------------------------------------- /astra-db-java-tools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | astra-db-java-tools 5 | Data API Client Tools 6 | 7 | 8 | com.datastax.astra 9 | astra-db-java-parent 10 | 2.0.0 11 | 12 | 13 | 14 | 15 | com.datastax.astra 16 | astra-db-java 17 | ${project.version} 18 | 19 | 20 | ch.qos.logback 21 | logback-classic 22 | 23 | 24 | 25 | org.apache.commons 26 | commons-csv 27 | 1.14.0 28 | 29 | 30 | com.opencsv 31 | opencsv 32 | 5.10 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/csv/CsvLoaderSettings.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.csv; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public class CsvLoaderSettings { 7 | 8 | private static final int BATCH_SIZE = 20; 9 | 10 | private static final int THREAD_POOL_SIZE = 5; 11 | 12 | private static final int TIMEOUT = 1800; 13 | 14 | @Builder.Default 15 | int batchSize = BATCH_SIZE;; 16 | 17 | @Builder.Default 18 | int threadPoolSize = THREAD_POOL_SIZE;; 19 | 20 | @Builder.Default 21 | int timeoutSeconds = TIMEOUT; 22 | } 23 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/csv/CsvRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.csv; 2 | 3 | import com.datastax.astra.client.collections.definition.documents.Document; 4 | 5 | /** 6 | * Settings for the CSV Loader 7 | */ 8 | public interface CsvRowMapper { 9 | 10 | /** 11 | * Process the document 12 | * 13 | * @param doc 14 | * document to process 15 | */ 16 | Document map(Document doc); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/json/JsonLoaderSettings.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.json; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public class JsonLoaderSettings { 7 | 8 | private static final int BATCH_SIZE = 20; 9 | 10 | private static final int THREAD_POOL_SIZE = 5; 11 | 12 | private static final int TIMEOUT = 1800; 13 | 14 | @Builder.Default 15 | int batchSize = BATCH_SIZE;; 16 | 17 | @Builder.Default 18 | int threadPoolSize = THREAD_POOL_SIZE;; 19 | 20 | @Builder.Default 21 | int timeoutSeconds = TIMEOUT; 22 | } 23 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/json/JsonRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.json; 2 | 3 | import com.datastax.astra.client.collections.definition.documents.Document; 4 | 5 | /** 6 | * To import a Json containing an arrray of records. 7 | */ 8 | public interface JsonRecordMapper { 9 | 10 | Document map(Document jsonRecord); 11 | } 12 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/pdf/PdfLoader.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.pdf; 2 | 3 | public class PdfLoader { 4 | } 5 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/rag/RagGenericTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.rag; 2 | 3 | import com.datastax.astra.client.core.query.Projection; 4 | import com.datastax.astra.client.tables.Table; 5 | import com.datastax.astra.client.tables.commands.options.TableFindOptions; 6 | import com.datastax.astra.tool.loader.rag.sources.RagSource; 7 | 8 | import java.util.UUID; 9 | 10 | public class RagGenericTest { 11 | 12 | public static void main(String[] args) { 13 | 14 | String token = System.getenv("ASTRA_DB_APPLICATION_TOKEN"); 15 | UUID TEST_TENANT = UUID.fromString("00000000-0000-0000-0000-000000000000"); 16 | 17 | //Database db = DataAPIClients.astra(token).getDatabase(TEST_TENANT); 18 | //System.out.println(db.getInfo().getName()); 19 | RagRepository repo = new RagRepository(token, "goodbards"); 20 | Table tableSources = repo.getTableRagSource(TEST_TENANT); 21 | 22 | TableFindOptions options = new TableFindOptions() 23 | .projection(Projection.include("name", "source", "location")); 24 | tableSources.find(options).toList().forEach(System.out::println); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/rag/sources/RagJobStatus.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.rag.sources; 2 | 3 | public enum RagJobStatus { 4 | NOT_STARTED, PROCESSING, COMPLETED, FAILED, CANCELLED 5 | } 6 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/rag/sources/RagSourceCreationRequest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.rag.sources; 2 | 3 | import lombok.Data; 4 | import lombok.experimental.Accessors; 5 | 6 | import java.util.UUID; 7 | 8 | @Data 9 | @Accessors(fluent = true, chain = true) 10 | public class RagSourceCreationRequest { 11 | 12 | // author 13 | UUID createdBy; 14 | 15 | // needed to get a name 16 | String name; 17 | 18 | // needed to select the loader 19 | RagSources source; 20 | 21 | // needed to select capture the data 22 | String location; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/rag/sources/RagSourceStatus.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.rag.sources; 2 | 3 | public enum RagSourceStatus { 4 | NEW,LOADED, PARSED, COMPLETED, FAILED, EXPIRED, DELETED, 5 | } 6 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/java/com/datastax/astra/tool/loader/rag/sources/RagSources.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.tool.loader.rag.sources; 2 | 3 | 4 | /** 5 | * Based on the source we will add the RAG. 6 | */ 7 | public enum RagSources { 8 | 9 | SETTINGS("settings"), 10 | 11 | DOCUMENT("document"), 12 | 13 | ASSET("asset"), 14 | 15 | CHAT("chat"), 16 | 17 | URL("url"), 18 | 19 | FILE("file"); 20 | 21 | RagSources(String key) { 22 | this.key = key; 23 | } 24 | 25 | private String key; 26 | 27 | public String getKey() { 28 | return key; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /astra-db-java-tools/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %magenta(%-5level) %cyan(%-20logger) : %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /astra-db-java/src/license/apache2/header.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 2 | You may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /astra-db-java/src/license/licenses.properties: -------------------------------------------------------------------------------- 1 | apache2=Apache 2 -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/DataAPIDestination.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Represent the destination of the data API. 25 | */ 26 | public enum DataAPIDestination { 27 | 28 | /** 29 | * Astra Production environment 30 | */ 31 | ASTRA, 32 | 33 | /** 34 | * Astra Development environment 35 | */ 36 | ASTRA_DEV, 37 | 38 | /** 39 | * Astra Test environment 40 | */ 41 | ASTRA_TEST, 42 | 43 | /** 44 | * Local installation of Datastax Enterprise 45 | */ 46 | DSE, 47 | 48 | /** 49 | * Hyper Converged Database 50 | */ 51 | HCD, 52 | 53 | /** 54 | * Local installation of Apache Cassandra 55 | */ 56 | CASSANDRA, 57 | 58 | /** 59 | * Extra local installation . 60 | */ 61 | OTHERS 62 | } 63 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/admin/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Administration classes to manage Databases and Namespaces. 3 | */ 4 | package com.datastax.astra.client.admin; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/ReturnDocument.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | 25 | /** 26 | * Enum to define the return document option. 27 | */ 28 | @Getter 29 | public enum ReturnDocument { 30 | 31 | /** if set to before, the command will return the document before the update */ 32 | BEFORE("before"), 33 | 34 | /** if set to after, the command will return the document after the update */ 35 | AFTER("after"); 36 | 37 | /** key to be used in the JSON payload */ 38 | private final String key; 39 | 40 | /** 41 | * Constructor. 42 | * 43 | * @param key key to be used in the JSON payload 44 | */ 45 | ReturnDocument(String key) { 46 | this.key = key; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/cursor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing cursors working with find collection commands. 3 | */ 4 | package com.datastax.astra.client.collections.commands.cursor; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/CollectionDeleteManyOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * Options to delete many documents. 31 | */ 32 | @Getter 33 | @Setter 34 | @Accessors(fluent = true, chain = true) 35 | public class CollectionDeleteManyOptions extends BaseOptions { 36 | 37 | /** 38 | * Default constructor. 39 | */ 40 | public CollectionDeleteManyOptions() { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/CollectionInsertOneOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * Options for InsertOne 31 | */ 32 | @Getter @Setter 33 | @Accessors(fluent = true, chain = true) 34 | public class CollectionInsertOneOptions extends BaseOptions { 35 | 36 | /** 37 | * Default constructor. 38 | */ 39 | public CollectionInsertOneOptions() { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/CollectionReplaceOneOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * Options for the replaceOne operation. 31 | */ 32 | @Getter @Setter 33 | @Accessors(fluent = true, chain = true) 34 | public class CollectionReplaceOneOptions extends BaseOptions { 35 | 36 | /** If upsert is selected. */ 37 | Boolean upsert; 38 | 39 | /** 40 | * Default constructor. 41 | */ 42 | public CollectionReplaceOneOptions() { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/CollectionUpdateManyOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * Options for the updateOne operation 31 | */ 32 | @Getter @Setter 33 | @Accessors(fluent = true, chain = true) 34 | public class CollectionUpdateManyOptions extends BaseOptions { 35 | 36 | /** 37 | * if upsert is selected 38 | */ 39 | private Boolean upsert; 40 | 41 | /** 42 | * Default constructor. 43 | */ 44 | public CollectionUpdateManyOptions() { 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/CountDocumentsOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * List Options for a FindOne command. 31 | */ 32 | @Getter @Setter 33 | @Accessors(fluent = true, chain = true) 34 | public class CountDocumentsOptions extends BaseOptions { 35 | 36 | /** 37 | * Default constructor. 38 | */ 39 | public CountDocumentsOptions() { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/EstimatedCountDocumentsOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.experimental.Accessors; 28 | 29 | /** 30 | * List Options for a FindOne command. 31 | */ 32 | @Getter @Setter 33 | @Accessors(fluent = true, chain = true) 34 | public class EstimatedCountDocumentsOptions extends BaseOptions { 35 | 36 | /** 37 | * Default constructor. 38 | */ 39 | public EstimatedCountDocumentsOptions() { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/ListCollectionOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import com.datastax.astra.internal.serdes.collections.DocumentSerializer; 25 | 26 | import static com.datastax.astra.client.core.commands.CommandType.COLLECTION_ADMIN; 27 | 28 | /** 29 | * Options for the listCollection operation. 30 | */ 31 | public class ListCollectionOptions extends BaseOptions { 32 | 33 | /** 34 | * Default constructor. 35 | */ 36 | public ListCollectionOptions() { 37 | super(null, COLLECTION_ADMIN, new DocumentSerializer(), null); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/options/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Options and Inputs for Collections commands. 3 | */ 4 | package com.datastax.astra.client.collections.commands.options; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Command Definitions for operating on Collections. 3 | */ 4 | package com.datastax.astra.client.collections.commands; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/results/CollectionDeleteResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | 25 | /** 26 | * Hold the result of delete commands (deleteOne, deleteMany). 27 | */ 28 | @Getter 29 | public class CollectionDeleteResult { 30 | 31 | /** 32 | * NUmber of documents deleted. 33 | */ 34 | private final int deletedCount; 35 | 36 | /** 37 | * Default constructor. 38 | * 39 | * @param deletedCount 40 | * number of items deleted 41 | */ 42 | public CollectionDeleteResult(int deletedCount) { 43 | this.deletedCount = deletedCount; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/results/CollectionInsertOneResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.AllArgsConstructor; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | 28 | /** 29 | * Represents the result returned by command 'insertOne()', mainly the insertedI 30 | */ 31 | @Getter @Setter 32 | @AllArgsConstructor 33 | public class CollectionInsertOneResult { 34 | 35 | /** 36 | * Object return but the insert one command. 37 | */ 38 | Object insertedId; 39 | 40 | /** 41 | * Default constructor. 42 | */ 43 | public CollectionInsertOneResult() { 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/results/CollectionUpdateResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | 27 | /** 28 | * Return update result. 29 | */ 30 | @Getter @Setter 31 | public class CollectionUpdateResult { 32 | 33 | /** 34 | * Number of matched documents 35 | */ 36 | Integer matchedCount; 37 | 38 | /** 39 | * Number of modified documents 40 | */ 41 | Integer modifiedCount; 42 | 43 | /** 44 | * Populated if upserted 45 | */ 46 | Object upsertedId; 47 | 48 | /** 49 | * Default constructor. 50 | */ 51 | public CollectionUpdateResult() { 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/results/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Outputs and DTO for Collections Commands. 3 | */ 4 | package com.datastax.astra.client.collections.commands.results; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/documents/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects describing the structure of a Document. 3 | */ 4 | package com.datastax.astra.client.collections.definition.documents; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/documents/types/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Object representing the type Id for collections. 3 | */ 4 | package com.datastax.astra.client.collections.definition.documents.types; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects describing the structure of a collection. 3 | */ 4 | package com.datastax.astra.client.collections.definition; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Specializations of the exceptions to work with Collections. 3 | */ 4 | package com.datastax.astra.client.collections.exceptions; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/collections/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Top package to interact with Collections 3 | */ 4 | package com.datastax.astra.client.collections; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/auth/StaticTokenProvider.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.auth; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Static token, never expires.. 25 | * 26 | * @author Cedrick LUNVEN (@clunven) 27 | */ 28 | public class StaticTokenProvider implements TokenProvider { 29 | 30 | /** Reference to token. */ 31 | private String token; 32 | 33 | /** 34 | * Constructor with all parameters. 35 | * 36 | * @param token 37 | * static token to be used 38 | */ 39 | public StaticTokenProvider(String token) { 40 | this.token = token; 41 | } 42 | 43 | /** {@inheritDoc} */ 44 | @Override 45 | public String getToken() { 46 | return token; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/auth/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes to authenticate against API endpoint. 3 | */ 4 | package com.datastax.astra.client.core.auth; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility classes for commands and operations. 3 | */ 4 | package com.datastax.astra.client.core.commands; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/headers/EmbeddingHeadersProvider.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.headers; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.Map; 24 | 25 | /** 26 | * To use the interface embeddings API the user needs to be authenticated against the embedding provider. 27 | * - You can set the header variable `x-embedding-api-key` to authenticate against the embedding provider. 28 | * - You can set multiple headers to authenticate against multiple embedding providers. 29 | */ 30 | public interface EmbeddingHeadersProvider extends HeadersProvider, Cloneable { 31 | 32 | /** 33 | * Clone the EmbeddingHeadersProvider. 34 | * 35 | * @return 36 | * a new instance of the EmbeddingHeadersProvider. 37 | */ 38 | EmbeddingHeadersProvider copy(); 39 | } 40 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/headers/HeadersProvider.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.headers; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 - 2025 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.Map; 24 | 25 | /** 26 | * Super interface to provide headers for the client. 27 | */ 28 | public interface HeadersProvider { 29 | 30 | /** 31 | * Build the Header to authenticate against embeddings provider. 32 | * 33 | * @return 34 | * headers to use for the embedding provider. 35 | */ 36 | Map getHeaders(); 37 | } 38 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/headers/RerankingHeadersProvider.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.headers; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * To use the interface embeddings API the user needs to be authenticated against the embedding provider. 25 | * - You can set the header variable `x-embedding-api-key` to authenticate against the embedding provider. 26 | * - You can set multiple headers to authenticate against multiple embedding providers. 27 | */ 28 | public interface RerankingHeadersProvider extends HeadersProvider, Cloneable { 29 | 30 | /** 31 | * Clone the EmbeddingHeadersProvider. 32 | * 33 | * @return 34 | * a new instance of the EmbeddingHeadersProvider. 35 | */ 36 | RerankingHeadersProvider copy(); 37 | } 38 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/http/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes to specialize the HTTP Client. 3 | */ 4 | package com.datastax.astra.client.core.http; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/lexical/Lexical.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.lexical; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 - 2025 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.internal.serdes.core.AnalyzerSerializer; 24 | import com.datastax.astra.internal.serdes.core.LexicalSerializer; 25 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 26 | import lombok.Data; 27 | import lombok.NonNull; 28 | 29 | /** 30 | * Lexical data. 31 | */ 32 | @Data 33 | @JsonSerialize(using = LexicalSerializer.class) 34 | public class Lexical { 35 | 36 | /** 37 | * Lexical data. 38 | */ 39 | private String text; 40 | 41 | /** 42 | * Default constructor. 43 | * 44 | * @param text 45 | * lexical data 46 | */ 47 | public Lexical(@NonNull String text) { 48 | this.text = text; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/options/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes for options of the core commands. 3 | */ 4 | package com.datastax.astra.client.core.options; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Core classes to interact both with Tables and Collections. 3 | */ 4 | package com.datastax.astra.client.core; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/paging/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Informations for cursor-based paging. 3 | */ 4 | package com.datastax.astra.client.core.paging; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/query/SortOrder.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.core.query; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | 25 | /** 26 | * Encode the sort order in results. 27 | */ 28 | @Getter 29 | public enum SortOrder { 30 | 31 | /** Value for ascending order. */ 32 | ASCENDING(1), 33 | 34 | /** Value for descending order. */ 35 | DESCENDING(-1); 36 | 37 | /** Order value. */ 38 | private final Integer code; 39 | 40 | /** 41 | * Constructor for the enum. 42 | * 43 | * @param code 44 | * value for the order 45 | */ 46 | SortOrder(Integer code) { 47 | this.code = code; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/query/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes uses to build queries with Sort and Projection. 3 | */ 4 | package com.datastax.astra.client.core.query; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/vector/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing Vector options (vector) 3 | */ 4 | package com.datastax.astra.client.core.vector; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/core/vectorize/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing Vector Services options (vectorize) 3 | */ 4 | package com.datastax.astra.client.core.vectorize; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing commands against databases and keyspaces. 3 | */ 4 | package com.datastax.astra.client.databases.commands; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/commands/results/FindEmbeddingProvidersResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.databases.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.vectorize.EmbeddingProvider; 24 | import lombok.AllArgsConstructor; 25 | import lombok.Getter; 26 | import lombok.NoArgsConstructor; 27 | 28 | import java.util.Map; 29 | 30 | /** 31 | * Wrapper to get information about the findEmbeddingProviders. 32 | */ 33 | @Getter 34 | @AllArgsConstructor 35 | public class FindEmbeddingProvidersResult { 36 | 37 | /** 38 | * List of embedding providers 39 | */ 40 | Map embeddingProviders; 41 | 42 | /** 43 | * Default constructor. 44 | */ 45 | public FindEmbeddingProvidersResult() {} 46 | 47 | } 48 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/commands/results/FindRerankingProvidersResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.databases.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.rerank.RerankProvider; 24 | import lombok.AllArgsConstructor; 25 | import lombok.Getter; 26 | 27 | import java.util.Map; 28 | 29 | /** 30 | * Wrapper to get information about the findEmbeddingProviders. 31 | */ 32 | @Getter 33 | @AllArgsConstructor 34 | public class FindRerankingProvidersResult { 35 | 36 | /** 37 | * List of embedding providers 38 | */ 39 | Map rerankingProviders; 40 | 41 | /** 42 | * Default constructor. 43 | */ 44 | public FindRerankingProvidersResult() {} 45 | 46 | } 47 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/commands/results/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Object representing keyspace level returns objects. 3 | */ 4 | package com.datastax.astra.client.databases.commands.results; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/definition/keyspaces/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Object representing the keyspaces. 3 | */ 4 | package com.datastax.astra.client.databases.definition.keyspaces; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/definition/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects the informations of databases 3 | */ 4 | package com.datastax.astra.client.databases.definition; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/databases/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Top package to interact with Databases and Keyspaces. 3 | */ 4 | package com.datastax.astra.client.databases; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/exceptions/DataAPITimeoutException.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.exceptions; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * A request to the Data API resulted in an HTTP 4xx or 5xx response. 25 | * In most cases this comes with additional information: the purpose 26 | * of this class is to present such information in a structured way, 27 | * asking to what happens for the DataAPIResponseException, while 28 | * still raising`. 29 | */ 30 | public class DataAPITimeoutException extends DataAPIHttpException { 31 | 32 | /** 33 | * Constructors providing all arguments and a parent exception. 34 | * 35 | * @param errorMessage 36 | * error message 37 | */ 38 | public DataAPITimeoutException(String errorMessage) { 39 | super(ERROR_CODE_TIMEOUT, errorMessage); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/exceptions/ErrorCodesServer.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.exceptions; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 - 2025 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | 25 | /** 26 | * Error codes for server-side errors. 27 | */ 28 | @Getter 29 | public enum ErrorCodesServer { 30 | 31 | /** 32 | * Indicates an error in client-side serialization. 33 | */ 34 | DESERIALIZATION_ERROR("Cannot deserialize String %s, cause: %s"); 35 | 36 | /** 37 | * The descriptive message associated with the error. 38 | */ 39 | private final String message; 40 | 41 | /** 42 | * Constructs a new {@code ClientErrorCodes} instance with the specified code and message. 43 | * 44 | * @param message the descriptive message associated with the error 45 | */ 46 | ErrorCodesServer(String message) { 47 | this.message = message; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Exceptions specialized checked and unchecked thrown by the client. 3 | */ 4 | package com.datastax.astra.client.exceptions; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/options/CountRowsOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.commands.CommandType; 24 | import com.datastax.astra.client.core.options.BaseOptions; 25 | import lombok.Getter; 26 | import lombok.NoArgsConstructor; 27 | import lombok.Setter; 28 | import lombok.experimental.Accessors; 29 | 30 | import static com.datastax.astra.client.tables.Table.DEFAULT_TABLE_SERIALIZER; 31 | 32 | /** 33 | * List Options for a FindOne command. 34 | */ 35 | @Getter @Setter 36 | @Accessors(fluent = true, chain = true) 37 | public class CountRowsOptions extends BaseOptions { 38 | 39 | /** 40 | * Default constructor. 41 | */ 42 | public CountRowsOptions() { 43 | super(null, CommandType.GENERAL_METHOD, DEFAULT_TABLE_SERIALIZER, null); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/options/ListIndexesOptions.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables.commands.options; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.datastax.astra.client.core.options.BaseOptions; 24 | import com.datastax.astra.internal.serdes.tables.RowSerializer; 25 | 26 | import static com.datastax.astra.client.core.commands.CommandType.TABLE_ADMIN; 27 | 28 | /** 29 | * Options to list indexes. 30 | */ 31 | public class ListIndexesOptions extends BaseOptions { 32 | 33 | /** 34 | * Default constructor. 35 | */ 36 | public ListIndexesOptions() { 37 | super(null, TABLE_ADMIN, new RowSerializer(), null); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/options/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Options and Inputs for Tables commands. 3 | */ 4 | package com.datastax.astra.client.tables.commands.options; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Command Definitions for operating on Tables. 3 | */ 4 | package com.datastax.astra.client.tables.commands; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/results/TableUpdateResult.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables.commands.results; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | 27 | /** 28 | * Return update result. 29 | */ 30 | @Getter @Setter 31 | public class TableUpdateResult { 32 | 33 | /** 34 | * Number of matched documents 35 | */ 36 | Integer matchedCount; 37 | 38 | /** 39 | * Number of modified documents 40 | */ 41 | Integer modifiedCount; 42 | 43 | /** 44 | * Populated if upserted 45 | */ 46 | Object upsertedId; 47 | 48 | /** 49 | * Default constructor. 50 | */ 51 | public TableUpdateResult() {} 52 | 53 | } 54 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/results/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Outputs and DTO for Tables Commands. 3 | */ 4 | package com.datastax.astra.client.tables.commands.results; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/cursor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing cursors working with find tables commands. 3 | */ 4 | package com.datastax.astra.client.tables.cursor; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/definition/columns/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing Table Columns 3 | */ 4 | package com.datastax.astra.client.tables.definition.columns; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/definition/indexes/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing Table Indexes. 3 | */ 4 | package com.datastax.astra.client.tables.definition.indexes; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/definition/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects describing the structure of a Table. 3 | */ 4 | package com.datastax.astra.client.tables.definition; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/definition/rows/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Objects representing Table Rows, like primary key. 3 | */ 4 | package com.datastax.astra.client.tables.definition.rows; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Specializations of the exceptions to work with Tables. 3 | */ 4 | package com.datastax.astra.client.tables.exceptions; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/mapping/EntityTable.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables.mapping; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * EntityTable annotation to define the table name 30 | */ 31 | @Target(ElementType.TYPE) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface EntityTable { 34 | 35 | /** 36 | * Table Name, if not provided the class name will be used 37 | * @return the table name 38 | */ 39 | String value() default ""; 40 | } 41 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/mapping/KeyValue.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables.mapping; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 - 2025 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | 26 | /** 27 | * Key value annotation. 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | public @interface KeyValue { 31 | 32 | /** 33 | * Key. 34 | * 35 | * @return key 36 | */ 37 | String key(); 38 | 39 | /** 40 | * Value. 41 | * 42 | * @return value 43 | */ 44 | String value(); 45 | } 46 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/mapping/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Annotations Set to map objects as Row Entities. 3 | */ 4 | package com.datastax.astra.client.tables.mapping; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/client/tables/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Top package to interact with Tables. 3 | */ 4 | package com.datastax.astra.client.tables; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/api/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes to marshall API responses 3 | */ 4 | package com.datastax.astra.internal.api; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/command/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes to run commands against the API. 3 | */ 4 | package com.datastax.astra.internal.command; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/http/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes to execute HTTP requests. 3 | */ 4 | package com.datastax.astra.internal.http; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes 3 | */ 4 | package com.datastax.astra.internal; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/reflection/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utilities for reflection at runtime 3 | */ 4 | package com.datastax.astra.internal.reflection; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/serdes/collections/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom Serializers to work with Collections. 3 | */ 4 | package com.datastax.astra.internal.serdes.collections; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/serdes/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utilities classes for Serialization and Deserialization 3 | */ 4 | package com.datastax.astra.internal.serdes; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/serdes/shared/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom Serializers applied for both tables and collections. 3 | */ 4 | package com.datastax.astra.internal.serdes.shared; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/serdes/tables/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom Serializers to work with Tables 3 | */ 4 | package com.datastax.astra.internal.serdes.tables; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/utils/BetaPreview.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.internal.utils; 2 | 3 | /*- 4 | * #%L 5 | * Data API Java Client 6 | * -- 7 | * Copyright (C) 2024 - 2025 DataStax 8 | * -- 9 | * Licensed under the Apache License, Version 2.0 10 | * You may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | /** 30 | * Indicates that a feature is still under development and might be heavily reworked. 31 | */ 32 | @Retention(RetentionPolicy.CLASS) 33 | @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) 34 | @Deprecated 35 | public @interface BetaPreview { 36 | 37 | /** 38 | * Message to be displayed when the feature is used. 39 | * 40 | * @return message 41 | * current depracation message 42 | */ 43 | String value() default "This feature is in beta and might undergo signature or behaviour changes in the future."; 44 | } 45 | -------------------------------------------------------------------------------- /astra-db-java/src/main/java/com/datastax/astra/internal/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal technical classes for low-level utilities 3 | */ 4 | package com.datastax.astra.internal.utils; 5 | /*- 6 | * #%L 7 | * Data API Java Client 8 | * -- 9 | * Copyright (C) 2024 DataStax 10 | * -- 11 | * Licensed under the Apache License, Version 2.0 12 | * You may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * #L% 23 | */ 24 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/AbstractAstraDBAdminTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration; 2 | 3 | import com.datastax.astra.client.admin.AstraDBDatabaseAdmin; 4 | import com.datastax.astra.client.databases.Database; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.junit.jupiter.api.MethodOrderer; 7 | import org.junit.jupiter.api.Order; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.TestMethodOrder; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | 13 | @Slf4j 14 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 15 | public abstract class AbstractAstraDBAdminTest extends AbstractDataAPITest { 16 | 17 | protected static com.dtsx.astra.sdk.db.domain.Database devopsDb; 18 | 19 | @Test 20 | @Order(1) 21 | public void should_create_database() { 22 | Database db = getDatabase(); 23 | devopsDb = ((AstraDBDatabaseAdmin)db.getDatabaseAdmin()).getDatabaseInformations(); 24 | assertThat(devopsDb).isNotNull(); 25 | assertThat(devopsDb.getInfo()).isNotNull(); 26 | assertThat(getAstraDBAdmin().listDatabaseNames()).contains(devopsDb.getInfo().getName()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/AbstractTableITTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.junit.jupiter.api.MethodOrderer; 5 | import org.junit.jupiter.api.TestMethodOrder; 6 | 7 | import java.util.Map; 8 | 9 | import static org.assertj.core.api.AssertionsForClassTypes.assertThat; 10 | 11 | @Slf4j 12 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 13 | public abstract class AbstractTableITTest extends AbstractDataAPITest { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/astra/Astra_01_AstraDBAdminITTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.astra; 2 | 3 | import com.datastax.astra.test.integration.AbstractAstraDBAdminTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_ASTRA_TOKEN; 7 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_PROVIDER; 8 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_REGION; 9 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_DESTINATION; 10 | 11 | @EnabledIfSystemProperty(named = ENV_VAR_ASTRA_TOKEN, matches = ".*") 12 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_PROVIDER, matches = ".*") 13 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_REGION, matches = ".*") 14 | @EnabledIfSystemProperty(named = ENV_VAR_DESTINATION, matches = "astra_(dev|prod|test)") 15 | class Astra_01_AstraDBAdminITTest extends AbstractAstraDBAdminTest {} -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/astra/Astra_02_DatabaseAdminITTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.astra; 2 | 3 | import com.datastax.astra.test.integration.AbstractDatabaseAdminITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_ASTRA_TOKEN; 7 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_PROVIDER; 8 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_REGION; 9 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_DESTINATION; 10 | 11 | @EnabledIfSystemProperty(named = ENV_VAR_ASTRA_TOKEN, matches = ".*") 12 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_PROVIDER, matches = ".*") 13 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_REGION, matches = ".*") 14 | @EnabledIfSystemProperty(named = ENV_VAR_DESTINATION, matches = "astra_(dev|prod|test)") 15 | public class Astra_02_DatabaseAdminITTest extends AbstractDatabaseAdminITTest { 16 | } 17 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/astra/Astra_03_DatabaseITTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.astra; 2 | 3 | import com.datastax.astra.test.integration.AbstractDatabaseTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_ASTRA_TOKEN; 7 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_PROVIDER; 8 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_REGION; 9 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_DESTINATION; 10 | 11 | /** 12 | * Integration tests against a Local Instance of Stargate. 13 | */ 14 | @EnabledIfSystemProperty(named = ENV_VAR_ASTRA_TOKEN, matches = ".*") 15 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_PROVIDER, matches = ".*") 16 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_REGION, matches = ".*") 17 | @EnabledIfSystemProperty(named = ENV_VAR_DESTINATION, matches = "astra_(dev|prod|test)") 18 | class Astra_03_DatabaseITTest extends AbstractDatabaseTest { 19 | } 20 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/astra/Astra_04_CollectionITTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.astra; 2 | 3 | import com.datastax.astra.test.integration.AbstractCollectionITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_ASTRA_TOKEN; 7 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_PROVIDER; 8 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_CLOUD_REGION; 9 | import static com.datastax.astra.test.integration.AbstractDataAPITest.ENV_VAR_DESTINATION; 10 | 11 | @EnabledIfSystemProperty(named = ENV_VAR_ASTRA_TOKEN, matches = ".*") 12 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_PROVIDER, matches = ".*") 13 | @EnabledIfSystemProperty(named = ENV_VAR_CLOUD_REGION, matches = ".*") 14 | @EnabledIfSystemProperty(named = ENV_VAR_DESTINATION, matches = "astra_prod") 15 | class Astra_04_CollectionITTest extends AbstractCollectionITTest {} 16 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_HuggingFaceITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "HF_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_HuggingFaceITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "huggingface"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("HF_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_JinaAITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "JINA_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_JinaAITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "jinaAI"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("JINA_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_MistralAITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "MISTRAL_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_MistralAITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "mistral"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("MISTRAL_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_NVidiaTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 6 | 7 | import java.util.Map; 8 | 9 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 10 | public class Local_13_Collection_Vectorize_NVidiaTest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "nvidia"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | // Authenticated with an Astra Token 20 | return readEnvVariable("ASTRA_DB_APPLICATION_TOKEN_DEV"); 21 | } 22 | 23 | @Override 24 | protected Map getAuthenticationParameters() { 25 | return Map.of(); 26 | } 27 | 28 | @Test 29 | public void should_test_vectorize_with_api_header() { 30 | // overriding as not possible 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_OpenAIITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "OPENAI_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_OpenAIITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "openai"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("OPENAI_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_UpstageAITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "UPSTAGE_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_UpstageAITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "upstageAI"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("UPSTAGE_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/integration/local/Local_13_Collection_Vectorize_VoyageAITest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.integration.local; 2 | 3 | import com.datastax.astra.test.integration.AbstractVectorizeApiHeaderITTest; 4 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 5 | 6 | import java.util.Map; 7 | 8 | @EnabledIfSystemProperty(named = "ASTRA_DB_JAVA_TEST_ENV", matches = "local") 9 | @EnabledIfSystemProperty(named = "VOYAGE_API_KEY", matches = ".*") 10 | public class Local_13_Collection_Vectorize_VoyageAITest extends AbstractVectorizeApiHeaderITTest { 11 | 12 | @Override 13 | protected String getEmbeddingProviderId() { 14 | return "voyageAI"; 15 | } 16 | 17 | @Override 18 | protected String getApiKey() { 19 | return readEnvVariable("VOYAGE_API_KEY"); 20 | } 21 | 22 | @Override 23 | protected Map getAuthenticationParameters() { 24 | return Map.of(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.UUID; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class Product { 14 | @JsonProperty("_id") 15 | protected ID id; 16 | protected String name; 17 | protected Double price; 18 | protected UUID code; 19 | } -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/ProductObjectUUID.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import lombok.NoArgsConstructor; 4 | 5 | import java.util.UUID; 6 | 7 | @NoArgsConstructor 8 | public class ProductObjectUUID extends Product {} -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/ProductString.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import lombok.NoArgsConstructor; 4 | 5 | @NoArgsConstructor 6 | public class ProductString extends Product { 7 | 8 | public ProductString(String id, String name, Double price) { 9 | this.id = id; 10 | this.name = name; 11 | this.price = price; 12 | } 13 | } -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/ProjectObjectId.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.datastax.astra.client.collections.definition.documents.types.ObjectId; 4 | import lombok.NoArgsConstructor; 5 | 6 | @NoArgsConstructor 7 | public class ProjectObjectId extends Product {} -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableCompositeAnnotatedRow.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.datastax.astra.client.tables.mapping.Column; 4 | import com.datastax.astra.client.tables.mapping.PartitionBy; 5 | import com.datastax.astra.client.tables.mapping.EntityTable; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import static com.datastax.astra.client.tables.definition.columns.ColumnTypes.INT; 11 | import static com.datastax.astra.client.tables.definition.columns.ColumnTypes.TEXT; 12 | 13 | @Data 14 | @EntityTable("table_composite_pk_annotated") 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class TableCompositeAnnotatedRow { 18 | 19 | @PartitionBy(0) 20 | @Column(name ="id", type=TEXT) 21 | private String idx; 22 | 23 | @PartitionBy(1) 24 | @Column(name ="name", type=TEXT) 25 | private String namex; 26 | 27 | @Column(name ="age", type=INT) 28 | private int agex; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableCompositeRow.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class TableCompositeRow { 11 | private int age; 12 | private String name; 13 | private String id; 14 | } 15 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableEntityGame.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.datastax.astra.client.core.vector.DataAPIVector; 4 | import com.datastax.astra.client.tables.mapping.Column; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.time.Instant; 9 | import java.util.Set; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | public class TableEntityGame { 14 | 15 | @Column(name ="match_id") 16 | private String matchId; 17 | 18 | private Integer round; 19 | 20 | private Integer score; 21 | 22 | private Instant when; 23 | 24 | private String winner; 25 | 26 | private Set fighters; 27 | 28 | @Column(name ="m_vector") 29 | private DataAPIVector vector; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableEntityGameWithAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.datastax.astra.client.core.query.SortOrder; 4 | import com.datastax.astra.client.core.vector.DataAPIVector; 5 | import com.datastax.astra.client.core.vector.SimilarityMetric; 6 | import com.datastax.astra.client.tables.mapping.Column; 7 | import com.datastax.astra.client.tables.mapping.ColumnVector; 8 | import com.datastax.astra.client.tables.mapping.EntityTable; 9 | import com.datastax.astra.client.tables.mapping.PartitionBy; 10 | import com.datastax.astra.client.tables.mapping.PartitionSort; 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | 15 | import java.time.Instant; 16 | import java.util.Set; 17 | import java.util.UUID; 18 | 19 | @Data 20 | @EntityTable("game_ann2") 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class TableEntityGameWithAnnotation { 24 | 25 | @PartitionBy(0) 26 | @Column(name ="match_id") 27 | private String matchId; 28 | 29 | @PartitionSort(position = 0, order = SortOrder.ASCENDING) 30 | private Integer round; 31 | 32 | private Integer score; 33 | 34 | private Instant when; 35 | 36 | private String winner; 37 | 38 | private Set fighters; 39 | 40 | @ColumnVector(name ="m_vector", dimension = 3, metric = SimilarityMetric.COSINE) 41 | private DataAPIVector vector; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableSimpleAnnotatedRow.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import com.datastax.astra.client.tables.mapping.Column; 4 | import com.datastax.astra.client.tables.mapping.PartitionBy; 5 | import com.datastax.astra.client.tables.mapping.PartitionSort; 6 | import com.datastax.astra.client.tables.mapping.EntityTable; 7 | import com.datastax.astra.test.integration.local.Local_20_TableITTest; 8 | import lombok.Builder; 9 | import lombok.Data; 10 | 11 | import static com.datastax.astra.client.core.query.SortOrder.ASCENDING; 12 | import static com.datastax.astra.client.tables.definition.columns.ColumnTypes.BOOLEAN; 13 | import static com.datastax.astra.client.tables.definition.columns.ColumnTypes.INT; 14 | import static com.datastax.astra.client.tables.definition.columns.ColumnTypes.TEXT; 15 | 16 | @Data 17 | @Builder 18 | @EntityTable(Local_20_TableITTest.TABLE_SIMPLE) 19 | public class TableSimpleAnnotatedRow { 20 | 21 | @PartitionBy(0) 22 | @Column(name ="email", type= TEXT) 23 | private String email; 24 | 25 | @PartitionSort(position = 0, order = ASCENDING) 26 | @Column(name ="age", type = INT) 27 | private Integer age; 28 | 29 | @Column(name ="country", type = TEXT) 30 | private String country; 31 | 32 | @Column(name ="name", type = TEXT) 33 | private String name; 34 | 35 | @Column(name ="human", type = BOOLEAN) 36 | private Boolean human; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/model/TableSimpleRow.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data @Builder 7 | public class TableSimpleRow { 8 | String email; 9 | Integer age; 10 | String country; 11 | String name; 12 | Boolean human; 13 | } 14 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/unit/DataAPIExceptionsTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.unit; 2 | 3 | import com.datastax.astra.client.exceptions.UnexpectedDataAPIResponseException; 4 | import com.datastax.astra.client.core.commands.Command; 5 | import com.datastax.astra.internal.api.DataAPIResponse; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 9 | 10 | 11 | /** 12 | * Tests on exceptions. 13 | */ 14 | class DataAPIExceptionsTest { 15 | 16 | @Test 17 | void shouldSerializeCommandInFaultyException() { 18 | // Given 19 | Command c = new Command("createCollection").append("name", "demo"); 20 | DataAPIResponse res = new DataAPIResponse(); 21 | assertThatThrownBy(() -> { throw new UnexpectedDataAPIResponseException(c, res, "demo message");} ) 22 | .isInstanceOf(UnexpectedDataAPIResponseException.class) 23 | .hasMessageContaining("demo message") 24 | .extracting("command", "response", "message") 25 | .containsExactly(c, res, "[CLIENT_ERROR] - demo message"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/unit/MockCommandObserver.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.unit; 2 | 3 | import com.datastax.astra.internal.command.CommandObserver; 4 | import com.datastax.astra.internal.command.ExecutionInfos; 5 | 6 | import static org.assertj.core.api.Assertions.assertThat; 7 | 8 | 9 | public class MockCommandObserver implements CommandObserver { 10 | 11 | @Override 12 | public void onCommand(ExecutionInfos executionInfo) { 13 | assertThat(executionInfo.getExecutionDate()).isNotNull(); 14 | assertThat(executionInfo.getResponseHttpHeaders()).isNotNull(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/unit/TableDefinitionSerializationTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.unit; 2 | 3 | import com.datastax.astra.client.tables.definition.indexes.TableRegularIndexDefinition; 4 | import com.datastax.astra.client.tables.definition.indexes.TableIndexMapTypes; 5 | import com.datastax.astra.internal.serdes.tables.RowSerializer; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class TableDefinitionSerializationTest { 9 | 10 | RowSerializer ROW_SERIALIZER = new RowSerializer(); 11 | 12 | private void log(TableRegularIndexDefinition idx) { 13 | System.out.println(ROW_SERIALIZER.marshall(idx)); 14 | } 15 | 16 | @Test 17 | public void should_serialize_table_index_column_definition() { 18 | log(new TableRegularIndexDefinition().column("scalar_col")); 19 | log(new TableRegularIndexDefinition().column("map_col1", TableIndexMapTypes.KEYS)); 20 | log(new TableRegularIndexDefinition().column("map_col2", TableIndexMapTypes.VALUES)); 21 | log(new TableRegularIndexDefinition().column("map_col2", TableIndexMapTypes.ENTRIES)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /astra-db-java/src/test/java/com/datastax/astra/test/unit/TokenProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.test.unit; 2 | 3 | import com.datastax.astra.client.core.auth.StaticTokenProvider; 4 | import com.datastax.astra.client.core.auth.UsernamePasswordTokenProvider; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import static org.assertj.core.api.Assertions.assertThat; 8 | 9 | /** 10 | * Test for Token Providers 11 | */ 12 | class TokenProviderTest { 13 | 14 | @Test 15 | void shouldFixedTokenProviderReturnToken() { 16 | assertThat(new StaticTokenProvider("token").getToken()).isEqualTo("token"); 17 | assertThat(new StaticTokenProvider("token").get()).isEqualTo("token"); 18 | } 19 | 20 | @Test 21 | void shouldGetMeAToken() { 22 | String token = new UsernamePasswordTokenProvider().getToken(); 23 | System.out.println(token); 24 | assertThat(token).isNotNull(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /astra-db-java/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %magenta(%-5level) %cyan(%-20logger) : %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/AccessListAddressRequest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.domain; 2 | 3 | /** 4 | * Create new Address. 5 | */ 6 | public class AccessListAddressRequest { 7 | 8 | /** Address. */ 9 | private final String address; 10 | 11 | /** Description. */ 12 | private final String description; 13 | 14 | /** Enabled. */ 15 | private final boolean enabled; 16 | 17 | /** 18 | * Complete constructor. 19 | * 20 | * @param address 21 | * ip address 22 | * @param description 23 | * description 24 | */ 25 | public AccessListAddressRequest(String address, String description) { 26 | this.address = address; 27 | this.enabled = true; 28 | this.description = description; 29 | } 30 | 31 | /** 32 | * Gets address 33 | * 34 | * @return value of address 35 | */ 36 | public String getAddress() { 37 | return address; 38 | } 39 | 40 | /** 41 | * Gets description 42 | * 43 | * @return value of description 44 | */ 45 | public String getDescription() { 46 | return description; 47 | } 48 | 49 | /** 50 | * Gets enabled 51 | * 52 | * @return value of enabled 53 | */ 54 | public boolean isEnabled() { 55 | return enabled; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/DatabaseCreationType.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.domain; 2 | 3 | /** 4 | * List of type available for vector. 5 | */ 6 | public enum DatabaseCreationType { 7 | 8 | /** Provided if the db is vector. */ 9 | vector 10 | } 11 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/RegionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright DataStax, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dtsx.astra.sdk.db.domain; 18 | 19 | /** 20 | * Encoded all values for 'region-type' 21 | */ 22 | public enum RegionType { 23 | /** all regions. */ 24 | ALL, 25 | 26 | /** SERVERLESS regions. */ 27 | SERVERLESS, 28 | 29 | /** VECTOR regions. */ 30 | VECTOR 31 | } 32 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** Entities and Pojo for Astra Db Service. */ 2 | package com.dtsx.astra.sdk.db.domain; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/CloudWatchTelemetryRequest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.domain.telemetry; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * Externalization of monitoring. 7 | */ 8 | public class CloudWatchTelemetryRequest { 9 | 10 | /** json field. */ 11 | @JsonProperty("access_key") 12 | private String accessKey; 13 | 14 | /** json field. */ 15 | private String secret; 16 | 17 | /** json field. */ 18 | private String region; 19 | 20 | /** 21 | * Default constructor. 22 | */ 23 | public CloudWatchTelemetryRequest() { 24 | } 25 | 26 | /** 27 | * Full constructor. 28 | * 29 | * @param accessKey 30 | * access key 31 | * @param secret 32 | * secret 33 | * @param region 34 | * region 35 | */ 36 | public CloudWatchTelemetryRequest(String accessKey, String secret, String region) { 37 | this.accessKey = accessKey; 38 | this.secret = secret; 39 | this.region = region; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/DatadogTelemetryRequest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.domain.telemetry; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * Hold configuration to export metrics to datadog. 7 | */ 8 | public class DatadogTelemetryRequest { 9 | 10 | /** 11 | * API key to authenticate to the Datadog API 12 | */ 13 | @JsonProperty("api_key") 14 | private String apiKey; 15 | 16 | /** 17 | * The Datadog site to send data to, which should be the site parameter corresponding to the Datadog site URL 18 | */ 19 | private String site; 20 | 21 | /** 22 | * Default constructor. 23 | */ 24 | public DatadogTelemetryRequest() {} 25 | 26 | /** 27 | * Gets apiKey 28 | * 29 | * @return value of apiKey 30 | */ 31 | public String getApiKey() { 32 | return apiKey; 33 | } 34 | 35 | /** 36 | * Set value for apiKey 37 | * 38 | * @param apiKey 39 | * new value for apiKey 40 | */ 41 | public void setApiKey(String apiKey) { 42 | this.apiKey = apiKey; 43 | } 44 | 45 | /** 46 | * Gets site 47 | * 48 | * @return value of site 49 | */ 50 | public String getSite() { 51 | return site; 52 | } 53 | 54 | /** 55 | * Set value for site 56 | * 57 | * @param site 58 | * new value for site 59 | */ 60 | public void setSite(String site) { 61 | this.site = site; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/domain/telemetry/package-info.java: -------------------------------------------------------------------------------- 1 | /** Entities and Pojo for Astra Db Telemetry Service. */ 2 | package com.dtsx.astra.sdk.db.domain.telemetry; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/ChangeDataCaptureNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a region from its name, and it is not found. 5 | */ 6 | public class ChangeDataCaptureNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor. 10 | * 11 | * @param id 12 | * cdc identifier 13 | * @param db 14 | * database identifier 15 | */ 16 | public ChangeDataCaptureNotFoundException(String id, String db) { 17 | super("Cdc " + id + " is not available in db " + db); 18 | } 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param keyspace 24 | * keyspace name 25 | * @param table 26 | * table name 27 | * @param tenant 28 | * tenant name 29 | * @param db 30 | * database identifier 31 | */ 32 | public ChangeDataCaptureNotFoundException(String keyspace, String table, String tenant, String db) { 33 | super("Cdc for " + 34 | "keyspace:'" + keyspace + "' " + 35 | "table:'" + table + "'" + 36 | "tenant:'" + tenant + "'" + 37 | "is not available in db '" + db + "'"); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/DatabaseNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a database from name or id, and it is not found. 5 | */ 6 | public class DatabaseNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor with dbName 10 | * 11 | * @param dbName 12 | * db name 13 | */ 14 | public DatabaseNotFoundException(String dbName) { 15 | super("Database '" + dbName + "' has not been found."); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceAlreadyExistException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when creating a keyspace with name already in use. 5 | */ 6 | public class KeyspaceAlreadyExistException extends RuntimeException { 7 | 8 | /** 9 | * Constructor with keyspace name 10 | * 11 | * @param ksName 12 | * keyspace name 13 | * @param dbname 14 | * database name 15 | */ 16 | public KeyspaceAlreadyExistException(String ksName, String dbname) { 17 | super("Keyspace '" + ksName + "' already exists for database '" + dbname + 18 | "' Cannot create another keyspace with same name. " + 19 | "Use flag --if-not-exist to connect to the existing keyspace."); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/KeyspaceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a keyspace from its name, and it is not found. 5 | */ 6 | public class KeyspaceNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor 10 | * @param db 11 | * db identifier 12 | * @param keyspace 13 | * keyspace identifier 14 | */ 15 | public KeyspaceNotFoundException(String db, String keyspace) { 16 | super("Keyspace " + keyspace + " does not exist for db" + db); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionAlreadyExistException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when creating a region with name already in use. 5 | */ 6 | public class RegionAlreadyExistException extends RuntimeException { 7 | 8 | /** 9 | * Constructor with region name 10 | * 11 | * @param regionName 12 | * region name 13 | * @param dbname 14 | * database name 15 | */ 16 | public RegionAlreadyExistException(String regionName, String dbname) { 17 | super("Region '" + regionName + "' already exists for database '" + dbname + "'. " + 18 | "Cannot create another region with same name. " + 19 | "Use flag --if-not-exist to connect to the existing region."); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/RegionNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.db.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a region from its name, and it is not found. 5 | */ 6 | public class RegionNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor 10 | * @param db 11 | * db identifier 12 | * @param region 13 | * region identifier 14 | */ 15 | public RegionNotFoundException(String db, String region) { 16 | super("Database " + db + " is not deployed in region"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** Exceptions for Astra Db Service. */ 2 | package com.dtsx.astra.sdk.db.exception; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/package-info.java: -------------------------------------------------------------------------------- 1 | /** Sub Clients relative to Astra Db Service. */ 2 | package com.dtsx.astra.sdk.db; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** Specialized Exceptions for Astra Devops API. */ 2 | package com.dtsx.astra.sdk.exception; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/KeyRegionDefinition.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Hold key region. 7 | * 8 | * @author Cedrick LUNVEN (@clunven) 9 | */ 10 | public class KeyRegionDefinition implements Serializable { 11 | 12 | /** Serial number. */ 13 | private static final long serialVersionUID = 5963216153488939655L; 14 | 15 | /** key identifier. */ 16 | private String keyID; 17 | 18 | /** region. */ 19 | private String region; 20 | 21 | /** 22 | * Default constructor. 23 | */ 24 | public KeyRegionDefinition() {} 25 | 26 | /** 27 | * Getter accessor for attribute 'keyID'. 28 | * 29 | * @return 30 | * current value of 'keyID' 31 | */ 32 | public String getKeyID() { 33 | return keyID; 34 | } 35 | 36 | /** 37 | * Setter accessor for attribute 'keyID'. 38 | * @param keyID 39 | * new value for 'keyID ' 40 | */ 41 | public void setKeyID(String keyID) { 42 | this.keyID = keyID; 43 | } 44 | 45 | /** 46 | * Getter accessor for attribute 'region'. 47 | * 48 | * @return 49 | * current value of 'region' 50 | */ 51 | public String getRegion() { 52 | return region; 53 | } 54 | 55 | /** 56 | * Setter accessor for attribute 'region'. 57 | * @param region 58 | * new value for 'region ' 59 | */ 60 | public void setRegion(String region) { 61 | this.region = region; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/ResponseAllIamTokens.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.domain; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Represents response of Iam token list. 7 | */ 8 | public class ResponseAllIamTokens { 9 | 10 | /** 11 | * client lists. 12 | */ 13 | private List clients; 14 | 15 | /** 16 | * Default constructor. 17 | */ 18 | public ResponseAllIamTokens() {} 19 | 20 | /** 21 | * Getter accessor for attribute 'clients'. 22 | * 23 | * @return 24 | * current value of 'clients' 25 | */ 26 | public List getClients() { 27 | return clients; 28 | } 29 | 30 | /** 31 | * Setter accessor for attribute 'clients'. 32 | * @param clients 33 | * new value for 'clients ' 34 | */ 35 | public void setClients(List clients) { 36 | this.clients = clients; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/UserStatus.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.domain; 2 | 3 | /** 4 | * User status in the db. 5 | */ 6 | public enum UserStatus { 7 | 8 | /** 9 | * invited. 10 | */ 11 | invited, 12 | 13 | /** 14 | * active. 15 | */ 16 | active; 17 | } 18 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** Entities and Pojo for Astra Core Service (IAM, Organization). */ 2 | package com.dtsx.astra.sdk.org.domain; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/RoleNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.exception; 2 | 3 | /*- 4 | * #%L 5 | * Astra Cli 6 | * %% 7 | * Copyright (C) 2022 DataStax 8 | * %% 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * #L% 20 | */ 21 | 22 | /** 23 | * Role not found. 24 | */ 25 | public class RoleNotFoundException extends RuntimeException { 26 | 27 | /** Serial Number. */ 28 | private static final long serialVersionUID = -1269813351970244235L; 29 | 30 | /** 31 | * Constructor with roleName 32 | * 33 | * @param roleName 34 | * role name 35 | */ 36 | public RoleNotFoundException(String roleName) { 37 | super("Role '" + roleName + "' has not been found."); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserAlreadyExistException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.exception; 2 | 3 | /*- 4 | * #%L 5 | * Astra Cli 6 | * %% 7 | * Copyright (C) 2022 DataStax 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Exception thrown when inviting a user that is already in the organization. 25 | */ 26 | public class UserAlreadyExistException extends RuntimeException { 27 | 28 | /** 29 | * Constructor with keyspace name 30 | * 31 | * @param userName 32 | * users name 33 | */ 34 | public UserAlreadyExistException(String userName) { 35 | super("User '" + userName + "' already exists in the organization."); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/UserNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.org.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a user that does not exist. 5 | */ 6 | public class UserNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor with userName 10 | * 11 | * @param userName 12 | * name of user 13 | */ 14 | public UserNotFoundException(String userName) { 15 | super("User " + userName + "' has not been found."); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** Exceptions for Astra Core Service (IAM, Organization). */ 2 | package com.dtsx.astra.sdk.org.exception; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/package-info.java: -------------------------------------------------------------------------------- 1 | /** Sub Clients relative to Astra Core Service (IAM, Organization). */ 2 | package com.dtsx.astra.sdk.org; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/package-info.java: -------------------------------------------------------------------------------- 1 | /** Devops Api Client main class. */ 2 | package com.dtsx.astra.sdk; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateCdc.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming.domain; 2 | 3 | /** 4 | * Cdc Creation Request. 5 | */ 6 | public class CreateCdc extends DeleteCdc { 7 | 8 | /** db Name. */ 9 | private String databaseName; 10 | 11 | /** Topic Partition. */ 12 | private int topicPartitions = 1; 13 | 14 | /** 15 | * Default constructor 16 | */ 17 | public CreateCdc() {} 18 | 19 | /** 20 | * Gets databaseName 21 | * 22 | * @return value of databaseName 23 | */ 24 | public String getDatabaseName() { 25 | return databaseName; 26 | } 27 | 28 | /** 29 | * Set value for databaseName 30 | * 31 | * @param databaseName 32 | * new value for databaseName 33 | */ 34 | public void setDatabaseName(String databaseName) { 35 | this.databaseName = databaseName; 36 | } 37 | 38 | /** 39 | * Gets topicPartitions 40 | * 41 | * @return value of topicPartitions 42 | */ 43 | public int getTopicPartitions() { 44 | return topicPartitions; 45 | } 46 | 47 | /** 48 | * Set value for topicPartitions 49 | * 50 | * @param topicPartitions 51 | * new value for topicPartitions 52 | */ 53 | public void setTopicPartitions(int topicPartitions) { 54 | this.topicPartitions = topicPartitions; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/CreateTenantResponse.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * Represents the pojo for tenant creation. 10 | */ 11 | @Data 12 | @JsonIgnoreProperties 13 | @EqualsAndHashCode(callSuper = true) 14 | public class CreateTenantResponse extends Tenant { 15 | 16 | private String namespace; 17 | 18 | private String topic; 19 | 20 | /** 21 | * Default constructor. 22 | */ 23 | public CreateTenantResponse() {} 24 | 25 | } 26 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/Tenant.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming.domain; 2 | 3 | import java.util.UUID; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | /** 12 | * Hold elements for tenant. 13 | */ 14 | @Data 15 | @JsonIgnoreProperties 16 | public class Tenant { 17 | 18 | @JsonProperty("astraOrgGUID") 19 | private UUID organizationId; 20 | 21 | private String tenantName; 22 | private String clusterName; 23 | 24 | private String webServiceUrl; 25 | private String brokerServiceUrl; 26 | private String websocketUrl; 27 | private String websocketQueryParamUrl; 28 | private String pulsarToken; 29 | 30 | private String plan; 31 | private int planCode; 32 | 33 | private String cloudRegion; 34 | private String cloudProvider; 35 | private int cloudProviderCode; 36 | 37 | private String status; 38 | private String jvmVersion; 39 | private String pulsarVersion; 40 | 41 | /** 42 | * Default constructor. 43 | */ 44 | public Tenant() {} 45 | } 46 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** Entities and Pojo for Astra Streaming Service. */ 2 | package com.dtsx.astra.sdk.streaming.domain; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantAlreadyExistException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming.exception; 2 | 3 | /*- 4 | * #%L 5 | * Astra Cli 6 | * %% 7 | * Copyright (C) 2022 DataStax 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Exception throws when creating a tenant with an existing name on the cluster. 25 | */ 26 | public class TenantAlreadyExistException extends RuntimeException { 27 | 28 | /** 29 | * Constructor with dbName 30 | * 31 | * @param tenantName 32 | * tenant name 33 | */ 34 | public TenantAlreadyExistException(String tenantName) { 35 | super("Tenant name '" + tenantName + "' already exist and must be unique for the cluster."); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/TenantNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming.exception; 2 | 3 | /** 4 | * Exception thrown when accessing a tenant that does not exist. 5 | */ 6 | public class TenantNotFoundException extends RuntimeException { 7 | 8 | /** 9 | * Constructor with tenant name 10 | * 11 | * @param tenantName 12 | * tenant name 13 | */ 14 | public TenantNotFoundException(String tenantName) { 15 | super("Tenant '" + tenantName + "' has not been found."); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** Exceptions for Astra Streaming Service. */ 2 | package com.dtsx.astra.sdk.streaming.exception; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/package-info.java: -------------------------------------------------------------------------------- 1 | /** Sub Clients relative to Astra Streaming Service and Providers for Pulsar admin and client. */ 2 | package com.dtsx.astra.sdk.streaming; -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiError.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.utils; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * Bean to old devops errors 7 | */ 8 | public class ApiError { 9 | 10 | /** 11 | * Error code devops API 12 | */ 13 | @JsonProperty("ID") 14 | private Integer id; 15 | 16 | /** 17 | * Error message Devops API 18 | */ 19 | private String message; 20 | 21 | /** 22 | * Error constructor 23 | */ 24 | public ApiError() { 25 | } 26 | 27 | /** 28 | * Gets id 29 | * 30 | * @return value of id 31 | */ 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | /** 37 | * Set value for id 38 | * 39 | * @param id new value for id 40 | */ 41 | public void setId(Integer id) { 42 | this.id = id; 43 | } 44 | 45 | /** 46 | * Gets message 47 | * 48 | * @return value of message 49 | */ 50 | public String getMessage() { 51 | return message; 52 | } 53 | 54 | /** 55 | * Set value for message 56 | * 57 | * @param message new value for message 58 | */ 59 | public void setMessage(String message) { 60 | this.message = message; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/ApiResponseError.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.utils; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Hold response. 7 | */ 8 | public class ApiResponseError { 9 | 10 | /** 11 | * Errors. 12 | */ 13 | private List errors; 14 | 15 | /** 16 | * Response Errors 17 | */ 18 | public ApiResponseError() {} 19 | 20 | /** 21 | * Gets errors 22 | * 23 | * @return value of errors 24 | */ 25 | public List getErrors() { 26 | return errors; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/IdUtils.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.utils; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Utilities to work with ids 7 | */ 8 | public class IdUtils { 9 | 10 | /** Hide constructor. */ 11 | private IdUtils() {} 12 | 13 | /** 14 | * Check if it is uuid. 15 | * 16 | * @param uuid 17 | * unique identifier 18 | * @return 19 | * check if this is uuid 20 | */ 21 | public static boolean isUUID(String uuid) { 22 | try { 23 | UUID.fromString(uuid); 24 | } catch(IllegalArgumentException ieox) { 25 | return false; 26 | } 27 | return true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** Utility Classes for devops. */ 2 | package com.dtsx.astra.sdk.utils; -------------------------------------------------------------------------------- /astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/AstraStreamingClientTest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming; 2 | 3 | import com.dtsx.astra.sdk.AbstractDevopsApiTest; 4 | import com.dtsx.astra.sdk.streaming.domain.Tenant; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; 7 | import org.junit.jupiter.api.Order; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.TestMethodOrder; 10 | 11 | import java.util.Set; 12 | import java.util.stream.Collectors; 13 | 14 | @TestMethodOrder(OrderAnnotation.class) 15 | public class AstraStreamingClientTest extends AbstractDevopsApiTest { 16 | 17 | @Test 18 | @Order(1) 19 | public void shouldFailInvalidParams() { 20 | Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraStreamingClient("")); 21 | Assertions.assertThrows(IllegalArgumentException.class, () -> new AstraStreamingClient((String) null)); 22 | } 23 | 24 | @Test 25 | @Order(2) 26 | public void shouldFindAllTenant() { 27 | // Given 28 | AstraStreamingClient cli = new AstraStreamingClient(getToken()); 29 | // When 30 | Set tenants = cli.findAll() 31 | .map(Tenant::getTenantName) 32 | .collect(Collectors.toSet()); 33 | // Then 34 | Assertions.assertNotNull(tenants); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/ProvidersClientTest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming; 2 | 3 | import com.dtsx.astra.sdk.AbstractDevopsApiTest; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.MethodOrderer; 7 | import org.junit.jupiter.api.Order; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.TestMethodOrder; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 15 | public class ProvidersClientTest extends AbstractDevopsApiTest { 16 | 17 | @Test 18 | @Order(1) 19 | @DisplayName("Find all providers for an Organization") 20 | public void shouldFindAllProviders() { 21 | // Given 22 | AstraStreamingClient cli = new AstraStreamingClient(getToken()); 23 | // When 24 | Map> providers = cli.providers().findAll(); 25 | // Then 26 | Assertions.assertNotNull(providers); 27 | Assertions.assertTrue(providers.containsKey("gcp")); 28 | Assertions.assertTrue(providers.get("gcp").contains("useast1")); 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/test/java/com/dtsx/astra/sdk/streaming/RegionClientTest.java: -------------------------------------------------------------------------------- 1 | package com.dtsx.astra.sdk.streaming; 2 | 3 | import com.dtsx.astra.sdk.AbstractDevopsApiTest; 4 | import com.dtsx.astra.sdk.streaming.domain.StreamingRegion; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.DisplayName; 7 | import org.junit.jupiter.api.MethodOrderer; 8 | import org.junit.jupiter.api.Order; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.TestMethodOrder; 11 | 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | 15 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 16 | public class RegionClientTest extends AbstractDevopsApiTest { 17 | 18 | @Test 19 | @Order(1) 20 | @DisplayName("Find all regions for an Organization") 21 | public void shouldFindAllRegions() { 22 | // Given 23 | RegionsClient cli = new AstraStreamingClient(getToken()).regions(); 24 | // When 25 | List regions = cli 26 | .findAllServerless() 27 | .map(StreamingRegion::getName) 28 | .collect(Collectors.toList()); 29 | // Then 30 | Assertions.assertNotNull(regions); 31 | Assertions.assertTrue(regions.contains("useast1")); 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /astra-sdk-devops/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %magenta(%-5level) %cyan(%-47logger) : %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | astra-db-java-examples 6 | Data API Client Samples 7 | 8 | 9 | com.datastax.astra 10 | astra-db-java-parent 11 | 2.0.0 12 | 13 | 14 | 15 | 16 | com.datastax.astra 17 | astra-db-java 18 | ${project.version} 19 | 20 | 21 | ch.qos.logback 22 | logback-classic 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/ConnectingAdmin.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client; 2 | 3 | 4 | import com.datastax.astra.client.admin.AstraDBAdmin; 5 | 6 | import static com.dtsx.astra.sdk.db.domain.CloudProviderType.GCP; 7 | 8 | public class ConnectingAdmin { 9 | public static void main(String[] args) { 10 | // Default Initialization 11 | DataAPIClient client = new DataAPIClient("TOKEN"); 12 | 13 | // Accessing admin providing a new token possibly with stronger permissions 14 | AstraDBAdmin astradbAdmin = client.getAdmin("SUPER_USER_TOKEN"); 15 | 16 | // Create a Database 17 | astradbAdmin.createDatabase("db-demo", GCP, "us-east-1").listKeyspaceNames(); 18 | } 19 | } -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/DataApiClientDemo.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client; 2 | 3 | import com.datastax.astra.client.admin.AstraDBAdmin; 4 | import com.datastax.astra.client.collections.Collection; 5 | import com.datastax.astra.client.collections.definition.CollectionDefinition; 6 | import com.datastax.astra.client.collections.definition.documents.Document; 7 | import com.datastax.astra.client.databases.Database; 8 | import com.datastax.astra.client.databases.DatabaseOptions; 9 | 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | import static com.datastax.astra.client.core.vector.SimilarityMetric.COSINE; 14 | 15 | public class DataApiClientDemo { 16 | public static void main(String[] args) { 17 | DataAPIClient client = new DataAPIClient("TOKEN"); 18 | Database database0 = client.getDatabase("API_ENDPOINT"); 19 | Collection collection0 = database0.createCollection("movies", 20 | new CollectionDefinition().vector(2, COSINE)); 21 | collection0.insertOne(new Document().append("title", "The Title").vector(new float[]{1.0f, 1.0f})); 22 | Database database1 = client.getDatabase(UUID.fromString("01234567-...")); 23 | Database database2 = client.getDatabase(UUID.fromString("01234567-..."), "us-east1", 24 | new DatabaseOptions().keyspace("*KEYSPACE*")); 25 | AstraDBAdmin admin1 = client.getAdmin(); 26 | AstraDBAdmin admin2 = client.getAdmin("more_powerful_token_override"); 27 | List databases = admin1.listDatabaseNames(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/admin/CreateDatabase.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.dtsx.astra.sdk.db.domain.CloudProviderType; 5 | 6 | public class CreateDatabase { 7 | public static void main(String[] args) { 8 | AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin(); 9 | 10 | // Choose a cloud provider (GCP, AZURE, AWS) and a region 11 | CloudProviderType cloudProvider = CloudProviderType.GCP; 12 | String cloudRegion = "us-east1"; 13 | 14 | // Create a database 15 | DatabaseAdmin admin = astraDBAdmin.createDatabase("DATABASE_NAME", cloudProvider, cloudRegion); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/admin/DropDatabase.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | 5 | import java.util.UUID; 6 | 7 | public class DropDatabase { 8 | public static void main(String[] args) { 9 | AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin(); 10 | 11 | // Delete an existing database 12 | astraDBAdmin.dropDatabase(""); 13 | 14 | // Delete an existing database by ID 15 | astraDBAdmin.dropDatabase(UUID.fromString("")); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/admin/GetDatabaseInformation.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.definition.DatabaseInfo; 5 | 6 | import java.util.UUID; 7 | 8 | public class GetDatabaseInformation { 9 | public static void main(String[] args) { 10 | 11 | AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin(); 12 | 13 | // Check if a database exists 14 | boolean exists1 = astraDBAdmin.databaseExists("database_name"); 15 | boolean exists2 = astraDBAdmin.databaseExists(UUID.fromString("")); 16 | 17 | // Find a database by name (names may not be unique) 18 | DatabaseInfo databaseInformation = astraDBAdmin 19 | .getDatabaseInfo(UUID.fromString("")); 20 | System.out.println("Name=" + databaseInformation.getName()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/admin/ListDatabases.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.definition.DatabaseInfo; 5 | 6 | public class ListDatabases { 7 | public static void main(String[] args) { 8 | 9 | // Initialization of admin (astra only) 10 | AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin(); 11 | 12 | // Display all database information 13 | astraDBAdmin.listDatabases().stream() 14 | .map(DatabaseInfo::getId) 15 | .forEach(System.out::println); 16 | 17 | // Display all database names 18 | astraDBAdmin.listDatabaseNames(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/ClearCollection.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.databases.Database; 6 | 7 | public class ClearCollection { 8 | public static void main(String[] args) { 9 | // Connect to running dn 10 | Database db = new DataAPIClient("TOKEN") 11 | .getDatabase("API_ENDPOINT"); 12 | 13 | // Accessing the collection 14 | Collection collection = db.getCollection("collection_simple"); 15 | 16 | // Delete all rows from an existing collection 17 | collection.deleteAll(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/CountDocuments.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.collections.exceptions.TooManyDocumentsToCountException; 6 | import com.datastax.astra.client.core.query.Filter; 7 | import com.datastax.astra.client.core.query.Filters; 8 | 9 | import static com.datastax.astra.client.core.query.Filters.lt; 10 | 11 | public class CountDocuments { 12 | public static void main(String[] args) { 13 | Collection collection = new DataAPIClient("TOKEN") 14 | .getDatabase("API_ENDPOINT") 15 | .getCollection("COLLECTION_NAME"); 16 | 17 | // Building a filter 18 | Filter filter = Filters.and( 19 | Filters.gt("field2", 10), 20 | lt("field3", 20), 21 | Filters.eq("field4", "value")); 22 | 23 | try { 24 | // Count with no filter 25 | collection.countDocuments(500); 26 | 27 | // Count with a filter 28 | collection.countDocuments(filter, 500); 29 | 30 | } catch(TooManyDocumentsToCountException tmde) { 31 | // Explicit error if the count is above the upper limit or above the 1000 limit 32 | } 33 | 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/DeleteAll.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.commands.results.CollectionDeleteResult; 5 | import com.datastax.astra.client.collections.definition.documents.Document; 6 | 7 | public class DeleteAll { 8 | public static void main(String[] args) { 9 | Collection collection = new DataAPIClient("TOKEN") 10 | .getDatabase("API_ENDPOINT") 11 | .getCollection("COLLECTION_NAME"); 12 | 13 | // Show the deleted count 14 | CollectionDeleteResult result = collection.deleteAll(); 15 | System.out.println("Deleted Count:" + result.getDeletedCount()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/DeleteMany.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.commands.results.CollectionDeleteResult; 5 | import com.datastax.astra.client.collections.definition.documents.Document; 6 | import com.datastax.astra.client.core.query.Filter; 7 | import com.datastax.astra.client.core.query.Filters; 8 | 9 | import static com.datastax.astra.client.core.query.Filters.lt; 10 | 11 | public class DeleteMany { 12 | public static void main(String[] args) { 13 | Collection collection = new DataAPIClient("TOKEN") 14 | .getDatabase("API_ENDPOINT") 15 | .getCollection("COLLECTION_NAME"); 16 | 17 | // Sample Filter 18 | Filter filter = Filters.and( 19 | Filters.gt("field2", 10), 20 | lt("field3", 20), 21 | Filters.eq("field4", "value")); 22 | CollectionDeleteResult result = collection.deleteMany(filter); 23 | System.out.println("Deleted Count:" + result.getDeletedCount()); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/DeleteOne.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.collections.commands.options.CollectionDeleteOneOptions; 6 | import com.datastax.astra.client.collections.commands.results.CollectionDeleteResult; 7 | import com.datastax.astra.client.core.query.Filter; 8 | import com.datastax.astra.client.core.query.Filters; 9 | import com.datastax.astra.client.core.query.Sort; 10 | 11 | import static com.datastax.astra.client.core.query.Filters.lt; 12 | 13 | public class DeleteOne { 14 | public static void main(String[] args) { 15 | Collection collection = new DataAPIClient("TOKEN") 16 | .getDatabase("API_ENDPOINT") 17 | .getCollection("COLLECTION_NAME"); 18 | 19 | // Sample Filter 20 | Filter filter = Filters.and( 21 | Filters.gt("field2", 10), 22 | lt("field3", 20), 23 | Filters.eq("field4", "value")); 24 | 25 | // Delete one options 26 | CollectionDeleteOneOptions options = new CollectionDeleteOneOptions() 27 | .sort(Sort.ascending("field2")); 28 | CollectionDeleteResult result = collection.deleteOne(filter, options); 29 | System.out.println("Deleted Count:" + result.getDeletedCount()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/Distinct.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.core.query.Filter; 6 | import com.datastax.astra.client.core.query.Filters; 7 | 8 | import java.util.Set; 9 | 10 | import static com.datastax.astra.client.core.query.Filters.lt; 11 | 12 | public class Distinct { 13 | public static void main(String[] args) { 14 | // Given an existing collection 15 | Collection collection = new DataAPIClient("TOKEN") 16 | .getDatabase("API_ENDPOINT") 17 | .getCollection("COLLECTION_NAME"); 18 | 19 | // Building a filter 20 | Filter filter = Filters.and( 21 | Filters.gt("field2", 10), 22 | lt("field3", 20), 23 | Filters.eq("field4", "value")); 24 | 25 | // Execute a find operation 26 | Set result = collection.distinct("field", String.class); 27 | Set result2 = collection.distinct("field", filter, String.class); 28 | 29 | // Iterate over the result 30 | for (String fieldValue : result) { 31 | System.out.println(fieldValue); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/EstimateCountDocuments.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.commands.options.EstimatedCountDocumentsOptions; 5 | import com.datastax.astra.client.collections.definition.documents.Document; 6 | import com.datastax.astra.internal.command.LoggingCommandObserver; 7 | 8 | public class EstimateCountDocuments { 9 | 10 | public static void main(String[] args) { 11 | Collection collection = new DataAPIClient("TOKEN") 12 | .getDatabase("API_ENDPOINT") 13 | .getCollection("COLLECTION_NAME"); 14 | 15 | // Count with no filter 16 | long estimatedCount = collection.estimatedDocumentCount(); 17 | 18 | // Count with options (adding a logger) 19 | EstimatedCountDocumentsOptions options = new EstimatedCountDocumentsOptions() 20 | .registerObserver("logger", new LoggingCommandObserver(DataAPIClient.class)); 21 | long estimateCount2 = collection.estimatedDocumentCount(options); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/FindOneAndDelete.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.core.query.Filter; 6 | import com.datastax.astra.client.core.query.Filters; 7 | 8 | import java.util.Optional; 9 | 10 | import static com.datastax.astra.client.core.query.Filters.lt; 11 | 12 | public class FindOneAndDelete { 13 | public static void main(String[] args) { 14 | Collection collection = new DataAPIClient("TOKEN") 15 | .getDatabase("API_ENDPOINT") 16 | .getCollection("COLLECTION_NAME"); 17 | 18 | // Building a filter 19 | Filter filter = Filters.and( 20 | Filters.gt("field2", 10), 21 | lt("field3", 20), 22 | Filters.eq("field4", "value")); 23 | 24 | // It will return the document before deleting it 25 | Optional docBeforeRelease = collection.findOneAndDelete(filter); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/FindOneAndUpdate.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.collections.commands.Update; 6 | import com.datastax.astra.client.collections.commands.Updates; 7 | import com.datastax.astra.client.core.query.Filter; 8 | import com.datastax.astra.client.core.query.Filters; 9 | 10 | import java.util.Optional; 11 | 12 | import static com.datastax.astra.client.core.query.Filters.lt; 13 | 14 | 15 | public class FindOneAndUpdate { 16 | public static void main(String[] args) { 17 | // Given an existing collection 18 | Collection collection = new DataAPIClient("TOKEN") 19 | .getDatabase("API_ENDPOINT") 20 | .getCollection("COLLECTION_NAME"); 21 | 22 | // Building a filter 23 | Filter filter = Filters.and( 24 | Filters.gt("field2", 10), 25 | lt("field3", 20), 26 | Filters.eq("field4", "value")); 27 | 28 | // Building the update 29 | Update update = Updates.set("field1", "value1") 30 | .inc("field2", 1d) 31 | .unset("field3"); 32 | 33 | Optional doc = collection.findOneAndUpdate(filter, update); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/UpdateOne.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.commands.results.CollectionUpdateResult; 5 | import com.datastax.astra.client.collections.definition.documents.Document; 6 | import com.datastax.astra.client.collections.commands.Update; 7 | import com.datastax.astra.client.collections.commands.Updates; 8 | import com.datastax.astra.client.core.query.Filter; 9 | import com.datastax.astra.client.core.query.Filters; 10 | 11 | import static com.datastax.astra.client.core.query.Filters.lt; 12 | 13 | 14 | public class UpdateOne { 15 | // Given an existing collection 16 | Collection collection = new DataAPIClient("TOKEN") 17 | .getDatabase("API_ENDPOINT") 18 | .getCollection("COLLECTION_NAME"); 19 | 20 | // Building a filter 21 | Filter filter = Filters.and( 22 | Filters.gt("field2", 10), 23 | lt("field3", 20), 24 | Filters.eq("field4", "value")); 25 | 26 | // Building the update 27 | Update update = Updates.set("field1", "value1") 28 | .inc("field2", 1d) 29 | .unset("field3"); 30 | 31 | CollectionUpdateResult result = collection.updateOne(filter, update); 32 | } 33 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/collections/WorkingWithSorts.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.collections; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.documents.Document; 5 | import com.datastax.astra.client.collections.commands.options.CollectionFindOptions; 6 | import com.datastax.astra.client.core.query.Sort; 7 | 8 | public class WorkingWithSorts { 9 | public static void main(String[] args) { 10 | // Given an existing collection 11 | Collection collection = new DataAPIClient("TOKEN") 12 | .getDatabase("API_ENDPOINT") 13 | .getCollection("COLLECTION_NAME"); 14 | 15 | // Sort Clause for a vector 16 | Sort.vector(new float[] {0.25f, 0.25f, 0.25f,0.25f, 0.25f});; 17 | 18 | // Sort Clause for other fields 19 | Sort s1 = Sort.ascending("field1"); 20 | Sort s2 = Sort.descending("field2"); 21 | 22 | // Build the sort clause 23 | new CollectionFindOptions().sort(s1, s2); 24 | 25 | // Adding vector 26 | new CollectionFindOptions().sort( 27 | Sort.vector(new float[] {0.25f, 0.25f, 0.25f,0.25f, 0.25f}), s1, s2); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/AlterTableAddColumn.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Table; 6 | import com.datastax.astra.client.tables.commands.AlterTableAddColumns; 7 | import com.datastax.astra.client.tables.definition.rows.Row; 8 | 9 | public class AlterTableAddColumn { 10 | 11 | public static void main(String[] args) { 12 | // Database db = new DataAPIClient(token).getDatabase(endpoint); 13 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 14 | Table myTable1 = db.getTable("games"); 15 | 16 | // Add A Columns 17 | AlterTableAddColumns add = new AlterTableAddColumns() 18 | .addColumnBoolean("tie_break") 19 | .addColumnText("venue"); 20 | myTable1.alter(add); 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/AlterTableAddVectorizes.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.core.vectorize.VectorServiceOptions; 5 | import com.datastax.astra.client.databases.Database; 6 | import com.datastax.astra.client.tables.Table; 7 | import com.datastax.astra.client.tables.commands.AlterTableAddVectorize; 8 | import com.datastax.astra.client.tables.definition.rows.Row; 9 | 10 | import java.util.Map; 11 | 12 | public class AlterTableAddVectorizes { 13 | 14 | public static void main(String[] args) { 15 | // Database db = new DataAPIClient(token).getDatabase(endpoint); 16 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 17 | Table myTable1 = db.getTable("games"); 18 | 19 | AlterTableAddVectorize addVectorize = 20 | new AlterTableAddVectorize().columns( 21 | Map.of("m_vector", new VectorServiceOptions() 22 | .modelName("text-embedding-3-small") 23 | .provider("openai").authentication( 24 | Map.of("providerKey", "ASTRA_KMS_API_KEY_NAME") 25 | )) 26 | ); 27 | myTable1.alter(addVectorize); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/AlterTableDropColumn.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Table; 6 | import com.datastax.astra.client.tables.commands.AlterTableAddColumns; 7 | import com.datastax.astra.client.tables.commands.AlterTableDropColumns; 8 | import com.datastax.astra.client.tables.definition.rows.Row; 9 | 10 | public class AlterTableDropColumn { 11 | 12 | public static void main(String[] args) { 13 | // Database db = new DataAPIClient(token).getDatabase(endpoint); 14 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 15 | Table myTable1 = db.getTable("games"); 16 | 17 | // Add A Columns 18 | AlterTableDropColumns dropColumn = new AlterTableDropColumns("tie_break"); 19 | myTable1.alter(dropColumn); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/AlterTableDropVectorizes.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Table; 6 | import com.datastax.astra.client.tables.commands.AlterTableDropColumns; 7 | import com.datastax.astra.client.tables.commands.AlterTableDropVectorize; 8 | import com.datastax.astra.client.tables.definition.rows.Row; 9 | 10 | public class AlterTableDropVectorizes { 11 | 12 | public static void main(String[] args) { 13 | // Database db = new DataAPIClient(token).getDatabase(endpoint); 14 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 15 | Table myTable1 = db.getTable("games"); 16 | 17 | // Add A Columns 18 | AlterTableDropVectorize dropVectorize = new AlterTableDropVectorize("m_vector"); 19 | myTable1.alter(dropVectorize); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/CreateTableOM.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.GameWithAnnotation; 6 | import com.datastax.astra.client.tables.GameWithAnnotationAllHints; 7 | import com.datastax.astra.client.tables.Table; 8 | 9 | import static com.datastax.astra.client.tables.commands.options.DropTableOptions.IF_EXISTS; 10 | 11 | public class CreateTableOM { 12 | 13 | public static void main(String[] args) { 14 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 15 | 16 | db.dropTable(db.getTableName(GameWithAnnotationAllHints.class), IF_EXISTS); 17 | db.dropTable(db.getTableName(GameWithAnnotation.class), IF_EXISTS); 18 | 19 | // Creation with a fully annotated bean 20 | Table table1 = db.createTable(GameWithAnnotationAllHints.class); 21 | 22 | // Minimal creation 23 | Table table2 = db.createTable(GameWithAnnotation.class); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/DropCollection.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.collections.commands.options.DropCollectionOptions; 6 | 7 | public class DropCollection { 8 | public static void main(String[] args) { 9 | Database db = new DataAPIClient("TOKEN") 10 | .getDatabase("API_ENDPOINT"); 11 | 12 | // Delete an existing collection 13 | DropCollectionOptions options = new DropCollectionOptions(); 14 | db.dropCollection("collection_vector2", options); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/DropTable.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.commands.options.DropTableOptions; 6 | 7 | import static com.datastax.astra.client.core.query.Sort.ascending; 8 | import static java.time.Duration.ofSeconds; 9 | 10 | public class DropTable { 11 | 12 | public static void main(String[] args) { 13 | // Database astraDb = new DataAPIClient(token).getDatabase(endpoint); 14 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 15 | 16 | // Drop without options 17 | db.dropTable("games"); 18 | 19 | // Adding a timestamp 20 | DropTableOptions options = new DropTableOptions() 21 | .ifExists(false) 22 | .timeout(ofSeconds(5)); 23 | db.dropTable("games", options); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/DropTableIndex.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.commands.options.DropTableIndexOptions; 6 | import com.datastax.astra.client.tables.commands.options.DropTableOptions; 7 | 8 | import static java.time.Duration.ofSeconds; 9 | 10 | public class DropTableIndex { 11 | 12 | public static void main(String[] args) { 13 | // Database astraDb = new DataAPIClient(token).getDatabase(endpoint); 14 | Database db = DataAPIClients.localDbWithDefaultKeyspace(); 15 | 16 | // Drop without options 17 | db.dropTableIndex("games"); 18 | 19 | // Adding a timestamp 20 | DropTableIndexOptions options = new DropTableIndexOptions() 21 | .ifExists(false) 22 | .keyspace("KEYSPACE_NAME") 23 | .timeout(ofSeconds(5)); 24 | db.dropTableIndex("games", options); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/FindCollection.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.Collection; 5 | import com.datastax.astra.client.collections.definition.CollectionDefinition; 6 | import com.datastax.astra.client.collections.definition.documents.Document; 7 | import com.datastax.astra.client.databases.Database; 8 | 9 | public class FindCollection { 10 | public static void main(String[] args) { 11 | Database db = new DataAPIClient("TOKEN") 12 | .getDatabase("API_ENDPOINT"); 13 | 14 | // Find a collection 15 | Collection collection = db.getCollection("collection_vector1"); 16 | 17 | // Gather collection information 18 | CollectionDefinition options = collection.getDefinition(); 19 | 20 | // Check if a collection exists 21 | boolean collectionExists = db.getCollection("collection_vector2").exists(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/GetTable.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Game; 6 | import com.datastax.astra.client.tables.Table; 7 | import com.datastax.astra.client.tables.TableOptions; 8 | import com.datastax.astra.client.tables.definition.rows.Row; 9 | 10 | import java.util.Map; 11 | 12 | public class GetTable { 13 | 14 | public static void main(String[] args) { 15 | // Database astraDb = new DataAPIClient(token).getDatabase(endpoint); 16 | Database db = 17 | DataAPIClients.localDbWithDefaultKeyspace(); 18 | 19 | // Default 20 | Table myTable1 = 21 | db.getTable("games"); 22 | 23 | // Options 24 | TableOptions options = new TableOptions() 25 | .keyspace("the_other_keyspace") 26 | .embeddingApiKey("secret-012abc...") 27 | .databaseAdditionalHeaders(Map.of("Feature-Flag-tables", "true")); 28 | Table myTable3 = db.getTable("games", options); 29 | 30 | // Typing 31 | Table myTable2 = 32 | db.getTable("games", Game.class); 33 | 34 | // Typing + Options 35 | Table myTable4 = 36 | db.getTable("games", Game.class, new TableOptions()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/ListCollections.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.collections.definition.CollectionDescriptor; 5 | import com.datastax.astra.client.databases.Database; 6 | 7 | import java.util.List; 8 | 9 | public class ListCollections { 10 | public static void main(String[] args) { 11 | Database db = new DataAPIClient("TOKEN") 12 | .getDatabase("API_ENDPOINT"); 13 | 14 | // Get collection Names 15 | List collectionNames = db.listCollectionNames(); 16 | 17 | // Get Collection information (with options) 18 | List collections = db.listCollections(); 19 | collections.stream().map(CollectionDescriptor::getOptions).forEach(System.out::println); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/ListTables.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Game; 6 | import com.datastax.astra.client.tables.Table; 7 | import com.datastax.astra.client.tables.TableOptions; 8 | import com.datastax.astra.client.tables.commands.options.ListTablesOptions; 9 | import com.datastax.astra.client.tables.definition.TableDefinition; 10 | import com.datastax.astra.client.tables.definition.TableDescriptor; 11 | import com.datastax.astra.client.tables.definition.rows.Row; 12 | 13 | import java.time.Duration; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class ListTables { 18 | 19 | public static void main(String[] args) { 20 | // Database astraDb = new DataAPIClient(token).getDatabase(endpoint); 21 | Database db = 22 | DataAPIClients.localDbWithDefaultKeyspace(); 23 | 24 | // Default 25 | List tableList = db.listTables(); 26 | 27 | // Options 28 | db.getDatabaseAdmin().createKeyspace("ks2"); 29 | ListTablesOptions options = new ListTablesOptions() 30 | .keyspace("ks2") 31 | .timeout(Duration.ofSeconds(5)); 32 | List tableList2 = db.listTables(options); 33 | Table ts = db.getTable("table_simple", new TableOptions().keyspace("ks2")); 34 | // Expecting an error as table does not exist in ks2 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database/ListTablesNames.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database; 2 | 3 | import com.datastax.astra.client.DataAPIClients; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.Table; 6 | import com.datastax.astra.client.tables.TableOptions; 7 | import com.datastax.astra.client.tables.commands.options.ListTablesOptions; 8 | import com.datastax.astra.client.tables.definition.TableDescriptor; 9 | import com.datastax.astra.client.tables.definition.rows.Row; 10 | 11 | import java.time.Duration; 12 | import java.util.List; 13 | 14 | public class ListTablesNames { 15 | 16 | public static void main(String[] args) { 17 | // Database astraDb = new DataAPIClient(token).getDatabase(endpoint); 18 | Database db = 19 | DataAPIClients.localDbWithDefaultKeyspace(); 20 | 21 | // Default 22 | List tableNames = db.listTableNames(); 23 | 24 | // Options 25 | db.getDatabaseAdmin().createKeyspace("ks2"); 26 | ListTablesOptions options = new ListTablesOptions() 27 | .keyspace("ks2") 28 | .timeout(Duration.ofSeconds(5)); 29 | List tableList2 = db.listTableNames(options); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database_admin/CreateKeyspace.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database_admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.databases.commands.options.CreateKeyspaceOptions; 6 | import com.datastax.astra.client.databases.definition.keyspaces.KeyspaceDefinition; 7 | 8 | public class CreateKeyspace { 9 | public static void main(String[] args) { 10 | // Default initialization 11 | Database db = new DataAPIClient("TOKEN").getDatabase("API_ENDPOINT"); 12 | 13 | // Create a new keyspace 14 | db.getDatabaseAdmin().createKeyspace(""); 15 | 16 | // The database can be mutate on keyspace creation 17 | db.getDatabaseAdmin().createKeyspace( 18 | new KeyspaceDefinition().name(""), 19 | new CreateKeyspaceOptions().updateDBKeyspace(true)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database_admin/DropKeyspace.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database_admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | 6 | public class DropKeyspace { 7 | 8 | public static void main(String[] args) { 9 | // Default initialization 10 | Database db = new DataAPIClient("TOKEN") 11 | .getDatabase("API_ENDPOINT"); 12 | // Drop a Namespace 13 | db.getDatabaseAdmin().dropKeyspace(""); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database_admin/GetDatabaseAdmin.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database_admin; 2 | 3 | 4 | import com.datastax.astra.client.DataAPIClient; 5 | import com.datastax.astra.client.admin.AstraDBAdmin; 6 | import com.datastax.astra.client.admin.DatabaseAdmin; 7 | 8 | import java.util.UUID; 9 | 10 | public class GetDatabaseAdmin { 11 | public static void main(String[] args) { 12 | // Default Initialization 13 | DataAPIClient client = new DataAPIClient("TOKEN"); 14 | 15 | // Accessing admin providing a new token possibly with stronger permissions 16 | AstraDBAdmin astradbAdmin = client.getAdmin("SUPER_USER_TOKEN"); 17 | 18 | DatabaseAdmin admin = astradbAdmin.getDatabaseAdmin(UUID.fromString("")); 19 | } 20 | } -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/database_admin/ListKeyspaces.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.database_admin; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.admin.AstraDBAdmin; 5 | import com.datastax.astra.client.admin.DatabaseAdmin; 6 | 7 | import java.util.Set; 8 | import java.util.UUID; 9 | 10 | public class ListKeyspaces { 11 | public static void main(String[] args) { 12 | 13 | DataAPIClient client = new DataAPIClient("TOKEN"); 14 | 15 | // Accessing admin providing a new token possibly with stronger permissions 16 | AstraDBAdmin admin = client.getAdmin("SUPER_USER_TOKEN"); 17 | 18 | DatabaseAdmin dbAdmin = admin.getDatabaseAdmin(UUID.fromString("DATABASE_ID")); 19 | 20 | // List available keyspaces 21 | Set names = dbAdmin.listKeyspaceNames(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/CreateIndex.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.commands.options.CreateIndexOptions; 6 | import com.datastax.astra.client.tables.definition.indexes.TableRegularIndexDefinition; 7 | import com.datastax.astra.client.tables.definition.rows.Row; 8 | 9 | import java.time.Duration; 10 | 11 | public class CreateIndex { 12 | public static void main(String[] args) { 13 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 14 | 15 | Table tableGames = db.getTable("games"); 16 | 17 | tableGames.createIndex("score_index","score"); 18 | 19 | TableRegularIndexDefinition definition = new TableRegularIndexDefinition() 20 | .column("winner") 21 | .ascii(true) // only text or ascii 22 | .caseSensitive(true) 23 | .normalize(true); 24 | 25 | CreateIndexOptions options = new CreateIndexOptions() 26 | .ifNotExists(true) 27 | .timeout(Duration.ofSeconds(2)); 28 | tableGames.createIndex("winner_index", definition, options); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/CreateVectorIndex.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.core.vector.SimilarityMetric; 5 | import com.datastax.astra.client.databases.Database; 6 | import com.datastax.astra.client.tables.commands.options.CreateVectorIndexOptions; 7 | import com.datastax.astra.client.tables.definition.indexes.TableVectorIndexDefinition; 8 | import com.datastax.astra.client.tables.definition.rows.Row; 9 | 10 | import java.time.Duration; 11 | 12 | public class CreateVectorIndex { 13 | public static void main(String[] args) { 14 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 15 | Table tableGames = db.getTable("games"); 16 | 17 | //tableGames.createVectorIndex("m_vector_index", "m_vector"); 18 | 19 | TableVectorIndexDefinition definition = new TableVectorIndexDefinition() 20 | .column("m_vector") 21 | .metric(SimilarityMetric.COSINE) 22 | .sourceModel("openai-v3-large"); 23 | 24 | CreateVectorIndexOptions options = new CreateVectorIndexOptions() 25 | .ifNotExists(true) 26 | .timeout(Duration.ofSeconds(2)); 27 | 28 | tableGames.createVectorIndex("m_vector_index", definition, options); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/DeleteMany.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.DataAPIClients; 5 | import com.datastax.astra.client.core.query.Filter; 6 | import com.datastax.astra.client.databases.Database; 7 | import com.datastax.astra.client.tables.commands.options.TableDeleteManyOptions; 8 | import com.datastax.astra.client.tables.commands.options.TableDeleteOneOptions; 9 | import com.datastax.astra.client.tables.definition.rows.Row; 10 | 11 | import static com.datastax.astra.client.core.query.Filters.and; 12 | import static com.datastax.astra.client.core.query.Filters.eq; 13 | import static com.datastax.astra.client.core.query.Filters.gte; 14 | 15 | public class DeleteMany { 16 | public static void main(String[] args) { 17 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 18 | 19 | Table tableRow = db.getTable("games"); 20 | 21 | // Update 22 | Filter filter = and( 23 | eq("match_id", "fight7"), 24 | eq("round", 2)); 25 | 26 | tableRow.deleteMany(filter); 27 | tableRow.deleteMany(filter, new TableDeleteManyOptions() 28 | .timeout(1000)); 29 | 30 | Filter filter2 = and( 31 | eq("match_id", "fight5"), 32 | gte("round", 5)); 33 | tableRow.deleteMany(filter2); 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/DeleteOne.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.DataAPIClients; 5 | import com.datastax.astra.client.core.query.Filter; 6 | import com.datastax.astra.client.databases.Database; 7 | import com.datastax.astra.client.tables.commands.TableUpdateOperation; 8 | import com.datastax.astra.client.tables.commands.options.TableDeleteOneOptions; 9 | import com.datastax.astra.client.tables.commands.options.TableUpdateOneOptions; 10 | import com.datastax.astra.client.tables.definition.rows.Row; 11 | 12 | import java.util.Set; 13 | 14 | import static com.datastax.astra.client.core.query.Filters.and; 15 | import static com.datastax.astra.client.core.query.Filters.eq; 16 | 17 | public class DeleteOne { 18 | public static void main(String[] args) { 19 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 20 | 21 | Table tableRow = db.getTable("games"); 22 | 23 | // Update 24 | Filter filter = and( 25 | eq("match_id", "fight7"), 26 | eq("round", 2)); 27 | 28 | tableRow.deleteOne(filter); 29 | tableRow.deleteOne(filter, new TableDeleteOneOptions() 30 | .timeout(1000)); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/Distinct.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.core.query.Filter; 5 | import com.datastax.astra.client.core.query.Filters; 6 | import com.datastax.astra.client.databases.Database; 7 | import com.datastax.astra.client.tables.commands.options.TableDistinctOptions; 8 | import com.datastax.astra.client.tables.commands.options.TableFindOptions; 9 | import com.datastax.astra.client.tables.definition.rows.Row; 10 | 11 | import java.util.List; 12 | 13 | import static com.datastax.astra.client.core.query.Filters.eq; 14 | import static com.datastax.astra.client.core.query.Projection.include; 15 | 16 | public class Distinct { 17 | public static void main(String[] args) { 18 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 19 | 20 | Table table = db.getTable("games"); 21 | 22 | // Show you all match id in the table 23 | List matches = table.find(null, new TableFindOptions() 24 | .projection(include("match_id"))).toList(); 25 | matches.forEach(System.out::println); 26 | 27 | Filter filter = Filters.eq("match_id", "challenge6"); 28 | 29 | TableDistinctOptions options = new TableDistinctOptions() 30 | .timeout(1000); 31 | // Show you the distinct match id in the table 32 | table.distinct("match_id", filter, String.class) 33 | .forEach(System.out::println); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/DropIndex.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.commands.options.DropTableIndexOptions; 6 | 7 | import java.time.Duration; 8 | 9 | public class DropIndex { 10 | public static void main(String[] args) { 11 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 12 | 13 | db.dropTableIndex("score_index"); 14 | 15 | DropTableIndexOptions options = new DropTableIndexOptions() 16 | .ifExists(true) 17 | .timeout(Duration.ofSeconds(5)); 18 | db.dropTableIndex("winner_index", options); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/GameWithAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.core.query.SortOrder; 4 | import com.datastax.astra.client.core.vector.DataAPIVector; 5 | import com.datastax.astra.client.core.vector.SimilarityMetric; 6 | import com.datastax.astra.client.tables.mapping.Column; 7 | import com.datastax.astra.client.tables.mapping.ColumnVector; 8 | import com.datastax.astra.client.tables.mapping.EntityTable; 9 | import com.datastax.astra.client.tables.mapping.PartitionBy; 10 | import com.datastax.astra.client.tables.mapping.PartitionSort; 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | 15 | import java.time.Instant; 16 | import java.util.Set; 17 | import java.util.UUID; 18 | 19 | @Data 20 | @EntityTable("game_ann2") 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class GameWithAnnotation { 24 | 25 | @PartitionBy(0) 26 | @Column(name ="match_id") 27 | private String matchId; 28 | 29 | @PartitionSort(position = 0, order = SortOrder.ASCENDING) 30 | private Integer round; 31 | 32 | private Integer score; 33 | 34 | private Instant when; 35 | 36 | private String winner; 37 | 38 | private Set fighters; 39 | 40 | @ColumnVector(name ="m_vector", dimension = 3, metric = SimilarityMetric.COSINE) 41 | private DataAPIVector vector; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/ListIndexes.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.databases.Database; 5 | import com.datastax.astra.client.tables.commands.options.ListIndexesOptions; 6 | import com.datastax.astra.client.tables.definition.rows.Row; 7 | 8 | import java.time.Duration; 9 | 10 | public class ListIndexes { 11 | public static void main(String[] args) { 12 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 13 | Table tableGames = db.getTable("games"); 14 | 15 | //List indexes = tableGames.listIndexes(); 16 | 17 | ListIndexesOptions options = new ListIndexesOptions() 18 | .timeout(Duration.ofSeconds(5)); 19 | 20 | tableGames.listIndexes(options).forEach(idx -> { 21 | System.out.println("Index: " + idx.getName() + " on column: " + idx.getDefinition().getColumn()); 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/src/main/java/com/datastax/astra/client/tables/ListIndexesNames.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.client.tables; 2 | 3 | import com.datastax.astra.client.DataAPIClient; 4 | import com.datastax.astra.client.DataAPIClients; 5 | import com.datastax.astra.client.databases.Database; 6 | import com.datastax.astra.client.tables.commands.options.ListIndexesOptions; 7 | import com.datastax.astra.client.tables.definition.rows.Row; 8 | 9 | import java.time.Duration; 10 | 11 | public class ListIndexesNames { 12 | public static void main(String[] args) { 13 | //Database db = new DataAPIClient("token").getDatabase("endpoint"); 14 | Database db = new DataAPIClient("token").getDatabase("endpoint"); 15 | Table tableGames = db.getTable("games"); 16 | 17 | //List indexesNames = tableGames.listIndexesNames(); 18 | 19 | ListIndexesOptions options = new ListIndexesOptions() 20 | .timeout(Duration.ofSeconds(5)); 21 | 22 | tableGames.listIndexesNames(options) 23 | .forEach(System.out::println); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %magenta(%-5level) %cyan(%-20logger) : %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/license/apache2/header.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 2 | You may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/license/licenses.properties: -------------------------------------------------------------------------------- 1 | apache2=Apache 2 -------------------------------------------------------------------------------- /langchain4j-astradb/src/main/java/com/datastax/astra/langchain4j/store/embedding/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of EmbeddingStore using AstraDB. 3 | */ 4 | package com.datastax.astra.langchain4j.store.embedding; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/main/java/com/datastax/astra/langchain4j/store/memory/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of ChatMemoryStore using AstraDB. 3 | */ 4 | package com.datastax.astra.langchain4j.store.memory; 5 | 6 | /*- 7 | * #%L 8 | * Data API Java Client 9 | * -- 10 | * Copyright (C) 2024 DataStax 11 | * -- 12 | * Licensed under the Apache License, Version 2.0 13 | * You may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/test/java/com/datastax/astra/langchain4j/Assistant.java: -------------------------------------------------------------------------------- 1 | package com.datastax.astra.langchain4j; 2 | 3 | public interface Assistant { 4 | 5 | String answer(String query); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %magenta(%-5level) %cyan(%-20logger) : %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /langchain4j-astradb/src/test/resources/shadow.txt: -------------------------------------------------------------------------------- 1 | Shadow, a sleek black Labrador with a shining coat and wise, deep-set eyes, lives in a quaint village surrounded by vast, rolling fields. Known for his loyalty and intelligence, Shadow belongs to Emily, a young veterinarian who adores him. One brisk autumn morning, Shadow discovers an abandoned litter of kittens in the old barn beside Emily's clinic. His protective instincts kick in, and he guards the kittens, refusing to leave their side until Emily finds him. 2 | Emily, moved by Shadow's compassion, takes the kittens into her care, but one little kitten is particularly frail. Shadow becomes a constant presence by the kitten's side, gently nudging it to eat and comforting it with his warmth. The villagers soon hear of Shadow's heroics, and his story spreads, warming the hearts of many and highlighting the unspoken bond between animals. 3 | As the seasons change, the kitten grows stronger under the vigilant care of Shadow and Emily. Shadow's story becomes a testament to loyalty and the nurturing spirit that animals can possess. His days are filled with adventures around the village, but he always returns to check on his now thriving feline friend. Shadow's life exemplifies that even in the smallest creatures, a big heart can be found. --------------------------------------------------------------------------------