Skip to content

Commit bf8e11d

Browse files
committed
Authentication keys support
1 parent a4eb7b9 commit bf8e11d

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

astra-db-java/src/main/java/com/datastax/astra/client/DataAPIOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class DataAPIOptions {
4646
public static final int DEFAULT_MAX_PAGE_SIZE = 20;
4747

4848
/** Maximum number of documents when you insert. */
49-
public static final int DEFAULT_MAX_CHUNKSIZE = 20;
49+
public static final int DEFAULT_MAX_CHUNK_SIZE = 100;
5050

5151
/** Default user agent. */
5252
public static final String DEFAULT_CALLER_NAME = "astra-db-java";
@@ -238,7 +238,7 @@ public static class DataAPIClientOptionsBuilder {
238238
private int maxPageSize = DEFAULT_MAX_PAGE_SIZE;
239239

240240
/** The maximum number of documents that can be inserted in a single operation. */
241-
private int maxDocumentsInInsert = DEFAULT_MAX_CHUNKSIZE;
241+
private int maxDocumentsInInsert = DEFAULT_MAX_CHUNK_SIZE;
242242

243243
/** The embedding service API key can be provided at top level. */
244244
private String embeddingAPIKey;
@@ -505,9 +505,9 @@ public DataAPIClientOptionsBuilder withMaxDocumentsInInsert(int maxDocumentsInIn
505505
if (maxDocumentsInInsert <= 0) {
506506
throw new IllegalArgumentException("Max documents in insert must be a positive number");
507507
}
508-
if (maxDocumentsInInsert > DEFAULT_MAX_CHUNKSIZE) {
508+
if (maxDocumentsInInsert > DEFAULT_MAX_CHUNK_SIZE) {
509509
log.warn("Setting the maximum number of documents in insert to a value greater than the " +
510-
"default value of {} may impact performance or result in error at server level", DEFAULT_MAX_CHUNKSIZE);
510+
"default value of {} may impact performance or result in error at server level", DEFAULT_MAX_CHUNK_SIZE);
511511
}
512512
this.maxDocumentsInInsert = maxDocumentsInInsert;
513513
return this;

astra-db-java/src/main/java/com/datastax/astra/client/model/CollectionOptions.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.fasterxml.jackson.annotation.JsonIgnore;
2424
import com.fasterxml.jackson.annotation.JsonProperty;
25+
import com.fasterxml.jackson.annotation.JsonUnwrapped;
2526
import lombok.Getter;
2627
import lombok.NonNull;
2728
import lombok.Setter;
@@ -162,7 +163,7 @@ public static class Service {
162163
private String modelName;
163164

164165
/** Authentication information like keys and secrets. */
165-
private Authentication authentication;
166+
private Map<String, Object> authentication;
166167

167168
/** Free form parameters. */
168169
private Map<String, Object> parameters;
@@ -173,24 +174,6 @@ public Service() {
173174
}
174175
}
175176

176-
/**
177-
* Subclass representing the Authentication options.
178-
*/
179-
@Getter @Setter
180-
public static class Authentication {
181-
182-
/** Type of authentication: Oauth, API Key, etc. */
183-
private List<String> type;
184-
185-
/** Name of the secret if sstored in Astra. */
186-
private String secretName;
187-
188-
/** Default constructor. */
189-
public Authentication() {
190-
// left blank, serialization with jackson
191-
}
192-
}
193-
194177
/**
195178
* Subclass representing a parameters for LLM Services
196179
*/

astra-db-java/src/main/java/com/datastax/astra/client/model/InsertManyOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class InsertManyOptions extends CommandOptions<InsertManyOptions> {
4242
/**
4343
* If the flag is set to true the command is failing on first error
4444
*/
45-
private int chunkSize = DataAPIOptions.DEFAULT_MAX_CHUNKSIZE;
45+
private int chunkSize = DataAPIOptions.DEFAULT_MAX_CHUNK_SIZE;
4646

4747
/**
4848
* If the flag is set to true the command is failing on first error

astra-db-java/src/test/java/com/datastax/astra/test/unit/DataApiOptionsTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.datastax.astra.client.model.CollectionOptions;
66
import com.datastax.astra.client.model.DeleteOneOptions;
77
import com.datastax.astra.client.model.DeleteResult;
8+
import com.datastax.astra.client.model.Document;
89
import com.datastax.astra.client.model.Filter;
910
import com.datastax.astra.client.model.FilterOperator;
1011
import com.datastax.astra.client.model.FindOneAndDeleteOptions;
@@ -28,6 +29,7 @@
2829
import org.junit.jupiter.api.Test;
2930

3031
import java.net.http.HttpClient;
32+
import java.util.HashMap;
3133
import java.util.List;
3234
import java.util.Map;
3335

@@ -192,9 +194,12 @@ void shouldTestCollectionOptions() {
192194
s.setModelName("OK");
193195

194196
CollectionOptions.Authentication a = new CollectionOptions.Authentication();
195-
a.setSecretName("secret");
197+
a.setSecrets(Map.of("secretName", "secret"));
196198
a.setType(List.of("type"));
197-
s.setAuthentication(a);
199+
Map<String, Object> authentication = new HashMap<>();
200+
authentication.put("type", new String[] {"type"});
201+
authentication.put("secretName", "secret");
202+
s.setAuthentication(authentication);
198203

199204
CollectionOptions.Parameters p1 = new CollectionOptions.Parameters();
200205
p1.setHelp("sample parama");
@@ -205,6 +210,7 @@ void shouldTestCollectionOptions() {
205210

206211
v.setService(s);
207212
c.setVector(v);
213+
System.out.println(JsonUtils.marshall(c));
208214
assertThat(JsonUtils.marshall(c)).isNotNull();
209215
}
210216

0 commit comments

Comments
 (0)