Skip to content

Commit 5c2ab59

Browse files
committed
Update JavaDocs
1 parent 74c6d69 commit 5c2ab59

34 files changed

+584
-151
lines changed

src/main/java/com/datastax/astra/client/Collection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ public class Collection<DOC> extends AbstractCommandRunner {
130130
* client namespace http
131131
* @param collectionName
132132
* collection identifier
133+
* @param clazz
134+
* working object for document in the collection
133135
*/
134136
protected Collection(Database db, String collectionName, Class<DOC> clazz) {
135137
notNull(db, "database");

src/main/java/com/datastax/astra/client/DataAPIClient.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
import static com.datastax.astra.client.AstraDBAdmin.DEFAULT_NAMESPACE;
3131

32+
/**
33+
* Entry point to access the Data API.
34+
*/
3235
public class DataAPIClient {
3336

3437
/** Token in use with the solution. */
@@ -37,10 +40,24 @@ public class DataAPIClient {
3740
/** Options to setup the client. */
3841
private final DataAPIOptions options;
3942

43+
/**
44+
* Constructor with a token
45+
*
46+
* @param token
47+
* authentication token.
48+
*/
4049
public DataAPIClient(String token) {
4150
this(token, DataAPIOptions.builder().build());
4251
}
4352

53+
/**
54+
* Constructor with a token and options.
55+
*
56+
* @param token
57+
* authentication token
58+
* @param options
59+
* set of options for the http client
60+
*/
4461
public DataAPIClient(String token, DataAPIOptions options) {
4562
Assert.hasLength(token, "token");
4663
Assert.notNull(options, "options");
@@ -52,14 +69,34 @@ public DataAPIClient(String token, DataAPIOptions options) {
5269
// --- Access AstraDBAdmin ---
5370
// --------------------------------------------------
5471

72+
/**
73+
* Access the administration client (crud on databases).
74+
*
75+
* @return
76+
* administration client
77+
*/
5578
public AstraDBAdmin getAdmin() {
5679
return getAdmin(this.token);
5780
}
5881

82+
/**
83+
* Access the administration client (crud on databases) by providing a stronger token.
84+
*
85+
* @param superUserToken
86+
* provide a token with enough privileges for admin operations
87+
* @return
88+
* administration client
89+
*/
5990
public AstraDBAdmin getAdmin(String superUserToken) {
6091
return new AstraDBAdmin(superUserToken, getAstraEnvironment(), options);
6192
}
6293

94+
/**
95+
* Allow to find the environment from the destination.
96+
*
97+
* @return
98+
* current astra environment
99+
*/
63100
private Optional<AstraEnvironment> findAstraEnvironment() {
64101
if (options.getDestination() != null) {
65102
switch (options.getDestination()) {
@@ -74,6 +111,12 @@ private Optional<AstraEnvironment> findAstraEnvironment() {
74111
return Optional.empty();
75112
}
76113

114+
/**
115+
* Get the current Astra Environment.
116+
*
117+
* @return
118+
* current astra environment
119+
*/
77120
private AstraEnvironment getAstraEnvironment() {
78121
return findAstraEnvironment()
79122
.orElseThrow(() -> new IllegalArgumentException("'destination' should be ASTRA* to use the AstraDBAdmin"));
@@ -83,6 +126,16 @@ private AstraEnvironment getAstraEnvironment() {
83126
// --- Access Database ---
84127
// --------------------------------------------------
85128

129+
/**
130+
* Access a database client to interact with the Data API.
131+
*
132+
* @param databaseId
133+
* unique identifier of the database
134+
* @param namespace
135+
* namespace to use
136+
* @return
137+
* database client
138+
*/
86139
public Database getDatabase(UUID databaseId, String namespace) {
87140
Assert.notNull(databaseId, "databaseId");
88141
Assert.hasLength(namespace, "namespace");
@@ -92,14 +145,38 @@ public Database getDatabase(UUID databaseId, String namespace) {
92145
namespace);
93146
}
94147

148+
/**
149+
* Access a database client to interact with the Data API.
150+
* @param databaseId
151+
* unique identifier of the database
152+
* @return
153+
* database client
154+
*/
95155
public Database getDatabase(UUID databaseId) {
96156
return getDatabase(databaseId, DEFAULT_NAMESPACE);
97157
}
98158

159+
/**
160+
* Access a database client to interact with the Data API.
161+
* @param apiEndpoint
162+
* url of the api in used
163+
* @param namespace
164+
* namespace to use
165+
* @return
166+
* database client
167+
*/
99168
public Database getDatabase(String apiEndpoint, String namespace) {
100169
return new Database(apiEndpoint, token, namespace, options);
101170
}
102171

172+
/**
173+
* Access a database client to interact with the Data API.
174+
*
175+
* @param apiEndpoint
176+
* url of the api in used
177+
* @return
178+
* database client
179+
*/
103180
public Database getDatabase(String apiEndpoint) {
104181
return getDatabase(apiEndpoint, DEFAULT_NAMESPACE);
105182
}

src/main/java/com/datastax/astra/client/DataAPIClients.java

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ public class DataAPIClients {
3434
/** Default endpoint. */
3535
public static final String DEFAULT_ENDPOINT = "http://localhost:8181";
3636

37-
/** Default endpoint. */
38-
public static final String PATH_HEALTH_CHECK = "/stargate/health";
39-
40-
/** Default service id. */
41-
public static final String DEFAULT_SERVICE_ID = "sgv2-json";
42-
43-
/** Default datacenter id. */
44-
private static final String DEFAULT_DATACENTER = "dc1";
45-
4637
/**
4738
* Utility class, should not be instanced.
4839
*/
4940
private DataAPIClients() {}
5041

5142
/**
52-
* Create from an Endpoint only
43+
* Create DataApiClient to interact with a local instance of Stargate.
44+
* @return
45+
* DataApiClient for local instance
46+
*
5347
*/
5448
public static DataAPIClient localClient() {
5549
return new DataAPIClient(
5650
new StargateAuthenticationService().getToken(),
5751
DataAPIOptions.builder().withDestination(DataAPIDestination.CASSANDRA).build());
5852
}
5953

54+
/**
55+
* Create DataApiClient and Database to interact with a local instance of Stargate.
56+
*
57+
* @return
58+
* Database client for local instance
59+
*/
6060
public static Database localDatabase() {
6161
Database db = localClient().getDatabase(DEFAULT_ENDPOINT, DEFAULT_NAMESPACE);
6262
db.registerListener("logger", new LoggingCommandObserver(Database.class));
@@ -66,26 +66,50 @@ public static Database localDatabase() {
6666
return db;
6767
}
6868

69+
70+
/**
71+
* Create DataApiClient and Database to interact with Astra,
72+
*
73+
* @param token
74+
* authentication token
75+
* @return
76+
* Database client to use Astra
77+
*/
6978
public static DataAPIClient astra(String token) {
7079
return new DataAPIClient(token, DataAPIOptions
7180
.builder()
7281
.withDestination(DataAPIDestination.ASTRA)
7382
.build());
7483
}
7584

85+
/**
86+
* Create DataApiClient and Database to interact with Astra in development environment.
87+
*
88+
* @param token
89+
* authentication token
90+
* @return
91+
* Database client to use Astra DEV
92+
*/
7693
public static DataAPIClient astraDev(String token) {
7794
return new DataAPIClient(token, DataAPIOptions
7895
.builder()
7996
.withDestination(DataAPIDestination.ASTRA_DEV)
8097
.build());
8198
}
8299

100+
/**
101+
* Create DataApiClient and Database to interact with Astra in test environment.
102+
*
103+
* @param token
104+
* authentication token
105+
* @return
106+
* Database client to use Astra TEST
107+
*/
83108
public static DataAPIClient astraTest(String token) {
84109
return new DataAPIClient(token, DataAPIOptions
85110
.builder()
86111
.withDestination(DataAPIDestination.ASTRA_TEST)
87112
.build());
88113
}
89114

90-
91115
}

src/main/java/com/datastax/astra/client/DataAPIDestination.java

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

23+
/**
24+
* Represent the destination of the data API.
25+
*/
2326
public enum DataAPIDestination {
24-
ASTRA, ASTRA_DEV, ASTRA_TEST, DSE, CASSANDRA, OTHERS
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+
* Local installation of Apache Cassandra
50+
*/
51+
CASSANDRA,
52+
53+
/**
54+
* Extra local installation .
55+
*/
56+
OTHERS
2557
}

src/main/java/com/datastax/astra/client/DatabaseAdmin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public interface DatabaseAdmin {
6161
* Retrieves a stream of namespace names available in the current database. This method is essential for
6262
* applications that need to enumerate all namespaces to perform operations such as displaying available
6363
* namespaces to users, managing namespaces programmatically, or executing specific tasks within each
64-
* namespace. The returned {@link Stream} facilitates efficient processing of namespace names, enabling
64+
* namespace. The returned Stream facilitates efficient processing of namespace names, enabling
6565
* operations like filtering, sorting, and mapping without the need for preloading all names into memory.
66-
* <p></p>
66+
*
6767
* <p>Example usage:</p>
6868
* <pre>
6969
* {@code

0 commit comments

Comments
 (0)