Skip to content

Commit 85225d0

Browse files
🌿 Fern Regeneration -- October 3, 2025 (#164)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: dogun-anduril <[email protected]>
1 parent be34ec3 commit 85225d0

File tree

52 files changed

+7769
-601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+7769
-601
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Add the dependency in your `pom.xml` file:
3434
<dependency>
3535
<groupId>com.anduril</groupId>
3636
<artifactId>lattice-sdk</artifactId>
37-
<version>2.4.0</version>
37+
<version>3.0.0</version>
3838
</dependency>
3939
```
4040

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
2222
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2323
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
24+
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
2425
}
2526

2627

@@ -47,7 +48,7 @@ java {
4748

4849
group = 'com.anduril'
4950

50-
version = '2.4.0'
51+
version = '3.0.0'
5152

5253
jar {
5354
dependsOn(":generatePomFileForMavenPublication")
@@ -78,7 +79,7 @@ publishing {
7879
maven(MavenPublication) {
7980
groupId = 'com.anduril'
8081
artifactId = 'lattice-sdk'
81-
version = '2.4.0'
82+
version = '3.0.0'
8283
from components.java
8384
pom {
8485
name = 'Anduril Industries, Inc.'

src/main/java/com/anduril/core/ClientOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ private ClientOptions(
3232
this.headers.putAll(headers);
3333
this.headers.putAll(new HashMap<String, String>() {
3434
{
35-
put("User-Agent", "com.anduril:lattice-sdk/2.4.0");
35+
put("User-Agent", "com.anduril:lattice-sdk/3.0.0");
3636
put("X-Fern-Language", "JAVA");
3737
put("X-Fern-SDK-Name", "com.anduril.fern:api-sdk");
38-
put("X-Fern-SDK-Version", "2.4.0");
38+
put("X-Fern-SDK-Version", "3.0.0");
3939
}
4040
});
4141
this.headerSuppliers = headerSuppliers;

src/main/java/com/anduril/core/Stream.java

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ private final class SSEIterator implements Iterator<T> {
174174
private T nextItem;
175175
private boolean hasNextItem = false;
176176
private boolean endOfStream = false;
177-
private StringBuilder buffer = new StringBuilder();
178-
private boolean prefixSeen = false;
177+
private StringBuilder eventDataBuffer = new StringBuilder();
178+
private String currentEventType = null;
179179

180180
private SSEIterator() {
181181
if (sseReader != null && !isStreamClosed()) {
@@ -223,39 +223,69 @@ private boolean readNextMessage() {
223223

224224
try {
225225
while (sseScanner.hasNextLine()) {
226-
String chunk = sseScanner.nextLine();
227-
buffer.append(chunk).append(NEWLINE);
228-
229-
int terminatorIndex;
230-
while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
231-
String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
232-
buffer.delete(0, terminatorIndex + messageTerminator.length());
233-
234-
line = line.trim();
235-
if (line.isEmpty()) {
236-
continue;
226+
String line = sseScanner.nextLine();
227+
228+
if (line.trim().isEmpty()) {
229+
if (eventDataBuffer.length() > 0) {
230+
try {
231+
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
232+
hasNextItem = true;
233+
eventDataBuffer.setLength(0);
234+
currentEventType = null;
235+
return true;
236+
} catch (Exception parseEx) {
237+
System.err.println("Failed to parse SSE event: " + parseEx.getMessage());
238+
eventDataBuffer.setLength(0);
239+
currentEventType = null;
240+
continue;
241+
}
237242
}
243+
continue;
244+
}
238245

239-
if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
240-
prefixSeen = true;
241-
line = line.substring(DATA_PREFIX.length()).trim();
242-
} else if (!prefixSeen) {
243-
continue;
246+
if (line.startsWith(DATA_PREFIX)) {
247+
String dataContent = line.substring(DATA_PREFIX.length());
248+
if (dataContent.startsWith(" ")) {
249+
dataContent = dataContent.substring(1);
244250
}
245251

246-
if (streamTerminator != null && line.contains(streamTerminator)) {
252+
if (eventDataBuffer.length() == 0
253+
&& streamTerminator != null
254+
&& dataContent.trim().equals(streamTerminator)) {
247255
endOfStream = true;
248256
return false;
249257
}
250258

251-
try {
252-
nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
253-
hasNextItem = true;
254-
prefixSeen = false;
255-
return true;
256-
} catch (Exception parseEx) {
257-
continue;
259+
if (eventDataBuffer.length() > 0) {
260+
eventDataBuffer.append('\n');
261+
}
262+
eventDataBuffer.append(dataContent);
263+
} else if (line.startsWith("event:")) {
264+
String eventValue = line.length() > 6 ? line.substring(6) : "";
265+
if (eventValue.startsWith(" ")) {
266+
eventValue = eventValue.substring(1);
258267
}
268+
currentEventType = eventValue;
269+
} else if (line.startsWith("id:")) {
270+
// Event ID field (ignored)
271+
} else if (line.startsWith("retry:")) {
272+
// Retry field (ignored)
273+
} else if (line.startsWith(":")) {
274+
// Comment line (ignored)
275+
}
276+
}
277+
278+
if (eventDataBuffer.length() > 0) {
279+
try {
280+
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
281+
hasNextItem = true;
282+
eventDataBuffer.setLength(0);
283+
currentEventType = null;
284+
return true;
285+
} catch (Exception parseEx) {
286+
System.err.println("Failed to parse final SSE event: " + parseEx.getMessage());
287+
eventDataBuffer.setLength(0);
288+
currentEventType = null;
259289
}
260290
}
261291

src/main/java/com/anduril/core/pagination/BasePage.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
package com.anduril.core.pagination;
55

66
import java.util.List;
7+
import java.util.Optional;
78

89
public abstract class BasePage<T> {
910
private final boolean hasNext;
1011
private final List<T> items;
12+
private final Object response;
1113

12-
public BasePage(boolean hasNext, List<T> items) {
14+
public BasePage(boolean hasNext, List<T> items, Object response) {
1315
this.hasNext = hasNext;
1416
this.items = items;
17+
this.response = response;
1518
}
1619

1720
public boolean hasNext() {
@@ -21,4 +24,15 @@ public boolean hasNext() {
2124
public List<T> getItems() {
2225
return items;
2326
}
27+
28+
/**
29+
* Returns the full response object for accessing pagination metadata like cursor tokens.
30+
*
31+
* @return Optional containing the response, or empty if unavailable
32+
*/
33+
public <R> Optional<R> getResponse() {
34+
@SuppressWarnings("unchecked")
35+
R typedResponse = (R) response;
36+
return Optional.ofNullable(typedResponse);
37+
}
2438
}

src/main/java/com/anduril/core/pagination/SyncPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
public class SyncPage<T> extends BasePage<T> {
1111
protected final Supplier<? extends SyncPage<T>> nextSupplier;
1212

13-
public SyncPage(boolean hasNext, List<T> items, Supplier<? extends SyncPage<T>> nextSupplier) {
14-
super(hasNext, items);
13+
public SyncPage(boolean hasNext, List<T> items, Object response, Supplier<? extends SyncPage<T>> nextSupplier) {
14+
super(hasNext, items, response);
1515
this.nextSupplier = nextSupplier;
1616
}
1717

src/main/java/com/anduril/core/pagination/SyncPagingIterable.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
public class SyncPagingIterable<T> extends SyncPage<T> implements Iterable<T> {
1616

17-
public SyncPagingIterable(boolean hasNext, List<T> items, Supplier<? extends SyncPage<T>> getNext) {
18-
super(hasNext, items, getNext);
17+
public SyncPagingIterable(
18+
boolean hasNext, List<T> items, Object response, Supplier<? extends SyncPage<T>> getNext) {
19+
super(hasNext, items, response, getNext);
1920
}
2021

21-
public SyncPagingIterable(boolean hasNext, Optional<List<T>> items, Supplier<? extends SyncPage<T>> getNext) {
22-
super(hasNext, items.orElse(new ArrayList<>()), getNext);
22+
public SyncPagingIterable(
23+
boolean hasNext, Optional<List<T>> items, Object response, Supplier<? extends SyncPage<T>> getNext) {
24+
super(hasNext, items.orElse(new ArrayList<>()), response, getNext);
2325
}
2426

2527
public Stream<T> streamItems() {

src/main/java/com/anduril/resources/objects/AsyncRawObjectsClient.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
114114
.build();
115115
List<PathMetadata> result = parsedResponse.getPathMetadatas();
116116
future.complete(new LatticeHttpResponse<>(
117-
new SyncPagingIterable<PathMetadata>(startingAfter.isPresent(), result, () -> {
118-
try {
119-
return listObjects(nextRequest, requestOptions)
120-
.get()
121-
.body();
122-
} catch (InterruptedException | ExecutionException e) {
123-
throw new RuntimeException(e);
124-
}
125-
}),
117+
new SyncPagingIterable<PathMetadata>(
118+
startingAfter.isPresent(), result, parsedResponse, () -> {
119+
try {
120+
return listObjects(nextRequest, requestOptions)
121+
.get()
122+
.body();
123+
} catch (InterruptedException | ExecutionException e) {
124+
throw new RuntimeException(e);
125+
}
126+
}),
126127
response));
127128
return;
128129
}

src/main/java/com/anduril/resources/objects/RawObjectsClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public LatticeHttpResponse<SyncPagingIterable<PathMetadata>> listObjects(
106106
List<PathMetadata> result = parsedResponse.getPathMetadatas();
107107
return new LatticeHttpResponse<>(
108108
new SyncPagingIterable<PathMetadata>(
109-
startingAfter.isPresent(), result, () -> listObjects(nextRequest, requestOptions)
109+
startingAfter.isPresent(), result, parsedResponse, () -> listObjects(
110+
nextRequest, requestOptions)
110111
.body()),
111112
response);
112113
}

src/main/java/com/anduril/resources/objects/types/GetObjectRequestAcceptEncoding.java

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,83 @@
33
*/
44
package com.anduril.resources.objects.types;
55

6+
import com.fasterxml.jackson.annotation.JsonCreator;
67
import com.fasterxml.jackson.annotation.JsonValue;
78

8-
public enum GetObjectRequestAcceptEncoding {
9-
IDENTITY("identity"),
9+
public final class GetObjectRequestAcceptEncoding {
10+
public static final GetObjectRequestAcceptEncoding IDENTITY =
11+
new GetObjectRequestAcceptEncoding(Value.IDENTITY, "identity");
1012

11-
ZSTD("zstd");
13+
public static final GetObjectRequestAcceptEncoding ZSTD = new GetObjectRequestAcceptEncoding(Value.ZSTD, "zstd");
1214

13-
private final String value;
15+
private final Value value;
1416

15-
GetObjectRequestAcceptEncoding(String value) {
17+
private final String string;
18+
19+
GetObjectRequestAcceptEncoding(Value value, String string) {
1620
this.value = value;
21+
this.string = string;
22+
}
23+
24+
public Value getEnumValue() {
25+
return value;
1726
}
1827

19-
@JsonValue
2028
@java.lang.Override
29+
@JsonValue
2130
public String toString() {
22-
return this.value;
31+
return this.string;
32+
}
33+
34+
@java.lang.Override
35+
public boolean equals(Object other) {
36+
return (this == other)
37+
|| (other instanceof GetObjectRequestAcceptEncoding
38+
&& this.string.equals(((GetObjectRequestAcceptEncoding) other).string));
39+
}
40+
41+
@java.lang.Override
42+
public int hashCode() {
43+
return this.string.hashCode();
44+
}
45+
46+
public <T> T visit(Visitor<T> visitor) {
47+
switch (value) {
48+
case IDENTITY:
49+
return visitor.visitIdentity();
50+
case ZSTD:
51+
return visitor.visitZstd();
52+
case UNKNOWN:
53+
default:
54+
return visitor.visitUnknown(string);
55+
}
56+
}
57+
58+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
59+
public static GetObjectRequestAcceptEncoding valueOf(String value) {
60+
switch (value) {
61+
case "identity":
62+
return IDENTITY;
63+
case "zstd":
64+
return ZSTD;
65+
default:
66+
return new GetObjectRequestAcceptEncoding(Value.UNKNOWN, value);
67+
}
68+
}
69+
70+
public enum Value {
71+
IDENTITY,
72+
73+
ZSTD,
74+
75+
UNKNOWN
76+
}
77+
78+
public interface Visitor<T> {
79+
T visitIdentity();
80+
81+
T visitZstd();
82+
83+
T visitUnknown(String unknownType);
2384
}
2485
}

0 commit comments

Comments
 (0)