Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"cliVersion": "4.23.1",
"cliVersion": "4.53.1",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.44.1",
"generatorVersion": "4.0.9",
"generatorConfig": {
"client-class-name": "Lattice",
"package-prefix": "com.anduril"
},
"originGitCommit": "887ddd18a6134482bc1a576d66a5adb5e722aefa",
"sdkVersion": "5.3.1"
"originGitCommit": "d139ec85d28b73d9598251516d91b3f51152cb46",
"sdkVersion": "5.4.0"
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Add the dependency in your `build.gradle` file:

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

Expand All @@ -53,7 +53,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.anduril</groupId>
<artifactId>lattice-sdk</artifactId>
<version>5.3.1</version>
<version>5.4.0</version>
</dependency>
```

Expand Down Expand Up @@ -145,11 +145,11 @@ Lattice client = Lattice
When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown.

```java
import com.anduril.core.AndurilApiApiException;
import com.anduril.core.LatticeApiException;

try{
client.entities().longPollEntityEvents(...);
} catch (AndurilApiApiException e){
} catch (LatticeApiException e){
// Do something with the API exception...
}
```
Expand Down Expand Up @@ -254,7 +254,7 @@ The `withRawResponse()` method returns a raw client that wraps all responses wit
(A normal client's `response` is identical to a raw client's `response.body()`.)

```java
LongPollEntityEventsHttpResponse response = client.entities().withRawResponse().longPollEntityEvents(...);
LatticeHttpResponse response = client.entities().withRawResponse().longPollEntityEvents(...);

System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ java {

group = 'com.anduril'

version = '5.3.1'
version = '5.4.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,7 +78,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.anduril'
artifactId = 'lattice-sdk'
version = '5.3.1'
version = '5.4.0'
from components.java
pom {
name = 'Anduril Industries, Inc.'
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/anduril/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "com.anduril:lattice-sdk/5.3.1");
put("User-Agent", "com.anduril:lattice-sdk/5.4.0");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.anduril:lattice-sdk");
put("X-Fern-SDK-Version", "5.3.1");
put("X-Fern-SDK-Version", "5.4.0");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/anduril/core/DoubleSerializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.anduril.core;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;

/**
* Custom serializer that writes integer-valued doubles without a decimal point.
* For example, {@code 24000.0} is serialized as {@code 24000} instead of {@code 24000.0}.
* Non-integer values like {@code 3.14} are serialized normally.
*/
class DoubleSerializer extends JsonSerializer<Double> {
private static final SimpleModule MODULE;

static {
MODULE = new SimpleModule()
.addSerializer(Double.class, new DoubleSerializer())
.addSerializer(double.class, new DoubleSerializer());
}

/**
* Gets a module wrapping this serializer as an adapter for the Jackson ObjectMapper.
*
* @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper.
*/
public static SimpleModule getModule() {
return MODULE;
}

@Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value != null && value == Math.floor(value) && !Double.isInfinite(value) && !Double.isNaN(value)) {
gen.writeNumber(value.longValue());
} else {
gen.writeNumber(value);
}
}
}
1 change: 1 addition & 0 deletions src/main/java/com/anduril/core/ObjectMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class ObjectMappers {
.addModule(new Jdk8Module())
.addModule(new JavaTimeModule())
.addModule(DateTimeDeserializer.getModule())
.addModule(DoubleSerializer.getModule())
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/anduril/core/RetryInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class RetryInterceptor implements Interceptor {
private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000);
private static final double JITTER_FACTOR = 0.2;

private final ExponentialBackoff backoff;
private final int maxRetries;
private final Random random = new Random();

public RetryInterceptor(int maxRetries) {
this.backoff = new ExponentialBackoff(maxRetries);
this.maxRetries = maxRetries;
}

@Override
Expand All @@ -38,7 +38,8 @@ public Response intercept(Chain chain) throws IOException {
}

private Response retryChain(Response response, Chain chain) throws IOException {
Optional<Duration> nextBackoff = this.backoff.nextBackoff(response);
ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries);
Optional<Duration> nextBackoff = backoff.nextBackoff(response);
while (nextBackoff.isPresent()) {
try {
Thread.sleep(nextBackoff.get().toMillis());
Expand All @@ -48,7 +49,7 @@ private Response retryChain(Response response, Chain chain) throws IOException {
response.close();
response = chain.proceed(chain.request());
if (shouldRetry(response.code())) {
nextBackoff = this.backoff.nextBackoff(response);
nextBackoff = backoff.nextBackoff(response);
} else {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private interface Value {
@JsonIgnoreProperties("event")
private static final class HeartbeatValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private EntityStreamHeartbeat value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down Expand Up @@ -148,6 +149,7 @@ public String toString() {
@JsonIgnoreProperties("event")
private static final class EntityValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private EntityStreamEvent value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.anduril.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -51,39 +51,39 @@ private ListObjectsRequest(
/**
* @return Filters the objects based on the specified prefix path. If no path is specified, all objects are returned.
*/
@JsonProperty("prefix")
@JsonIgnore
public Optional<String> getPrefix() {
return prefix;
}

/**
* @return Sets the age for the oldest objects to query across the environment.
*/
@JsonProperty("sinceTimestamp")
@JsonIgnore
public Optional<OffsetDateTime> getSinceTimestamp() {
return sinceTimestamp;
}

/**
* @return Base64 and URL-encoded cursor returned by the service to continue paging.
*/
@JsonProperty("pageToken")
@JsonIgnore
public Optional<String> getPageToken() {
return pageToken;
}

/**
* @return Lists objects across all environment nodes in a Lattice Mesh.
*/
@JsonProperty("allObjectsInMesh")
@JsonIgnore
public Optional<Boolean> getAllObjectsInMesh() {
return allObjectsInMesh;
}

/**
* @return Sets the maximum number of items that should be returned on a single page.
*/
@JsonProperty("maxPageSize")
@JsonIgnore
public Optional<Integer> getMaxPageSize() {
return maxPageSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private interface Value {
@JsonIgnoreProperties("event")
private static final class HeartbeatValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private StreamHeartbeat value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down Expand Up @@ -148,6 +149,7 @@ public String toString() {
@JsonIgnoreProperties("event")
private static final class AgentRequestValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private AgentStreamEvent value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private interface Value {
@JsonIgnoreProperties("event")
private static final class HeartbeatValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private StreamHeartbeat value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down Expand Up @@ -148,6 +149,7 @@ public String toString() {
@JsonIgnoreProperties("event")
private static final class TaskEventValue implements Value {
@JsonUnwrapped
@JsonIgnoreProperties(value = "event", allowSetters = true)
private TaskStreamEvent value;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down
Loading