Skip to content

Commit 73be9fa

Browse files
committed
doc
1 parent 0da617f commit 73be9fa

19 files changed

+415
-97
lines changed

pom.xml

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,35 @@
1717
<sonar.organization>clun-datastax</sonar.organization>
1818
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
1919

20-
<astra-sdk.version>0.7.3</astra-sdk.version>
20+
<astra-sdk.version>1.2.8-SNAPSHOT</astra-sdk.version>
21+
<astra-db-java.version>1.2.0</astra-db-java.version>
2122
<jansi.version>2.4.1</jansi.version>
22-
<airline.version>2.9.0</airline.version>
23-
<slf4j.version>2.0.9</slf4j.version>
23+
<airline.version>3.0.0</airline.version>
24+
<slf4j.version>2.0.13</slf4j.version>
2425
<httpclient.version>5.1.2</httpclient.version>
2526
<jackson-datatype.version>2.15.3</jackson-datatype.version>
26-
<commons-compress.version>1.25.0</commons-compress.version>
27+
<commons-compress.version>1.26.2</commons-compress.version>
2728
<!-- Junit -->
28-
<junit-jupiter.version>5.10.1</junit-jupiter.version>
29-
<awaitibility.version>4.2.0</awaitibility.version>
29+
<junit-jupiter.version>5.10.2</junit-jupiter.version>
30+
<awaitibility.version>4.2.1</awaitibility.version>
3031
<!-- Java -->
3132
<maven.plugin.compiler.source>17</maven.plugin.compiler.source>
3233
<maven.plugin.compiler.target>17</maven.plugin.compiler.target>
3334
<maven.plugin.javadoc.source>17</maven.plugin.javadoc.source>
3435
<!-- Maven -->
35-
<version.maven.plugin.assembly>3.6.0</version.maven.plugin.assembly>
36-
<version.maven.plugin.compiler>3.11.0</version.maven.plugin.compiler>
36+
<version.maven.plugin.assembly>3.7.1</version.maven.plugin.assembly>
37+
<version.maven.plugin.compiler>3.12.1</version.maven.plugin.compiler>
3738
<version.maven.plugin.coveralls>4.3.0</version.maven.plugin.coveralls>
3839
<version.maven.plugin.dependency>3.6.1</version.maven.plugin.dependency>
39-
<version.maven.plugin.exec>3.1.0</version.maven.plugin.exec>
40+
<version.maven.plugin.exec>3.3.0</version.maven.plugin.exec>
4041
<version.maven.plugin.jacoco>0.8.11</version.maven.plugin.jacoco>
4142
<version.maven.plugin.javadoc>3.6.0</version.maven.plugin.javadoc>
42-
<version.maven.plugin.jar>3.3.0</version.maven.plugin.jar>
43-
<version.maven.plugin.license>2.3.0</version.maven.plugin.license>
44-
<version.maven.plugin.native>0.9.28</version.maven.plugin.native>
43+
<version.maven.plugin.jar>3.4.1</version.maven.plugin.jar>
44+
<version.maven.plugin.license>2.4.0</version.maven.plugin.license>
45+
<version.maven.plugin.native>0.10.2</version.maven.plugin.native>
4546
<version.maven.plugin.release>3.0.1</version.maven.plugin.release>
4647
<version.maven.plugin.resources>3.3.1</version.maven.plugin.resources>
47-
<version.maven.plugin.shade>3.5.1</version.maven.plugin.shade>
48+
<version.maven.plugin.shade>3.5.3</version.maven.plugin.shade>
4849
<version.maven.plugin.surefire>3.2.5</version.maven.plugin.surefire>
4950
</properties>
5051

@@ -64,19 +65,13 @@
6465
<!-- Http client wrapping Calls -->
6566
<dependency>
6667
<groupId>com.datastax.astra</groupId>
67-
<artifactId>astra-db-client</artifactId>
68+
<artifactId>astra-sdk-devops</artifactId>
6869
<version>${astra-sdk.version}</version>
69-
<exclusions>
70-
<exclusion>
71-
<groupId>com.datastax.stargate</groupId>
72-
<artifactId>stargate-sdk-grpc</artifactId>
73-
</exclusion>
74-
75-
<exclusion>
76-
<groupId>ch.qos.logback</groupId>
77-
<artifactId>logback-classic</artifactId>
78-
</exclusion>
79-
</exclusions>
70+
</dependency>
71+
<dependency>
72+
<groupId>com.datastax.astra</groupId>
73+
<artifactId>astra-db-java</artifactId>
74+
<version>${astra-db-java.version}</version>
8075
</dependency>
8176

8277
<dependency>

src/main/dist/astra-init.sh

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ function _complete_astra_group_db_command_listcollections() {
13711371
COMMANDS=$1
13721372

13731373
FLAG_OPTS="--no-color -v --verbose"
1374-
ARG_OPTS="--token -cf --config-file -o -conf --env --config --output"
1374+
ARG_OPTS="--token -cf --config-file --keyspace -o -conf --env -k --config --output"
13751375

13761376
$( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
13771377
SAW_ARG=$?
@@ -1389,6 +1389,11 @@ function _complete_astra_group_db_command_listcollections() {
13891389
echo ${COMPREPLY[@]}
13901390
return 0
13911391
;;
1392+
-k|--keyspace)
1393+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1394+
echo ${COMPREPLY[@]}
1395+
return 0
1396+
;;
13921397
-conf|--config)
13931398
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
13941399
echo ${COMPREPLY[@]}
@@ -1421,7 +1426,7 @@ function _complete_astra_group_db_command_deletecollection() {
14211426
COMMANDS=$1
14221427

14231428
FLAG_OPTS="--no-color --async -v --verbose"
1424-
ARG_OPTS="--token -cf --config-file -o -c -conf --timeout --collection --env --config --output"
1429+
ARG_OPTS="--token --config-file --keyspace -o --timeout --config -cf -c -conf --collection --env -k --output"
14251430

14261431
$( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
14271432
SAW_ARG=$?
@@ -1439,6 +1444,11 @@ function _complete_astra_group_db_command_deletecollection() {
14391444
echo ${COMPREPLY[@]}
14401445
return 0
14411446
;;
1447+
-k|--keyspace)
1448+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1449+
echo ${COMPREPLY[@]}
1450+
return 0
1451+
;;
14421452
-conf|--config)
14431453
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
14441454
echo ${COMPREPLY[@]}
@@ -1481,7 +1491,7 @@ function _complete_astra_group_db_command_createcollection() {
14811491
COMMANDS=$1
14821492

14831493
FLAG_OPTS="--no-color --async -v --verbose"
1484-
ARG_OPTS="--token -m --config-file -o --metric --timeout --config -cf --dimension -c -d -conf --collection --env --output"
1494+
ARG_OPTS="--token -m --keyspace --config-file --indexing-allow -o --metric --embedding-model --default-id --timeout --config --indexing-deny -cf --dimension -c -d -conf --collection --embedding-provider --env -k --output"
14851495

14861496
$( containsElement ${PREV_WORD} ${ARG_OPTS[@]} )
14871497
SAW_ARG=$?
@@ -1494,7 +1504,12 @@ function _complete_astra_group_db_command_createcollection() {
14941504
echo ${COMPREPLY[@]}
14951505
return 0
14961506
;;
1497-
-cf|--config-file)
1507+
--indexing-allow)
1508+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1509+
echo ${COMPREPLY[@]}
1510+
return 0
1511+
;;
1512+
-k|--keyspace)
14981513
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
14991514
echo ${COMPREPLY[@]}
15001515
return 0
@@ -1504,12 +1519,17 @@ function _complete_astra_group_db_command_createcollection() {
15041519
echo ${COMPREPLY[@]}
15051520
return 0
15061521
;;
1522+
--embedding-model)
1523+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1524+
echo ${COMPREPLY[@]}
1525+
return 0
1526+
;;
15071527
-conf|--config)
15081528
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
15091529
echo ${COMPREPLY[@]}
15101530
return 0
15111531
;;
1512-
-c|--collection)
1532+
--default-id)
15131533
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
15141534
echo ${COMPREPLY[@]}
15151535
return 0
@@ -1524,6 +1544,26 @@ function _complete_astra_group_db_command_createcollection() {
15241544
echo ${COMPREPLY[@]}
15251545
return 0
15261546
;;
1547+
--indexing-deny)
1548+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1549+
echo ${COMPREPLY[@]}
1550+
return 0
1551+
;;
1552+
-cf|--config-file)
1553+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1554+
echo ${COMPREPLY[@]}
1555+
return 0
1556+
;;
1557+
-c|--collection)
1558+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1559+
echo ${COMPREPLY[@]}
1560+
return 0
1561+
;;
1562+
--embedding-provider)
1563+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
1564+
echo ${COMPREPLY[@]}
1565+
return 0
1566+
;;
15271567
--env)
15281568
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
15291569
echo ${COMPREPLY[@]}
@@ -2684,6 +2724,11 @@ function _complete_astra_group_db_command_createcdc() {
26842724
echo ${COMPREPLY[@]}
26852725
return 0
26862726
;;
2727+
-p, --partition)
2728+
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
2729+
echo ${COMPREPLY[@]}
2730+
return 0
2731+
;;
26872732
--table)
26882733
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
26892734
echo ${COMPREPLY[@]}

src/main/java/com/dtsx/astra/cli/AstraCli.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* #L%
2121
*/
2222

23+
import com.datastax.astra.client.exception.AuthenticationException;
2324
import com.dtsx.astra.cli.config.ConfigCreateCmd;
2425
import com.dtsx.astra.cli.config.ConfigDeleteCmd;
2526
import com.dtsx.astra.cli.config.ConfigDescribeCmd;
@@ -316,7 +317,7 @@ public static ExitCode run(Class<?> clazz, String[] args) {
316317
} catch(ParseException ex) {
317318
LoggerShell.exception(ex,"Command is not properly formatted.");
318319
return ExitCode.UNRECOGNIZED_COMMAND;
319-
} catch (InvalidTokenException | TokenNotFoundException |
320+
} catch (InvalidTokenException | TokenNotFoundException | AuthenticationException | com.dtsx.astra.sdk.exception.AuthenticationException |
320321
FileSystemException | ConfigurationException e) {
321322
AstraCliConsole.outputError(ExitCode.CONFIGURATION, e.getMessage());
322323
return ExitCode.CONFIGURATION;

src/main/java/com/dtsx/astra/cli/config/ConfigCreateCmd.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.github.rvesse.airline.annotations.Arguments;
3333
import com.github.rvesse.airline.annotations.Command;
3434
import com.github.rvesse.airline.annotations.Option;
35-
import com.github.rvesse.airline.annotations.restrictions.Required;
3635

3736
/**
3837
* Create a new section in configuration.
@@ -65,7 +64,7 @@ public void execute() {
6564
throw new InvalidTokenException(token);
6665
}
6766
// validate token at the same time
68-
AstraEnvironment targetEnv = AstraCliUtils.lookupEnvironment(env);
67+
AstraEnvironment targetEnv = AstraCliUtils.parseEnvironment(env);
6968
Organization o = new AstraOpsClient(token, targetEnv).getOrganization();
7069
if (sectionName == null) {
7170
sectionName = o.getName();

src/main/java/com/dtsx/astra/cli/config/SetupCmd.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
import com.dtsx.astra.cli.core.out.LoggerShell;
2727
import com.dtsx.astra.cli.utils.AstraCliUtils;
2828
import com.dtsx.astra.sdk.AstraOpsClient;
29-
import com.dtsx.astra.sdk.org.domain.Organization;
3029
import com.dtsx.astra.sdk.utils.AstraEnvironment;
31-
import com.dtsx.astra.sdk.utils.AstraRc;
3230
import com.github.rvesse.airline.annotations.Command;
3331
import com.github.rvesse.airline.annotations.Option;
3432

@@ -61,7 +59,7 @@ public class SetupCmd extends AbstractCmd {
6159
/** {@inheritDoc} */
6260
@Override
6361
public void execute() {
64-
AstraEnvironment targetEnv = AstraCliUtils.lookupEnvironment(env);
62+
AstraEnvironment targetEnv = AstraCliUtils.parseEnvironment(env);
6563
// As not token is provided we ask for it in the console
6664
if (token == null || token.isBlank()) {
6765
verbose = true;

src/main/java/com/dtsx/astra/cli/core/AbstractConnectedCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
import com.dtsx.astra.cli.config.AstraCliConfiguration;
2424
import com.dtsx.astra.cli.core.out.OutputFormat;
2525
import com.dtsx.astra.cli.utils.AstraCliUtils;
26-
import com.dtsx.astra.sdk.utils.AstraEnvironment;
2726
import com.github.rvesse.airline.annotations.Option;
28-
import com.github.rvesse.airline.parser.errors.ParseRestrictionViolatedException;
2927

30-
import java.util.Arrays;
31-
import java.util.List;
3228
import java.util.Locale;
3329

3430
/**
@@ -63,7 +59,7 @@ public void run() {
6359
validateOptions();
6460

6561
ctx().init(new CoreOptions(verbose, noColor, OutputFormat.valueOf(output.toUpperCase(Locale.ROOT)), configFilename));
66-
ctx().initToken(new TokenOptions(token, configSectionName, AstraCliUtils.lookupEnvironment(env)));
62+
ctx().initToken(new TokenOptions(token, configSectionName, AstraCliUtils.parseEnvironment(env)));
6763
execute();
6864
}
6965

src/main/java/com/dtsx/astra/cli/core/CliContext.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* #L%
2121
*/
2222

23+
import com.datastax.astra.client.DataAPIClient;
24+
import com.datastax.astra.client.DataAPIOptions;
2325
import com.dtsx.astra.cli.config.AstraCliConfiguration;
2426
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
2527
import com.dtsx.astra.cli.core.exception.TokenNotFoundException;
@@ -82,6 +84,9 @@ public static synchronized CliContext getInstance() {
8284
/** Single for Ops Client. */
8385
private AstraOpsClient devopsApiClient;
8486

87+
/** Singleton for Data API Client. */
88+
private DataAPIClient dataAPIClient;
89+
8590
/**
8691
* Should initialize the client based on provided parameters.
8792
*
@@ -240,6 +245,36 @@ public AstraOpsClient getApiDevops() {
240245
return devopsApiClient;
241246
}
242247

248+
/**
249+
* Initializing and Retrieving the Data API Client for vector Operations.
250+
*
251+
* @return
252+
* instance od DataAPIClient for current configuration
253+
*/
254+
public DataAPIClient getDataAPIClient() {
255+
if (dataAPIClient == null) {
256+
dataAPIClient = new DataAPIClient(getToken(),
257+
DataAPIOptions.builder()
258+
.withDestination(getDestination())
259+
.build());
260+
}
261+
return dataAPIClient;
262+
}
263+
264+
/**
265+
* Mapping for AstraEnvironment to DataApiDestination which is broader to work with DSE.
266+
*
267+
* @return
268+
* destination for the data api
269+
*/
270+
private DataAPIOptions.DataAPIDestination getDestination() {
271+
return switch (getAstraEnvironment()) {
272+
case DEV -> DataAPIOptions.DataAPIDestination.ASTRA_DEV;
273+
case TEST -> DataAPIOptions.DataAPIDestination.ASTRA_TEST;
274+
default -> DataAPIOptions.DataAPIDestination.ASTRA;
275+
};
276+
}
277+
243278
/**
244279
* Validate a token for a target environment.
245280
*

src/main/java/com/dtsx/astra/cli/core/exception/InvalidRegionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class InvalidRegionException extends InvalidArgumentException {
3939
* current region
4040
*/
4141
public InvalidRegionException(String cloud, String region) {
42-
super(String.format("Region '%s' is valid for cloud '%s'.", region, cloud));
42+
super(String.format("Region '%s' is invalid for the cloud '%s'.", region, cloud));
4343
}
4444

4545
/**

src/main/java/com/dtsx/astra/cli/db/DaoDatabase.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
* limitations under the License.
2020
* #L%
2121
*/
22-
22+
import com.datastax.astra.client.admin.AstraDBAdmin;
2323
import com.dtsx.astra.cli.core.CliContext;
2424
import com.dtsx.astra.cli.core.exception.InvalidArgumentException;
2525
import com.dtsx.astra.cli.core.out.LoggerShell;
2626
import com.dtsx.astra.cli.db.exception.DatabaseNameNotUniqueException;
2727
import com.dtsx.astra.cli.utils.AstraCliUtils;
2828
import com.dtsx.astra.cli.utils.FileUtils;
29-
import com.dtsx.astra.sdk.AstraDB;
30-
import com.dtsx.astra.sdk.AstraOpsClient;
3129
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
3230
import com.dtsx.astra.sdk.db.DbOpsClient;
3331
import com.dtsx.astra.sdk.db.domain.Database;
@@ -72,7 +70,6 @@ public static synchronized DaoDatabase getInstance() {
7270
private DaoDatabase() {
7371
}
7472

75-
7673
/**
7774
* Access unique db.
7875
*
@@ -102,13 +99,24 @@ public Database getDatabase(String databaseName)
10299
* @return
103100
* astraDB
104101
*/
105-
public AstraDB getAstraDB(String databaseName) {
102+
public com.datastax.astra.client.Database getDataAPIDatabase(String databaseName) {
103+
return getDataAPIDatabase(databaseName, AstraDBAdmin.DEFAULT_NAMESPACE);
104+
}
105+
106+
/**
107+
* Accessing the AstraDB client for a vectorDB.
108+
*
109+
* @param databaseName
110+
* database name
111+
* @return
112+
* instance of a client for the DataAPI
113+
*/
114+
public com.datastax.astra.client.Database getDataAPIDatabase(String databaseName, String keyspace) {
106115
Database db = getDatabase(databaseName);
107116
if (db.getInfo().getDbType() == null) {
108117
throw new IllegalArgumentException("Database %s is not a vector database".formatted(databaseName));
109118
}
110-
AstraOpsClient ops = CliContext.getInstance().getApiDevops();
111-
return new AstraDB(ops.getToken(), UUID.fromString(db.getId()), db.getInfo().getRegion(),ops.getEnvironment());
119+
return CliContext.getInstance().getDataAPIClient().getDatabase(UUID.fromString(db.getId()), keyspace);
112120
}
113121

114122
/**

0 commit comments

Comments
 (0)