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
6 changes: 3 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"cliVersion": "3.40.0",
"cliVersion": "3.49.5",
"generatorName": "fernapi/fern-java-sdk",
"generatorVersion": "3.29.1",
"generatorVersion": "3.27.6",
"generatorConfig": {
"client-class-name": "Lattice",
"package-prefix": "com.anduril"
},
"sdkVersion": "5.1.0"
"sdkVersion": "6.0.0"
}
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Add the dependency in your `pom.xml` file:
<dependency>
<groupId>com.anduril</groupId>
<artifactId>lattice-sdk</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
</dependency>
```

Expand Down Expand Up @@ -93,6 +93,30 @@ This SDK supports two authentication methods:

If you already have a valid access token, you can use it directly:

```java
Lattice client = Lattice.withToken("your-access-token")
.url("https://api.example.com")
.build();
```

### Option 2: OAuth Client Credentials

The SDK can automatically handle token acquisition and refresh:

```java
Lattice client = Lattice.withCredentials("client-id", "client-secret")
.url("https://api.example.com")
.build();
```

## Authentication

This SDK supports two authentication methods:

### Option 1: Direct Bearer Token

If you already have a valid access token, you can use it directly:

```java
Lattice client = Lattice.builder()
.token("your-access-token")
Expand Down
16 changes: 8 additions & 8 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.1.0'
version = '6.0.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -78,21 +78,21 @@ publishing {
maven(MavenPublication) {
groupId = 'com.anduril'
artifactId = 'lattice-sdk'
version = '5.1.0'
version = '6.0.0'
from components.java
pom {
name = 'Anduril Industries, Inc.'
description = 'Anduril Lattice SDK for Java'
url = 'https://developer.anduril.com'
name = 'anduril'
description = 'The official SDK of anduril'
url = 'https://buildwithfern.com'
licenses {
license {
name = 'Anduril Lattice Software Development Kit License Agreement'
name = 'Custom License (LICENSE)'
}
}
developers {
developer {
name = 'Anduril Industries, Inc.'
email = 'lattice-developers@anduril.com'
name = 'anduril'
email = 'developers@anduril.com'
}
}
scm {
Expand Down
12 changes: 6 additions & 6 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ client.entities().longPollEntityEvents(
</dl>
</details>

<details><summary><code>client.entities.streamEntities(request) -> Iterable&amp;lt;StreamEntitiesResponse&amp;gt;</code></summary>
<details><summary><code>client.entities.streamEntities(request) -> Iterable&lt;StreamEntitiesResponse&gt;</code></summary>
<dl>
<dd>

Expand Down Expand Up @@ -914,7 +914,7 @@ client.tasks().listenAsAgent(
</details>

## Objects
<details><summary><code>client.objects.listObjects() -> SyncPagingIterable&amp;lt;PathMetadata&amp;gt;</code></summary>
<details><summary><code>client.objects.listObjects() -> SyncPagingIterable&lt;PathMetadata&gt;</code></summary>
<dl>
<dd>

Expand Down Expand Up @@ -1243,8 +1243,8 @@ client.objects().getObjectMetadata(
</dl>
</details>

## OAuth2
<details><summary><code>client.oAuth2.getToken(request) -> GetTokenResponse</code></summary>
## oauth
<details><summary><code>client.oauth.getToken(request) -> GetTokenResponse</code></summary>
<dl>
<dd>

Expand All @@ -1256,7 +1256,7 @@ client.objects().getObjectMetadata(
<dl>
<dd>

Support the client credentials authorization flow
Gets a new short-lived token using the specified client credentials
</dd>
</dl>
</dd>
Expand All @@ -1271,7 +1271,7 @@ Support the client credentials authorization flow
<dd>

```java
client.oAuth2().getToken(
client.oauth().getToken(
GetTokenRequest
.builder()
.build()
Expand Down
18 changes: 5 additions & 13 deletions src/main/java/com/anduril/AsyncLattice.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.anduril.core.ClientOptions;
import com.anduril.core.Suppliers;
import com.anduril.resources.entities.AsyncEntitiesClient;
import com.anduril.resources.oauth2.AsyncOAuth2Client;
import com.anduril.resources.oauth.AsyncOauthClient;
import com.anduril.resources.objects.AsyncObjectsClient;
import com.anduril.resources.tasks.AsyncTasksClient;
import java.util.function.Supplier;
Expand All @@ -20,14 +20,14 @@ public class AsyncLattice {

protected final Supplier<AsyncObjectsClient> objectsClient;

protected final Supplier<AsyncOAuth2Client> oAuth2Client;
protected final Supplier<AsyncOauthClient> oauthClient;

public AsyncLattice(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.entitiesClient = Suppliers.memoize(() -> new AsyncEntitiesClient(clientOptions));
this.tasksClient = Suppliers.memoize(() -> new AsyncTasksClient(clientOptions));
this.objectsClient = Suppliers.memoize(() -> new AsyncObjectsClient(clientOptions));
this.oAuth2Client = Suppliers.memoize(() -> new AsyncOAuth2Client(clientOptions));
this.oauthClient = Suppliers.memoize(() -> new AsyncOauthClient(clientOptions));
}

public AsyncEntitiesClient entities() {
Expand All @@ -42,8 +42,8 @@ public AsyncObjectsClient objects() {
return this.objectsClient.get();
}

public AsyncOAuth2Client oAuth2() {
return this.oAuth2Client.get();
public AsyncOauthClient oauth() {
return this.oauthClient.get();
}

/**
Expand All @@ -64,12 +64,4 @@ public static AsyncLatticeBuilder._TokenAuth withToken(String token) {
public static AsyncLatticeBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) {
return AsyncLatticeBuilder.withCredentials(clientId, clientSecret);
}

/**
* Creates a new client builder.
* @return A builder for configuring and creating the client
*/
public static AsyncLatticeBuilder._Builder builder() {
return AsyncLatticeBuilder.builder();
}
}
127 changes: 2 additions & 125 deletions src/main/java/com/anduril/AsyncLatticeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.anduril.core.ClientOptions;
import com.anduril.core.Environment;
import com.anduril.core.OAuthTokenSupplier;
import com.anduril.resources.oauth2.OAuth2Client;
import com.anduril.resources.oauth.OauthClient;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -47,16 +47,6 @@ public static _CredentialsAuth withCredentials(String clientId, String clientSec
return new _CredentialsAuth(clientId, clientSecret);
}

/**
* Creates a new client builder.
* Use this method to start building a client with the classic builder pattern.
*
* @return A builder for configuring authentication and creating the client
*/
public static _Builder builder() {
return new _Builder();
}

public AsyncLatticeBuilder environment(Environment environment) {
this.environment = environment;
return this;
Expand Down Expand Up @@ -249,7 +239,7 @@ public static final class _CredentialsAuth extends AsyncLatticeBuilder {
public AsyncLattice build() {
validateConfiguration();
ClientOptions baseOptions = buildClientOptions();
OAuth2Client authClient = new OAuth2Client(baseOptions);
OauthClient authClient = new OauthClient(baseOptions);
OAuthTokenSupplier oAuthTokenSupplier =
new OAuthTokenSupplier(this.clientId, this.clientSecret, authClient);
ClientOptions finalOptions = ClientOptions.Builder.from(baseOptions)
Expand All @@ -258,117 +248,4 @@ public AsyncLattice build() {
return new AsyncLattice(finalOptions);
}
}

public static final class _Builder {
private Environment environment;

private Optional<Integer> timeout = Optional.empty();

private Optional<Integer> maxRetries = Optional.empty();

private OkHttpClient httpClient;

private final Map<String, String> headers = new HashMap<>();

public _Builder environment(Environment environment) {
this.environment = environment;
return this;
}

public _Builder url(String url) {
this.environment = Environment.custom(url);
return this;
}

/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public _Builder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}

/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public _Builder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public _Builder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}

/**
* Add a custom header to be sent with all requests.
* @param name The header name
* @param value The header value
* @return This builder for method chaining
*/
public _Builder addHeader(String name, String value) {
this.headers.put(name, value);
return this;
}

/**
* Configure the client to use a pre-generated access token for authentication.
* Use this when you already have a valid access token and want to bypass
* the OAuth client credentials flow.
*
* @param token The access token to use for Authorization header
* @return A builder configured for token authentication
*/
public _TokenAuth token(String token) {
_TokenAuth auth = new _TokenAuth(token);
if (this.environment != null) {
auth.environment = this.environment;
}
if (this.timeout.isPresent()) {
auth.timeout(this.timeout.get());
}
if (this.maxRetries.isPresent()) {
auth.maxRetries(this.maxRetries.get());
}
if (this.httpClient != null) {
auth.httpClient(this.httpClient);
}
for (Map.Entry<String, String> header : this.headers.entrySet()) {
auth.addHeader(header.getKey(), header.getValue());
}
return auth;
}

/**
* Configure the client to use OAuth client credentials for authentication.
* The builder will automatically handle token acquisition and refresh.
*
* @param clientId The OAuth client ID
* @param clientSecret The OAuth client secret
* @return A builder configured for OAuth client credentials authentication
*/
public _CredentialsAuth credentials(String clientId, String clientSecret) {
_CredentialsAuth auth = new _CredentialsAuth(clientId, clientSecret);
if (this.environment != null) {
auth.environment = this.environment;
}
if (this.timeout.isPresent()) {
auth.timeout(this.timeout.get());
}
if (this.maxRetries.isPresent()) {
auth.maxRetries(this.maxRetries.get());
}
if (this.httpClient != null) {
auth.httpClient(this.httpClient);
}
for (Map.Entry<String, String> header : this.headers.entrySet()) {
auth.addHeader(header.getKey(), header.getValue());
}
return auth;
}
}
}
18 changes: 5 additions & 13 deletions src/main/java/com/anduril/Lattice.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.anduril.core.ClientOptions;
import com.anduril.core.Suppliers;
import com.anduril.resources.entities.EntitiesClient;
import com.anduril.resources.oauth2.OAuth2Client;
import com.anduril.resources.oauth.OauthClient;
import com.anduril.resources.objects.ObjectsClient;
import com.anduril.resources.tasks.TasksClient;
import java.util.function.Supplier;
Expand All @@ -20,14 +20,14 @@ public class Lattice {

protected final Supplier<ObjectsClient> objectsClient;

protected final Supplier<OAuth2Client> oAuth2Client;
protected final Supplier<OauthClient> oauthClient;

public Lattice(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.entitiesClient = Suppliers.memoize(() -> new EntitiesClient(clientOptions));
this.tasksClient = Suppliers.memoize(() -> new TasksClient(clientOptions));
this.objectsClient = Suppliers.memoize(() -> new ObjectsClient(clientOptions));
this.oAuth2Client = Suppliers.memoize(() -> new OAuth2Client(clientOptions));
this.oauthClient = Suppliers.memoize(() -> new OauthClient(clientOptions));
}

public EntitiesClient entities() {
Expand All @@ -42,8 +42,8 @@ public ObjectsClient objects() {
return this.objectsClient.get();
}

public OAuth2Client oAuth2() {
return this.oAuth2Client.get();
public OauthClient oauth() {
return this.oauthClient.get();
}

/**
Expand All @@ -64,12 +64,4 @@ public static LatticeBuilder._TokenAuth withToken(String token) {
public static LatticeBuilder._CredentialsAuth withCredentials(String clientId, String clientSecret) {
return LatticeBuilder.withCredentials(clientId, clientSecret);
}

/**
* Creates a new client builder.
* @return A builder for configuring and creating the client
*/
public static LatticeBuilder._Builder builder() {
return LatticeBuilder.builder();
}
}
Loading