Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,3 @@ jobs:

- name: Test
run: ./gradlew test
publish:
needs: [ compile, test ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Java
id: setup-jre
uses: actions/setup-java@v1
with:
java-version: "11"
architecture: x64

- name: Publish to maven
run: |
./gradlew sonatypeCentralUpload
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_PUBLISH_REGISTRY_URL: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }}
MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }}
MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }}
8 changes: 0 additions & 8 deletions .publish/prepare.sh

This file was deleted.

189 changes: 0 additions & 189 deletions LICENSE

This file was deleted.

41 changes: 4 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,16 @@

![](https://www.anduril.com/lattice-sdk/)

[![Maven Central](https://img.shields.io/maven-central/v/com.anduril/lattice-sdk)](https://central.sonatype.com/artifact/com.anduril/lattice-sdk)

The Lattice SDK Java library provides convenient access to the Lattice SDK APIs from Java.

## Documentation

API reference documentation is available [here](https://developer.anduril.com/).

## Requirements

This repository is tested against Java 1.8 or later.

## Installation

### Gradle

Add the dependency in your `build.gradle` file:

```groovy
dependencies {
implementation 'com.anduril:lattice-sdk'
}
```

### Maven

Add the dependency in your `pom.xml` file:

```xml
<dependency>
<groupId>com.anduril</groupId>
<artifactId>lattice-sdk</artifactId>
<version>2.4.0</version>
</dependency>
```

## Support
## Reference

For support with this library please reach out to your Anduril representative.
A full reference for this library is available [here](./reference.md).

## Usage

Expand Down Expand Up @@ -103,9 +74,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc
```java
import com.anduril.core.AndurilApiApiException;

try {
try{
client.entities().longPollEntityEvents(...);
} catch (AndurilApiApiException e) {
} catch (AndurilApiApiException e){
// Do something with the API exception...
}
```
Expand Down Expand Up @@ -201,7 +172,3 @@ client.entities().longPollEntityEvents(
.build()
);
```

## Reference

A full reference for this library is available [here](https://github.com/anduril/lattice-sdk-java/blob/HEAD/./reference.md).
82 changes: 2 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.11.0'
id 'signing'
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
}

repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}

Expand All @@ -21,6 +19,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
}


Expand All @@ -45,87 +44,10 @@ java {
}


group = 'com.anduril'

version = '2.4.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
archiveBaseName = "lattice-sdk"
}

sourcesJar {
archiveBaseName = "lattice-sdk"
}

javadocJar {
archiveBaseName = "lattice-sdk"
}

signing {
sign(publishing.publications)
}

test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'com.anduril'
artifactId = 'lattice-sdk'
version = '2.4.0'
from components.java
pom {
name = 'Anduril Industries, Inc.'
description = 'Anduril Lattice SDK for Java'
url = 'https://developer.anduril.com'
licenses {
license {
name = 'Anduril Lattice Software Development Kit License Agreement'
}
}
developers {
developer {
name = 'Anduril Industries, Inc.'
email = 'lattice-developers@anduril.com'
}
}
scm {
connection = 'scm:git:git://github.com/anduril/lattice-sdk-java.git'
developerConnection = 'scm:git:git://github.com/anduril/lattice-sdk-java.git'
url = 'https://github.com/anduril/lattice-sdk-java'
}
}
}
}
}

sonatypeCentralUpload {
username = "$System.env.MAVEN_USERNAME"
password = "$System.env.MAVEN_PASSWORD"

archives = files(
"$buildDir/libs/lattice-sdk-" + version + ".jar",
"$buildDir/libs/lattice-sdk-" + version + "-sources.jar",
"$buildDir/libs/lattice-sdk-" + version + "-javadoc.jar"
)

pom = file("$buildDir/publications/maven/pom-default.xml")
signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD"
}

signing {
def signingKeyId = "$System.env.MAVEN_SIGNATURE_KID"
def signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD"
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign publishing.publications.maven
}

sonatypeCentralUpload.dependsOn build
Empty file removed gradle.properties
Empty file.
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
rootProject.name = 'lattice-sdk'

include 'sample-app'
3 changes: 0 additions & 3 deletions src/main/java/com/anduril/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "com.anduril:lattice-sdk/2.4.0");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.anduril.fern:api-sdk");
put("X-Fern-SDK-Version", "2.4.0");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
82 changes: 56 additions & 26 deletions src/main/java/com/anduril/core/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ private final class SSEIterator implements Iterator<T> {
private T nextItem;
private boolean hasNextItem = false;
private boolean endOfStream = false;
private StringBuilder buffer = new StringBuilder();
private boolean prefixSeen = false;
private StringBuilder eventDataBuffer = new StringBuilder();
private String currentEventType = null;

private SSEIterator() {
if (sseReader != null && !isStreamClosed()) {
Expand Down Expand Up @@ -223,39 +223,69 @@ private boolean readNextMessage() {

try {
while (sseScanner.hasNextLine()) {
String chunk = sseScanner.nextLine();
buffer.append(chunk).append(NEWLINE);

int terminatorIndex;
while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
buffer.delete(0, terminatorIndex + messageTerminator.length());

line = line.trim();
if (line.isEmpty()) {
continue;
String line = sseScanner.nextLine();

if (line.trim().isEmpty()) {
if (eventDataBuffer.length() > 0) {
try {
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
hasNextItem = true;
eventDataBuffer.setLength(0);
currentEventType = null;
return true;
} catch (Exception parseEx) {
System.err.println("Failed to parse SSE event: " + parseEx.getMessage());
eventDataBuffer.setLength(0);
currentEventType = null;
continue;
}
}
continue;
}

if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
prefixSeen = true;
line = line.substring(DATA_PREFIX.length()).trim();
} else if (!prefixSeen) {
continue;
if (line.startsWith(DATA_PREFIX)) {
String dataContent = line.substring(DATA_PREFIX.length());
if (dataContent.startsWith(" ")) {
dataContent = dataContent.substring(1);
}

if (streamTerminator != null && line.contains(streamTerminator)) {
if (eventDataBuffer.length() == 0
&& streamTerminator != null
&& dataContent.trim().equals(streamTerminator)) {
endOfStream = true;
return false;
}

try {
nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
hasNextItem = true;
prefixSeen = false;
return true;
} catch (Exception parseEx) {
continue;
if (eventDataBuffer.length() > 0) {
eventDataBuffer.append('\n');
}
eventDataBuffer.append(dataContent);
} else if (line.startsWith("event:")) {
String eventValue = line.length() > 6 ? line.substring(6) : "";
if (eventValue.startsWith(" ")) {
eventValue = eventValue.substring(1);
}
currentEventType = eventValue;
} else if (line.startsWith("id:")) {
// Event ID field (ignored)
} else if (line.startsWith("retry:")) {
// Retry field (ignored)
} else if (line.startsWith(":")) {
// Comment line (ignored)
}
}

if (eventDataBuffer.length() > 0) {
try {
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
hasNextItem = true;
eventDataBuffer.setLength(0);
currentEventType = null;
return true;
} catch (Exception parseEx) {
System.err.println("Failed to parse final SSE event: " + parseEx.getMessage());
eventDataBuffer.setLength(0);
currentEventType = null;
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/anduril/core/pagination/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
package com.anduril.core.pagination;

import java.util.List;
import java.util.Optional;

public abstract class BasePage<T> {
private final boolean hasNext;
private final List<T> items;
private final Object response;

public BasePage(boolean hasNext, List<T> items) {
public BasePage(boolean hasNext, List<T> items, Object response) {
this.hasNext = hasNext;
this.items = items;
this.response = response;
}

public boolean hasNext() {
Expand All @@ -21,4 +24,15 @@ public boolean hasNext() {
public List<T> getItems() {
return items;
}

/**
* Returns the full response object for accessing pagination metadata like cursor tokens.
*
* @return Optional containing the response, or empty if unavailable
*/
public <R> Optional<R> getResponse() {
@SuppressWarnings("unchecked")
R typedResponse = (R) response;
return Optional.ofNullable(typedResponse);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/anduril/core/pagination/SyncPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
public class SyncPage<T> extends BasePage<T> {
protected final Supplier<? extends SyncPage<T>> nextSupplier;

public SyncPage(boolean hasNext, List<T> items, Supplier<? extends SyncPage<T>> nextSupplier) {
super(hasNext, items);
public SyncPage(boolean hasNext, List<T> items, Object response, Supplier<? extends SyncPage<T>> nextSupplier) {
super(hasNext, items, response);
this.nextSupplier = nextSupplier;
}

Expand Down
Loading