diff --git a/.fern/metadata.json b/.fern/metadata.json index 3da9bce..0f0f30e 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,10 +1,10 @@ { - "cliVersion": "3.40.0", + "cliVersion": "3.51.2", "generatorName": "fernapi/fern-java-sdk", "generatorVersion": "3.29.1", "generatorConfig": { "client-class-name": "Lattice", "package-prefix": "com.anduril" }, - "sdkVersion": "5.1.0" + "sdkVersion": "5.2.0" } \ No newline at end of file diff --git a/README.md b/README.md index 393fa29..50dd7ca 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The Lattice SDK Java library provides convenient access to the Lattice SDK APIs - [Installation](#installation) - [Support](#support) - [Usage](#usage) +- [Authentication](#authentication) - [Environments](#environments) - [Base Url](#base-url) - [Exception Handling](#exception-handling) @@ -52,7 +53,7 @@ Add the dependency in your `pom.xml` file: com.anduril lattice-sdk - 5.1.0 + 5.2.0 ``` @@ -111,6 +112,32 @@ Lattice client = Lattice.builder() .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") + .url("https://api.example.com") + .build(); +``` + +### Option 2: OAuth Client Credentials + +The SDK can automatically handle token acquisition and refresh: + +```java +Lattice client = Lattice.builder() + .credentials("client-id", "client-secret") + .url("https://api.example.com") + .build(); +``` + ## Environments This SDK allows you to configure different environments for API requests. diff --git a/build.gradle b/build.gradle index 6a89afa..078fd98 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'com.anduril' -version = '5.1.0' +version = '5.2.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'com.anduril' artifactId = 'lattice-sdk' - version = '5.1.0' + version = '5.2.0' from components.java pom { name = 'Anduril Industries, Inc.' diff --git a/reference.md b/reference.md index e8ee820..8386af5 100644 --- a/reference.md +++ b/reference.md @@ -832,6 +832,97 @@ any of the remaining parameters, but not both. + + + + +
client.tasks.streamTasks(request) -> Iterable<StreamTasksResponse> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + +The stream delivers all existing non-terminal tasks when first connected, followed by real-time +updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tasks().streamTasks( + TaskStreamRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**heartbeatIntervalMs:** `Optional` — The time interval, in milliseconds, that determines the frequency at which to send heartbeat events. Defaults to 30000 (30 seconds). + +
+
+ +
+
+ +**rateLimit:** `Optional` + +The time interval, in milliseconds, after an update for a given task before another one will be sent for the same task. +If set, value must be >= 250. + +
+
+ +
+
+ +**excludePreexistingTasks:** `Optional` + +Optional flag to only include tasks created or updated after the stream is initiated, and not any previous preexisting tasks. +If unset or false, the stream will include any new tasks and task updates, as well as all preexisting tasks. + +
+
+ +
+
+ +**taskType:** `Optional` — Optional filter that only returns tasks with specific types. If not provided, all task types will be streamed. + +
+
+
+
+ +
@@ -909,6 +1000,88 @@ client.tasks().listenAsAgent( + + + + +
client.tasks.streamAsAgent(request) -> Iterable<StreamAsAgentResponse> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Establishes a server streaming connection that delivers tasks to taskable agents for execution +using Server-Sent Events (SSE). + +This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria. + +The stream delivers three types of requests: +- `ExecuteRequest`: Contains a new task for the agent to execute +- `CancelRequest`: Indicates a task should be canceled +- `CompleteRequest`: Indicates a task should be completed + +Additionally, heartbeat messages are sent periodically to maintain the connection. + +This is recommended method for taskable agents to receive and process tasks in real-time. +Agents should maintain connection to this stream and process incoming tasks according to their capabilities. + +When an agent receives a task, it should update the task status using the `UpdateStatus` endpoint +to provide progress information back to Tasks API. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tasks().streamAsAgent( + AgentStreamRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**agentSelector:** `Optional` — The selector criteria to determine which tasks the agent receives. + +
+
+ +
+
+ +**heartbeatIntervalMs:** `Optional` — The time interval, defined in seconds, that determines the frequency at which to send heartbeat events. Defaults to 30s. + +
+
+
+
+ +
@@ -1243,8 +1416,8 @@ client.objects().getObjectMetadata( -## OAuth2 -
client.oAuth2.getToken(request) -> GetTokenResponse +## oauth +
client.oauth.getToken(request) -> GetTokenResponse
@@ -1256,7 +1429,7 @@ client.objects().getObjectMetadata(
-Support the client credentials authorization flow +Gets a new short-lived token using the specified client credentials
@@ -1271,7 +1444,7 @@ Support the client credentials authorization flow
```java -client.oAuth2().getToken( +client.oauth().getToken( GetTokenRequest .builder() .build() diff --git a/src/main/java/com/anduril/AsyncLattice.java b/src/main/java/com/anduril/AsyncLattice.java index cf78069..d18fc60 100644 --- a/src/main/java/com/anduril/AsyncLattice.java +++ b/src/main/java/com/anduril/AsyncLattice.java @@ -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; @@ -20,14 +20,14 @@ public class AsyncLattice { protected final Supplier objectsClient; - protected final Supplier oAuth2Client; + protected final Supplier 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() { @@ -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(); } /** diff --git a/src/main/java/com/anduril/AsyncLatticeBuilder.java b/src/main/java/com/anduril/AsyncLatticeBuilder.java index 2696fef..7071172 100644 --- a/src/main/java/com/anduril/AsyncLatticeBuilder.java +++ b/src/main/java/com/anduril/AsyncLatticeBuilder.java @@ -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; @@ -249,7 +249,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) diff --git a/src/main/java/com/anduril/Lattice.java b/src/main/java/com/anduril/Lattice.java index eb743ff..bd8b30c 100644 --- a/src/main/java/com/anduril/Lattice.java +++ b/src/main/java/com/anduril/Lattice.java @@ -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; @@ -20,14 +20,14 @@ public class Lattice { protected final Supplier objectsClient; - protected final Supplier oAuth2Client; + protected final Supplier 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() { @@ -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(); } /** diff --git a/src/main/java/com/anduril/LatticeBuilder.java b/src/main/java/com/anduril/LatticeBuilder.java index dcfbedd..2928d08 100644 --- a/src/main/java/com/anduril/LatticeBuilder.java +++ b/src/main/java/com/anduril/LatticeBuilder.java @@ -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; @@ -249,7 +249,7 @@ public static final class _CredentialsAuth extends LatticeBuilder { public Lattice 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) diff --git a/src/main/java/com/anduril/core/ClientOptions.java b/src/main/java/com/anduril/core/ClientOptions.java index 4e4b62c..b8861c9 100644 --- a/src/main/java/com/anduril/core/ClientOptions.java +++ b/src/main/java/com/anduril/core/ClientOptions.java @@ -35,10 +35,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.anduril:lattice-sdk/5.1.0"); + put("User-Agent", "com.anduril:lattice-sdk/5.2.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.anduril.fern:api-sdk"); - put("X-Fern-SDK-Version", "5.1.0"); + put("X-Fern-SDK-Version", "5.2.0"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/anduril/core/OAuthTokenSupplier.java b/src/main/java/com/anduril/core/OAuthTokenSupplier.java index f114a00..d6647e5 100644 --- a/src/main/java/com/anduril/core/OAuthTokenSupplier.java +++ b/src/main/java/com/anduril/core/OAuthTokenSupplier.java @@ -3,9 +3,9 @@ */ package com.anduril.core; -import com.anduril.resources.oauth2.OAuth2Client; -import com.anduril.resources.oauth2.requests.GetTokenRequest; -import com.anduril.resources.oauth2.types.GetTokenResponse; +import com.anduril.resources.oauth.OauthClient; +import com.anduril.resources.oauth.requests.GetTokenRequest; +import com.anduril.resources.oauth.types.GetTokenResponse; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.function.Supplier; @@ -17,13 +17,13 @@ public final class OAuthTokenSupplier implements Supplier { private final String clientSecret; - private final OAuth2Client authClient; + private final OauthClient authClient; private String accessToken; private Instant expiresAt; - public OAuthTokenSupplier(String clientId, String clientSecret, OAuth2Client authClient) { + public OAuthTokenSupplier(String clientId, String clientSecret, OauthClient authClient) { this.clientId = clientId; this.clientSecret = clientSecret; this.authClient = authClient; diff --git a/src/main/java/com/anduril/resources/oauth2/AsyncOAuth2Client.java b/src/main/java/com/anduril/resources/oauth/AsyncOauthClient.java similarity index 60% rename from src/main/java/com/anduril/resources/oauth2/AsyncOAuth2Client.java rename to src/main/java/com/anduril/resources/oauth/AsyncOauthClient.java index 7b9861a..70de354 100644 --- a/src/main/java/com/anduril/resources/oauth2/AsyncOAuth2Client.java +++ b/src/main/java/com/anduril/resources/oauth/AsyncOauthClient.java @@ -1,40 +1,40 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2; +package com.anduril.resources.oauth; import com.anduril.core.ClientOptions; import com.anduril.core.RequestOptions; -import com.anduril.resources.oauth2.requests.GetTokenRequest; -import com.anduril.resources.oauth2.types.GetTokenResponse; +import com.anduril.resources.oauth.requests.GetTokenRequest; +import com.anduril.resources.oauth.types.GetTokenResponse; import java.util.concurrent.CompletableFuture; -public class AsyncOAuth2Client { +public class AsyncOauthClient { protected final ClientOptions clientOptions; - private final AsyncRawOAuth2Client rawClient; + private final AsyncRawOauthClient rawClient; - public AsyncOAuth2Client(ClientOptions clientOptions) { + public AsyncOauthClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new AsyncRawOAuth2Client(clientOptions); + this.rawClient = new AsyncRawOauthClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public AsyncRawOAuth2Client withRawResponse() { + public AsyncRawOauthClient withRawResponse() { return this.rawClient; } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public CompletableFuture getToken(GetTokenRequest request) { return this.rawClient.getToken(request).thenApply(response -> response.body()); } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public CompletableFuture getToken(GetTokenRequest request, RequestOptions requestOptions) { return this.rawClient.getToken(request, requestOptions).thenApply(response -> response.body()); diff --git a/src/main/java/com/anduril/resources/oauth2/AsyncRawOAuth2Client.java b/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java similarity index 92% rename from src/main/java/com/anduril/resources/oauth2/AsyncRawOAuth2Client.java rename to src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java index 0a76d36..e440582 100644 --- a/src/main/java/com/anduril/resources/oauth2/AsyncRawOAuth2Client.java +++ b/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2; +package com.anduril.resources.oauth; import com.anduril.core.ClientOptions; import com.anduril.core.LatticeApiException; @@ -11,8 +11,8 @@ import com.anduril.core.RequestOptions; import com.anduril.errors.BadRequestError; import com.anduril.errors.UnauthorizedError; -import com.anduril.resources.oauth2.requests.GetTokenRequest; -import com.anduril.resources.oauth2.types.GetTokenResponse; +import com.anduril.resources.oauth.requests.GetTokenRequest; +import com.anduril.resources.oauth.types.GetTokenResponse; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -27,22 +27,22 @@ import okhttp3.ResponseBody; import org.jetbrains.annotations.NotNull; -public class AsyncRawOAuth2Client { +public class AsyncRawOauthClient { protected final ClientOptions clientOptions; - public AsyncRawOAuth2Client(ClientOptions clientOptions) { + public AsyncRawOauthClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public CompletableFuture> getToken(GetTokenRequest request) { return getToken(request, null); } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public CompletableFuture> getToken( GetTokenRequest request, RequestOptions requestOptions) { diff --git a/src/main/java/com/anduril/resources/oauth2/OAuth2Client.java b/src/main/java/com/anduril/resources/oauth/OauthClient.java similarity index 56% rename from src/main/java/com/anduril/resources/oauth2/OAuth2Client.java rename to src/main/java/com/anduril/resources/oauth/OauthClient.java index 5da9605..47fe1ee 100644 --- a/src/main/java/com/anduril/resources/oauth2/OAuth2Client.java +++ b/src/main/java/com/anduril/resources/oauth/OauthClient.java @@ -1,39 +1,39 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2; +package com.anduril.resources.oauth; import com.anduril.core.ClientOptions; import com.anduril.core.RequestOptions; -import com.anduril.resources.oauth2.requests.GetTokenRequest; -import com.anduril.resources.oauth2.types.GetTokenResponse; +import com.anduril.resources.oauth.requests.GetTokenRequest; +import com.anduril.resources.oauth.types.GetTokenResponse; -public class OAuth2Client { +public class OauthClient { protected final ClientOptions clientOptions; - private final RawOAuth2Client rawClient; + private final RawOauthClient rawClient; - public OAuth2Client(ClientOptions clientOptions) { + public OauthClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new RawOAuth2Client(clientOptions); + this.rawClient = new RawOauthClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public RawOAuth2Client withRawResponse() { + public RawOauthClient withRawResponse() { return this.rawClient; } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public GetTokenResponse getToken(GetTokenRequest request) { return this.rawClient.getToken(request).body(); } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public GetTokenResponse getToken(GetTokenRequest request, RequestOptions requestOptions) { return this.rawClient.getToken(request, requestOptions).body(); diff --git a/src/main/java/com/anduril/resources/oauth2/RawOAuth2Client.java b/src/main/java/com/anduril/resources/oauth/RawOauthClient.java similarity index 90% rename from src/main/java/com/anduril/resources/oauth2/RawOAuth2Client.java rename to src/main/java/com/anduril/resources/oauth/RawOauthClient.java index 1f221ed..abb5ea0 100644 --- a/src/main/java/com/anduril/resources/oauth2/RawOAuth2Client.java +++ b/src/main/java/com/anduril/resources/oauth/RawOauthClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2; +package com.anduril.resources.oauth; import com.anduril.core.ClientOptions; import com.anduril.core.LatticeApiException; @@ -11,8 +11,8 @@ import com.anduril.core.RequestOptions; import com.anduril.errors.BadRequestError; import com.anduril.errors.UnauthorizedError; -import com.anduril.resources.oauth2.requests.GetTokenRequest; -import com.anduril.resources.oauth2.types.GetTokenResponse; +import com.anduril.resources.oauth.requests.GetTokenRequest; +import com.anduril.resources.oauth.types.GetTokenResponse; import com.fasterxml.jackson.core.JsonProcessingException; import java.io.IOException; import okhttp3.FormBody; @@ -23,22 +23,22 @@ import okhttp3.Response; import okhttp3.ResponseBody; -public class RawOAuth2Client { +public class RawOauthClient { protected final ClientOptions clientOptions; - public RawOAuth2Client(ClientOptions clientOptions) { + public RawOauthClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public LatticeHttpResponse getToken(GetTokenRequest request) { return getToken(request, null); } /** - * Support the client credentials authorization flow + * Gets a new short-lived token using the specified client credentials */ public LatticeHttpResponse getToken(GetTokenRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) diff --git a/src/main/java/com/anduril/resources/oauth2/requests/GetTokenRequest.java b/src/main/java/com/anduril/resources/oauth/requests/GetTokenRequest.java similarity index 98% rename from src/main/java/com/anduril/resources/oauth2/requests/GetTokenRequest.java rename to src/main/java/com/anduril/resources/oauth/requests/GetTokenRequest.java index 11e1758..83a3243 100644 --- a/src/main/java/com/anduril/resources/oauth2/requests/GetTokenRequest.java +++ b/src/main/java/com/anduril/resources/oauth/requests/GetTokenRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2.requests; +package com.anduril.resources.oauth.requests; import com.anduril.core.ObjectMappers; import com.fasterxml.jackson.annotation.JsonAnyGetter; diff --git a/src/main/java/com/anduril/resources/oauth2/types/GetTokenResponse.java b/src/main/java/com/anduril/resources/oauth/types/GetTokenResponse.java similarity index 99% rename from src/main/java/com/anduril/resources/oauth2/types/GetTokenResponse.java rename to src/main/java/com/anduril/resources/oauth/types/GetTokenResponse.java index 1c52a01..68c7e2a 100644 --- a/src/main/java/com/anduril/resources/oauth2/types/GetTokenResponse.java +++ b/src/main/java/com/anduril/resources/oauth/types/GetTokenResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.anduril.resources.oauth2.types; +package com.anduril.resources.oauth.types; import com.anduril.core.ObjectMappers; import com.fasterxml.jackson.annotation.JsonAnyGetter; diff --git a/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java b/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java index 84bbf6a..86cece5 100644 --- a/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java @@ -10,14 +10,20 @@ import com.anduril.core.MediaTypes; import com.anduril.core.ObjectMappers; import com.anduril.core.RequestOptions; +import com.anduril.core.ResponseBodyReader; +import com.anduril.core.Stream; import com.anduril.errors.BadRequestError; import com.anduril.errors.NotFoundError; import com.anduril.errors.UnauthorizedError; import com.anduril.resources.tasks.requests.AgentListener; +import com.anduril.resources.tasks.requests.AgentStreamRequest; import com.anduril.resources.tasks.requests.GetTaskRequest; import com.anduril.resources.tasks.requests.TaskCreation; import com.anduril.resources.tasks.requests.TaskQuery; import com.anduril.resources.tasks.requests.TaskStatusUpdate; +import com.anduril.resources.tasks.requests.TaskStreamRequest; +import com.anduril.resources.tasks.types.StreamAsAgentResponse; +import com.anduril.resources.tasks.types.StreamTasksResponse; import com.anduril.types.AgentRequest; import com.anduril.types.Task; import com.anduril.types.TaskQueryResults; @@ -541,6 +547,109 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture>> streamTasks() { + return streamTasks(TaskStreamRequest.builder().build()); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture>> streamTasks( + RequestOptions requestOptions) { + return streamTasks(TaskStreamRequest.builder().build(), requestOptions); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture>> streamTasks( + TaskStreamRequest request) { + return streamTasks(request, null); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture>> streamTasks( + TaskStreamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api/v1/tasks/stream") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new LatticeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete(new LatticeHttpResponse<>( + Stream.fromSse(StreamTasksResponse.class, new ResponseBodyReader(response)), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new LatticeApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new LatticeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new LatticeException("Network error executing HTTP request", e)); + } + }); + return future; + } + /** * Establishes a server streaming connection that delivers tasks to taskable agents for execution. *

This method creates a persistent connection from Tasks API to an agent, allowing the server @@ -696,4 +805,152 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture>> streamAsAgent() { + return streamAsAgent(AgentStreamRequest.builder().build()); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture>> streamAsAgent( + RequestOptions requestOptions) { + return streamAsAgent(AgentStreamRequest.builder().build(), requestOptions); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture>> streamAsAgent( + AgentStreamRequest request) { + return streamAsAgent(request, null); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture>> streamAsAgent( + AgentStreamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api/v1/agent/stream") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new LatticeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete(new LatticeHttpResponse<>( + Stream.fromSse(StreamAsAgentResponse.class, new ResponseBodyReader(response)), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new LatticeApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new LatticeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new LatticeException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/anduril/resources/tasks/AsyncTasksClient.java b/src/main/java/com/anduril/resources/tasks/AsyncTasksClient.java index 5305bdf..63a2874 100644 --- a/src/main/java/com/anduril/resources/tasks/AsyncTasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/AsyncTasksClient.java @@ -6,10 +6,14 @@ import com.anduril.core.ClientOptions; import com.anduril.core.RequestOptions; import com.anduril.resources.tasks.requests.AgentListener; +import com.anduril.resources.tasks.requests.AgentStreamRequest; import com.anduril.resources.tasks.requests.GetTaskRequest; import com.anduril.resources.tasks.requests.TaskCreation; import com.anduril.resources.tasks.requests.TaskQuery; import com.anduril.resources.tasks.requests.TaskStatusUpdate; +import com.anduril.resources.tasks.requests.TaskStreamRequest; +import com.anduril.resources.tasks.types.StreamAsAgentResponse; +import com.anduril.resources.tasks.types.StreamTasksResponse; import com.anduril.types.AgentRequest; import com.anduril.types.Task; import com.anduril.types.TaskQueryResults; @@ -265,6 +269,43 @@ public CompletableFuture queryTasks(TaskQuery request, Request return this.rawClient.queryTasks(request, requestOptions).thenApply(response -> response.body()); } + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture> streamTasks() { + return this.rawClient.streamTasks().thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture> streamTasks(RequestOptions requestOptions) { + return this.rawClient.streamTasks(requestOptions).thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture> streamTasks(TaskStreamRequest request) { + return this.rawClient.streamTasks(request).thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public CompletableFuture> streamTasks( + TaskStreamRequest request, RequestOptions requestOptions) { + return this.rawClient.streamTasks(request, requestOptions).thenApply(response -> response.body()); + } + /** * Establishes a server streaming connection that delivers tasks to taskable agents for execution. *

This method creates a persistent connection from Tasks API to an agent, allowing the server @@ -356,4 +397,85 @@ public CompletableFuture listenAsAgent(AgentListener request) { public CompletableFuture listenAsAgent(AgentListener request, RequestOptions requestOptions) { return this.rawClient.listenAsAgent(request, requestOptions).thenApply(response -> response.body()); } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture> streamAsAgent() { + return this.rawClient.streamAsAgent().thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture> streamAsAgent(RequestOptions requestOptions) { + return this.rawClient.streamAsAgent(requestOptions).thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture> streamAsAgent(AgentStreamRequest request) { + return this.rawClient.streamAsAgent(request).thenApply(response -> response.body()); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public CompletableFuture> streamAsAgent( + AgentStreamRequest request, RequestOptions requestOptions) { + return this.rawClient.streamAsAgent(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/anduril/resources/tasks/RawTasksClient.java b/src/main/java/com/anduril/resources/tasks/RawTasksClient.java index 50fca28..5d7b75a 100644 --- a/src/main/java/com/anduril/resources/tasks/RawTasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/RawTasksClient.java @@ -10,14 +10,20 @@ import com.anduril.core.MediaTypes; import com.anduril.core.ObjectMappers; import com.anduril.core.RequestOptions; +import com.anduril.core.ResponseBodyReader; +import com.anduril.core.Stream; import com.anduril.errors.BadRequestError; import com.anduril.errors.NotFoundError; import com.anduril.errors.UnauthorizedError; import com.anduril.resources.tasks.requests.AgentListener; +import com.anduril.resources.tasks.requests.AgentStreamRequest; import com.anduril.resources.tasks.requests.GetTaskRequest; import com.anduril.resources.tasks.requests.TaskCreation; import com.anduril.resources.tasks.requests.TaskQuery; import com.anduril.resources.tasks.requests.TaskStatusUpdate; +import com.anduril.resources.tasks.requests.TaskStreamRequest; +import com.anduril.resources.tasks.types.StreamAsAgentResponse; +import com.anduril.resources.tasks.types.StreamTasksResponse; import com.anduril.types.AgentRequest; import com.anduril.types.Task; import com.anduril.types.TaskQueryResults; @@ -459,6 +465,90 @@ public LatticeHttpResponse queryTasks(TaskQuery request, Reque } } + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public LatticeHttpResponse> streamTasks() { + return streamTasks(TaskStreamRequest.builder().build()); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public LatticeHttpResponse> streamTasks(RequestOptions requestOptions) { + return streamTasks(TaskStreamRequest.builder().build(), requestOptions); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public LatticeHttpResponse> streamTasks(TaskStreamRequest request) { + return streamTasks(request, null); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public LatticeHttpResponse> streamTasks( + TaskStreamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api/v1/tasks/stream") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new LatticeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new LatticeHttpResponse<>( + Stream.fromSse(StreamTasksResponse.class, new ResponseBodyReader(response)), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new LatticeApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new LatticeException("Network error executing HTTP request", e); + } + } + /** * Establishes a server streaming connection that delivers tasks to taskable agents for execution. *

This method creates a persistent connection from Tasks API to an agent, allowing the server @@ -596,4 +686,132 @@ public LatticeHttpResponse listenAsAgent(AgentListener request, Re throw new LatticeException("Network error executing HTTP request", e); } } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public LatticeHttpResponse> streamAsAgent() { + return streamAsAgent(AgentStreamRequest.builder().build()); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public LatticeHttpResponse> streamAsAgent(RequestOptions requestOptions) { + return streamAsAgent(AgentStreamRequest.builder().build(), requestOptions); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public LatticeHttpResponse> streamAsAgent(AgentStreamRequest request) { + return streamAsAgent(request, null); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public LatticeHttpResponse> streamAsAgent( + AgentStreamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api/v1/agent/stream") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new LatticeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new LatticeHttpResponse<>( + Stream.fromSse(StreamAsAgentResponse.class, new ResponseBodyReader(response)), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new LatticeApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new LatticeException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/anduril/resources/tasks/TasksClient.java b/src/main/java/com/anduril/resources/tasks/TasksClient.java index 32ac79e..5d9eeb3 100644 --- a/src/main/java/com/anduril/resources/tasks/TasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/TasksClient.java @@ -6,10 +6,14 @@ import com.anduril.core.ClientOptions; import com.anduril.core.RequestOptions; import com.anduril.resources.tasks.requests.AgentListener; +import com.anduril.resources.tasks.requests.AgentStreamRequest; import com.anduril.resources.tasks.requests.GetTaskRequest; import com.anduril.resources.tasks.requests.TaskCreation; import com.anduril.resources.tasks.requests.TaskQuery; import com.anduril.resources.tasks.requests.TaskStatusUpdate; +import com.anduril.resources.tasks.requests.TaskStreamRequest; +import com.anduril.resources.tasks.types.StreamAsAgentResponse; +import com.anduril.resources.tasks.types.StreamTasksResponse; import com.anduril.types.AgentRequest; import com.anduril.types.Task; import com.anduril.types.TaskQueryResults; @@ -263,6 +267,42 @@ public TaskQueryResults queryTasks(TaskQuery request, RequestOptions requestOpti return this.rawClient.queryTasks(request, requestOptions).body(); } + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public Iterable streamTasks() { + return this.rawClient.streamTasks().body(); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public Iterable streamTasks(RequestOptions requestOptions) { + return this.rawClient.streamTasks(requestOptions).body(); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public Iterable streamTasks(TaskStreamRequest request) { + return this.rawClient.streamTasks(request).body(); + } + + /** + * Establishes a server streaming connection that delivers task updates in real-time using Server-Sent Events (SSE). + *

The stream delivers all existing non-terminal tasks when first connected, followed by real-time + * updates for task creation and status changes. Additionally, heartbeat messages are sent periodically to maintain the connection.

+ */ + public Iterable streamTasks(TaskStreamRequest request, RequestOptions requestOptions) { + return this.rawClient.streamTasks(request, requestOptions).body(); + } + /** * Establishes a server streaming connection that delivers tasks to taskable agents for execution. *

This method creates a persistent connection from Tasks API to an agent, allowing the server @@ -354,4 +394,84 @@ public AgentRequest listenAsAgent(AgentListener request) { public AgentRequest listenAsAgent(AgentListener request, RequestOptions requestOptions) { return this.rawClient.listenAsAgent(request, requestOptions).body(); } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public Iterable streamAsAgent() { + return this.rawClient.streamAsAgent().body(); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public Iterable streamAsAgent(RequestOptions requestOptions) { + return this.rawClient.streamAsAgent(requestOptions).body(); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public Iterable streamAsAgent(AgentStreamRequest request) { + return this.rawClient.streamAsAgent(request).body(); + } + + /** + * Establishes a server streaming connection that delivers tasks to taskable agents for execution + * using Server-Sent Events (SSE). + *

This method creates a connection from the Tasks API to an agent that streams relevant tasks to the listener agent. The agent receives a stream of tasks that match the entities specified by the tasks' selector criteria.

+ *

The stream delivers three types of requests:

+ *
    + *
  • ExecuteRequest: Contains a new task for the agent to execute
  • + *
  • CancelRequest: Indicates a task should be canceled
  • + *
  • CompleteRequest: Indicates a task should be completed
  • + *
+ *

Additionally, heartbeat messages are sent periodically to maintain the connection.

+ *

This is recommended method for taskable agents to receive and process tasks in real-time. + * Agents should maintain connection to this stream and process incoming tasks according to their capabilities.

+ *

When an agent receives a task, it should update the task status using the UpdateStatus endpoint + * to provide progress information back to Tasks API.

+ */ + public Iterable streamAsAgent(AgentStreamRequest request, RequestOptions requestOptions) { + return this.rawClient.streamAsAgent(request, requestOptions).body(); + } } diff --git a/src/main/java/com/anduril/resources/tasks/requests/AgentStreamRequest.java b/src/main/java/com/anduril/resources/tasks/requests/AgentStreamRequest.java new file mode 100644 index 0000000..69c1e8f --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/requests/AgentStreamRequest.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.requests; + +import com.anduril.core.ObjectMappers; +import com.anduril.types.EntityIdsSelector; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentStreamRequest.Builder.class) +public final class AgentStreamRequest { + private final Optional agentSelector; + + private final Optional heartbeatIntervalMs; + + private final Map additionalProperties; + + private AgentStreamRequest( + Optional agentSelector, + Optional heartbeatIntervalMs, + Map additionalProperties) { + this.agentSelector = agentSelector; + this.heartbeatIntervalMs = heartbeatIntervalMs; + this.additionalProperties = additionalProperties; + } + + /** + * @return The selector criteria to determine which tasks the agent receives. + */ + @JsonProperty("agentSelector") + public Optional getAgentSelector() { + return agentSelector; + } + + /** + * @return The time interval, defined in seconds, that determines the frequency at which to send heartbeat events. Defaults to 30s. + */ + @JsonProperty("heartbeatIntervalMs") + public Optional getHeartbeatIntervalMs() { + return heartbeatIntervalMs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentStreamRequest && equalTo((AgentStreamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AgentStreamRequest other) { + return agentSelector.equals(other.agentSelector) && heartbeatIntervalMs.equals(other.heartbeatIntervalMs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.agentSelector, this.heartbeatIntervalMs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional agentSelector = Optional.empty(); + + private Optional heartbeatIntervalMs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentStreamRequest other) { + agentSelector(other.getAgentSelector()); + heartbeatIntervalMs(other.getHeartbeatIntervalMs()); + return this; + } + + /** + *

The selector criteria to determine which tasks the agent receives.

+ */ + @JsonSetter(value = "agentSelector", nulls = Nulls.SKIP) + public Builder agentSelector(Optional agentSelector) { + this.agentSelector = agentSelector; + return this; + } + + public Builder agentSelector(EntityIdsSelector agentSelector) { + this.agentSelector = Optional.ofNullable(agentSelector); + return this; + } + + /** + *

The time interval, defined in seconds, that determines the frequency at which to send heartbeat events. Defaults to 30s.

+ */ + @JsonSetter(value = "heartbeatIntervalMs", nulls = Nulls.SKIP) + public Builder heartbeatIntervalMs(Optional heartbeatIntervalMs) { + this.heartbeatIntervalMs = heartbeatIntervalMs; + return this; + } + + public Builder heartbeatIntervalMs(Integer heartbeatIntervalMs) { + this.heartbeatIntervalMs = Optional.ofNullable(heartbeatIntervalMs); + return this; + } + + public AgentStreamRequest build() { + return new AgentStreamRequest(agentSelector, heartbeatIntervalMs, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/requests/TaskStreamRequest.java b/src/main/java/com/anduril/resources/tasks/requests/TaskStreamRequest.java new file mode 100644 index 0000000..1eeeebe --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/requests/TaskStreamRequest.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.requests; + +import com.anduril.core.ObjectMappers; +import com.anduril.resources.tasks.types.TaskStreamRequestTaskType; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskStreamRequest.Builder.class) +public final class TaskStreamRequest { + private final Optional heartbeatIntervalMs; + + private final Optional rateLimit; + + private final Optional excludePreexistingTasks; + + private final Optional taskType; + + private final Map additionalProperties; + + private TaskStreamRequest( + Optional heartbeatIntervalMs, + Optional rateLimit, + Optional excludePreexistingTasks, + Optional taskType, + Map additionalProperties) { + this.heartbeatIntervalMs = heartbeatIntervalMs; + this.rateLimit = rateLimit; + this.excludePreexistingTasks = excludePreexistingTasks; + this.taskType = taskType; + this.additionalProperties = additionalProperties; + } + + /** + * @return The time interval, in milliseconds, that determines the frequency at which to send heartbeat events. Defaults to 30000 (30 seconds). + */ + @JsonProperty("heartbeatIntervalMs") + public Optional getHeartbeatIntervalMs() { + return heartbeatIntervalMs; + } + + /** + * @return The time interval, in milliseconds, after an update for a given task before another one will be sent for the same task. + * If set, value must be >= 250. + */ + @JsonProperty("rateLimit") + public Optional getRateLimit() { + return rateLimit; + } + + /** + * @return Optional flag to only include tasks created or updated after the stream is initiated, and not any previous preexisting tasks. + * If unset or false, the stream will include any new tasks and task updates, as well as all preexisting tasks. + */ + @JsonProperty("excludePreexistingTasks") + public Optional getExcludePreexistingTasks() { + return excludePreexistingTasks; + } + + /** + * @return Optional filter that only returns tasks with specific types. If not provided, all task types will be streamed. + */ + @JsonProperty("taskType") + public Optional getTaskType() { + return taskType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskStreamRequest && equalTo((TaskStreamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskStreamRequest other) { + return heartbeatIntervalMs.equals(other.heartbeatIntervalMs) + && rateLimit.equals(other.rateLimit) + && excludePreexistingTasks.equals(other.excludePreexistingTasks) + && taskType.equals(other.taskType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.heartbeatIntervalMs, this.rateLimit, this.excludePreexistingTasks, this.taskType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional heartbeatIntervalMs = Optional.empty(); + + private Optional rateLimit = Optional.empty(); + + private Optional excludePreexistingTasks = Optional.empty(); + + private Optional taskType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TaskStreamRequest other) { + heartbeatIntervalMs(other.getHeartbeatIntervalMs()); + rateLimit(other.getRateLimit()); + excludePreexistingTasks(other.getExcludePreexistingTasks()); + taskType(other.getTaskType()); + return this; + } + + /** + *

The time interval, in milliseconds, that determines the frequency at which to send heartbeat events. Defaults to 30000 (30 seconds).

+ */ + @JsonSetter(value = "heartbeatIntervalMs", nulls = Nulls.SKIP) + public Builder heartbeatIntervalMs(Optional heartbeatIntervalMs) { + this.heartbeatIntervalMs = heartbeatIntervalMs; + return this; + } + + public Builder heartbeatIntervalMs(Integer heartbeatIntervalMs) { + this.heartbeatIntervalMs = Optional.ofNullable(heartbeatIntervalMs); + return this; + } + + /** + *

The time interval, in milliseconds, after an update for a given task before another one will be sent for the same task. + * If set, value must be >= 250.

+ */ + @JsonSetter(value = "rateLimit", nulls = Nulls.SKIP) + public Builder rateLimit(Optional rateLimit) { + this.rateLimit = rateLimit; + return this; + } + + public Builder rateLimit(Integer rateLimit) { + this.rateLimit = Optional.ofNullable(rateLimit); + return this; + } + + /** + *

Optional flag to only include tasks created or updated after the stream is initiated, and not any previous preexisting tasks. + * If unset or false, the stream will include any new tasks and task updates, as well as all preexisting tasks.

+ */ + @JsonSetter(value = "excludePreexistingTasks", nulls = Nulls.SKIP) + public Builder excludePreexistingTasks(Optional excludePreexistingTasks) { + this.excludePreexistingTasks = excludePreexistingTasks; + return this; + } + + public Builder excludePreexistingTasks(Boolean excludePreexistingTasks) { + this.excludePreexistingTasks = Optional.ofNullable(excludePreexistingTasks); + return this; + } + + /** + *

Optional filter that only returns tasks with specific types. If not provided, all task types will be streamed.

+ */ + @JsonSetter(value = "taskType", nulls = Nulls.SKIP) + public Builder taskType(Optional taskType) { + this.taskType = taskType; + return this; + } + + public Builder taskType(TaskStreamRequestTaskType taskType) { + this.taskType = Optional.ofNullable(taskType); + return this; + } + + public TaskStreamRequest build() { + return new TaskStreamRequest( + heartbeatIntervalMs, rateLimit, excludePreexistingTasks, taskType, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/types/StreamAsAgentResponse.java b/src/main/java/com/anduril/resources/tasks/types/StreamAsAgentResponse.java new file mode 100644 index 0000000..ad94dde --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/types/StreamAsAgentResponse.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.types; + +import com.anduril.types.AgentStreamEvent; +import com.anduril.types.StreamHeartbeat; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class StreamAsAgentResponse { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private StreamAsAgentResponse(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static StreamAsAgentResponse heartbeat(StreamHeartbeat value) { + return new StreamAsAgentResponse(new HeartbeatValue(value)); + } + + public static StreamAsAgentResponse agentRequest(AgentStreamEvent value) { + return new StreamAsAgentResponse(new AgentRequestValue(value)); + } + + public boolean isHeartbeat() { + return value instanceof HeartbeatValue; + } + + public boolean isAgentRequest() { + return value instanceof AgentRequestValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getHeartbeat() { + if (isHeartbeat()) { + return Optional.of(((HeartbeatValue) value).value); + } + return Optional.empty(); + } + + public Optional getAgentRequest() { + if (isAgentRequest()) { + return Optional.of(((AgentRequestValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitHeartbeat(StreamHeartbeat heartbeat); + + T visitAgentRequest(AgentStreamEvent agentRequest); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "event", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({@JsonSubTypes.Type(HeartbeatValue.class), @JsonSubTypes.Type(AgentRequestValue.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("heartbeat") + @JsonIgnoreProperties("event") + private static final class HeartbeatValue implements Value { + @JsonUnwrapped + private StreamHeartbeat value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private HeartbeatValue() {} + + private HeartbeatValue(StreamHeartbeat value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitHeartbeat(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HeartbeatValue && equalTo((HeartbeatValue) other); + } + + private boolean equalTo(HeartbeatValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamAsAgentResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("agent_request") + @JsonIgnoreProperties("event") + private static final class AgentRequestValue implements Value { + @JsonUnwrapped + private AgentStreamEvent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AgentRequestValue() {} + + private AgentRequestValue(AgentStreamEvent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAgentRequest(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentRequestValue && equalTo((AgentRequestValue) other); + } + + private boolean equalTo(AgentRequestValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamAsAgentResponse{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("event") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "StreamAsAgentResponse{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/types/StreamTasksResponse.java b/src/main/java/com/anduril/resources/tasks/types/StreamTasksResponse.java new file mode 100644 index 0000000..c763027 --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/types/StreamTasksResponse.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.types; + +import com.anduril.types.StreamHeartbeat; +import com.anduril.types.TaskStreamEvent; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class StreamTasksResponse { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private StreamTasksResponse(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static StreamTasksResponse heartbeat(StreamHeartbeat value) { + return new StreamTasksResponse(new HeartbeatValue(value)); + } + + public static StreamTasksResponse taskEvent(TaskStreamEvent value) { + return new StreamTasksResponse(new TaskEventValue(value)); + } + + public boolean isHeartbeat() { + return value instanceof HeartbeatValue; + } + + public boolean isTaskEvent() { + return value instanceof TaskEventValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getHeartbeat() { + if (isHeartbeat()) { + return Optional.of(((HeartbeatValue) value).value); + } + return Optional.empty(); + } + + public Optional getTaskEvent() { + if (isTaskEvent()) { + return Optional.of(((TaskEventValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitHeartbeat(StreamHeartbeat heartbeat); + + T visitTaskEvent(TaskStreamEvent taskEvent); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "event", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({@JsonSubTypes.Type(HeartbeatValue.class), @JsonSubTypes.Type(TaskEventValue.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("heartbeat") + @JsonIgnoreProperties("event") + private static final class HeartbeatValue implements Value { + @JsonUnwrapped + private StreamHeartbeat value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private HeartbeatValue() {} + + private HeartbeatValue(StreamHeartbeat value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitHeartbeat(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HeartbeatValue && equalTo((HeartbeatValue) other); + } + + private boolean equalTo(HeartbeatValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamTasksResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("task_event") + @JsonIgnoreProperties("event") + private static final class TaskEventValue implements Value { + @JsonUnwrapped + private TaskStreamEvent value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private TaskEventValue() {} + + private TaskEventValue(TaskStreamEvent value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitTaskEvent(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskEventValue && equalTo((TaskEventValue) other); + } + + private boolean equalTo(TaskEventValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "StreamTasksResponse{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("event") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "StreamTasksResponse{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskType.java b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskType.java new file mode 100644 index 0000000..a20411f --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskType.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = TaskStreamRequestTaskType.Deserializer.class) +public final class TaskStreamRequestTaskType { + private final Object value; + + private final int type; + + private TaskStreamRequestTaskType(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((TaskStreamRequestTaskTypeTaskTypeUrls) this.value); + } else if (this.type == 1) { + return visitor.visit((TaskStreamRequestTaskTypeTaskTypePrefix) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskStreamRequestTaskType && equalTo((TaskStreamRequestTaskType) other); + } + + private boolean equalTo(TaskStreamRequestTaskType other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static TaskStreamRequestTaskType of(TaskStreamRequestTaskTypeTaskTypeUrls value) { + return new TaskStreamRequestTaskType(value, 0); + } + + public static TaskStreamRequestTaskType of(TaskStreamRequestTaskTypeTaskTypePrefix value) { + return new TaskStreamRequestTaskType(value, 1); + } + + public interface Visitor { + T visit(TaskStreamRequestTaskTypeTaskTypeUrls value); + + T visit(TaskStreamRequestTaskTypeTaskTypePrefix value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TaskStreamRequestTaskType.class); + } + + @java.lang.Override + public TaskStreamRequestTaskType deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TaskStreamRequestTaskTypeTaskTypeUrls.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TaskStreamRequestTaskTypeTaskTypePrefix.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypePrefix.java b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypePrefix.java new file mode 100644 index 0000000..9eaa991 --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypePrefix.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskStreamRequestTaskTypeTaskTypePrefix.Builder.class) +public final class TaskStreamRequestTaskTypeTaskTypePrefix { + private final String taskTypePrefix; + + private final Map additionalProperties; + + private TaskStreamRequestTaskTypeTaskTypePrefix(String taskTypePrefix, Map additionalProperties) { + this.taskTypePrefix = taskTypePrefix; + this.additionalProperties = additionalProperties; + } + + /** + * @return Prefix string to match task types. Any task with a type that starts with this prefix will be included. + */ + @JsonProperty("taskTypePrefix") + public String getTaskTypePrefix() { + return taskTypePrefix; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskStreamRequestTaskTypeTaskTypePrefix + && equalTo((TaskStreamRequestTaskTypeTaskTypePrefix) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskStreamRequestTaskTypeTaskTypePrefix other) { + return taskTypePrefix.equals(other.taskTypePrefix); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.taskTypePrefix); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TaskTypePrefixStage builder() { + return new Builder(); + } + + public interface TaskTypePrefixStage { + /** + *

Prefix string to match task types. Any task with a type that starts with this prefix will be included.

+ */ + _FinalStage taskTypePrefix(@NotNull String taskTypePrefix); + + Builder from(TaskStreamRequestTaskTypeTaskTypePrefix other); + } + + public interface _FinalStage { + TaskStreamRequestTaskTypeTaskTypePrefix build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TaskTypePrefixStage, _FinalStage { + private String taskTypePrefix; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TaskStreamRequestTaskTypeTaskTypePrefix other) { + taskTypePrefix(other.getTaskTypePrefix()); + return this; + } + + /** + *

Prefix string to match task types. Any task with a type that starts with this prefix will be included.

+ *

Prefix string to match task types. Any task with a type that starts with this prefix will be included.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("taskTypePrefix") + public _FinalStage taskTypePrefix(@NotNull String taskTypePrefix) { + this.taskTypePrefix = Objects.requireNonNull(taskTypePrefix, "taskTypePrefix must not be null"); + return this; + } + + @java.lang.Override + public TaskStreamRequestTaskTypeTaskTypePrefix build() { + return new TaskStreamRequestTaskTypeTaskTypePrefix(taskTypePrefix, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypeUrls.java b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypeUrls.java new file mode 100644 index 0000000..9c58d28 --- /dev/null +++ b/src/main/java/com/anduril/resources/tasks/types/TaskStreamRequestTaskTypeTaskTypeUrls.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.resources.tasks.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskStreamRequestTaskTypeTaskTypeUrls.Builder.class) +public final class TaskStreamRequestTaskTypeTaskTypeUrls { + private final List taskTypeUrls; + + private final Map additionalProperties; + + private TaskStreamRequestTaskTypeTaskTypeUrls(List taskTypeUrls, Map additionalProperties) { + this.taskTypeUrls = taskTypeUrls; + this.additionalProperties = additionalProperties; + } + + /** + * @return List of exact task type URLs to match. + */ + @JsonProperty("taskTypeUrls") + public List getTaskTypeUrls() { + return taskTypeUrls; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskStreamRequestTaskTypeTaskTypeUrls + && equalTo((TaskStreamRequestTaskTypeTaskTypeUrls) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskStreamRequestTaskTypeTaskTypeUrls other) { + return taskTypeUrls.equals(other.taskTypeUrls); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.taskTypeUrls); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List taskTypeUrls = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TaskStreamRequestTaskTypeTaskTypeUrls other) { + taskTypeUrls(other.getTaskTypeUrls()); + return this; + } + + /** + *

List of exact task type URLs to match.

+ */ + @JsonSetter(value = "taskTypeUrls", nulls = Nulls.SKIP) + public Builder taskTypeUrls(List taskTypeUrls) { + this.taskTypeUrls.clear(); + if (taskTypeUrls != null) { + this.taskTypeUrls.addAll(taskTypeUrls); + } + return this; + } + + public Builder addTaskTypeUrls(String taskTypeUrls) { + this.taskTypeUrls.add(taskTypeUrls); + return this; + } + + public Builder addAllTaskTypeUrls(List taskTypeUrls) { + if (taskTypeUrls != null) { + this.taskTypeUrls.addAll(taskTypeUrls); + } + return this; + } + + public TaskStreamRequestTaskTypeTaskTypeUrls build() { + return new TaskStreamRequestTaskTypeTaskTypeUrls(taskTypeUrls, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/AgentStreamEvent.java b/src/main/java/com/anduril/types/AgentStreamEvent.java new file mode 100644 index 0000000..30305e7 --- /dev/null +++ b/src/main/java/com/anduril/types/AgentStreamEvent.java @@ -0,0 +1,148 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentStreamEvent.Builder.class) +public final class AgentStreamEvent implements IAgentTaskRequest { + private final Optional executeRequest; + + private final Optional cancelRequest; + + private final Optional completeRequest; + + private final Map additionalProperties; + + private AgentStreamEvent( + Optional executeRequest, + Optional cancelRequest, + Optional completeRequest, + Map additionalProperties) { + this.executeRequest = executeRequest; + this.cancelRequest = cancelRequest; + this.completeRequest = completeRequest; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("executeRequest") + @java.lang.Override + public Optional getExecuteRequest() { + return executeRequest; + } + + @JsonProperty("cancelRequest") + @java.lang.Override + public Optional getCancelRequest() { + return cancelRequest; + } + + @JsonProperty("completeRequest") + @java.lang.Override + public Optional getCompleteRequest() { + return completeRequest; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentStreamEvent && equalTo((AgentStreamEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AgentStreamEvent other) { + return executeRequest.equals(other.executeRequest) + && cancelRequest.equals(other.cancelRequest) + && completeRequest.equals(other.completeRequest); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.executeRequest, this.cancelRequest, this.completeRequest); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional executeRequest = Optional.empty(); + + private Optional cancelRequest = Optional.empty(); + + private Optional completeRequest = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentStreamEvent other) { + executeRequest(other.getExecuteRequest()); + cancelRequest(other.getCancelRequest()); + completeRequest(other.getCompleteRequest()); + return this; + } + + @JsonSetter(value = "executeRequest", nulls = Nulls.SKIP) + public Builder executeRequest(Optional executeRequest) { + this.executeRequest = executeRequest; + return this; + } + + public Builder executeRequest(ExecuteRequest executeRequest) { + this.executeRequest = Optional.ofNullable(executeRequest); + return this; + } + + @JsonSetter(value = "cancelRequest", nulls = Nulls.SKIP) + public Builder cancelRequest(Optional cancelRequest) { + this.cancelRequest = cancelRequest; + return this; + } + + public Builder cancelRequest(CancelRequest cancelRequest) { + this.cancelRequest = Optional.ofNullable(cancelRequest); + return this; + } + + @JsonSetter(value = "completeRequest", nulls = Nulls.SKIP) + public Builder completeRequest(Optional completeRequest) { + this.completeRequest = completeRequest; + return this; + } + + public Builder completeRequest(CompleteRequest completeRequest) { + this.completeRequest = Optional.ofNullable(completeRequest); + return this; + } + + public AgentStreamEvent build() { + return new AgentStreamEvent(executeRequest, cancelRequest, completeRequest, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/AgentStreamHeartbeat.java b/src/main/java/com/anduril/types/AgentStreamHeartbeat.java deleted file mode 100644 index a0dfb96..0000000 --- a/src/main/java/com/anduril/types/AgentStreamHeartbeat.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.anduril.types; - -import com.anduril.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -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.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentStreamHeartbeat.Builder.class) -public final class AgentStreamHeartbeat { - private final AgentStreamHeartbeatEvent event; - - private final AgentStreamHeartbeatData data; - - private final Map additionalProperties; - - private AgentStreamHeartbeat( - AgentStreamHeartbeatEvent event, AgentStreamHeartbeatData data, Map additionalProperties) { - this.event = event; - this.data = data; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("event") - public AgentStreamHeartbeatEvent getEvent() { - return event; - } - - @JsonProperty("data") - public AgentStreamHeartbeatData getData() { - return data; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentStreamHeartbeat && equalTo((AgentStreamHeartbeat) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AgentStreamHeartbeat other) { - return event.equals(other.event) && data.equals(other.data); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.event, this.data); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static EventStage builder() { - return new Builder(); - } - - public interface EventStage { - DataStage event(@NotNull AgentStreamHeartbeatEvent event); - - Builder from(AgentStreamHeartbeat other); - } - - public interface DataStage { - _FinalStage data(@NotNull AgentStreamHeartbeatData data); - } - - public interface _FinalStage { - AgentStreamHeartbeat build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements EventStage, DataStage, _FinalStage { - private AgentStreamHeartbeatEvent event; - - private AgentStreamHeartbeatData data; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AgentStreamHeartbeat other) { - event(other.getEvent()); - data(other.getData()); - return this; - } - - @java.lang.Override - @JsonSetter("event") - public DataStage event(@NotNull AgentStreamHeartbeatEvent event) { - this.event = Objects.requireNonNull(event, "event must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("data") - public _FinalStage data(@NotNull AgentStreamHeartbeatData data) { - this.data = Objects.requireNonNull(data, "data must not be null"); - return this; - } - - @java.lang.Override - public AgentStreamHeartbeat build() { - return new AgentStreamHeartbeat(event, data, additionalProperties); - } - } -} diff --git a/src/main/java/com/anduril/types/AgentStreamHeartbeatEvent.java b/src/main/java/com/anduril/types/AgentStreamHeartbeatEvent.java deleted file mode 100644 index 079c042..0000000 --- a/src/main/java/com/anduril/types/AgentStreamHeartbeatEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.anduril.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class AgentStreamHeartbeatEvent { - public static final AgentStreamHeartbeatEvent HEARTBEAT = - new AgentStreamHeartbeatEvent(Value.HEARTBEAT, "heartbeat"); - - private final Value value; - - private final String string; - - AgentStreamHeartbeatEvent(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof AgentStreamHeartbeatEvent - && this.string.equals(((AgentStreamHeartbeatEvent) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case HEARTBEAT: - return visitor.visitHeartbeat(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static AgentStreamHeartbeatEvent valueOf(String value) { - switch (value) { - case "heartbeat": - return HEARTBEAT; - default: - return new AgentStreamHeartbeatEvent(Value.UNKNOWN, value); - } - } - - public enum Value { - HEARTBEAT, - - UNKNOWN - } - - public interface Visitor { - T visitHeartbeat(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/anduril/types/AgentTaskRequest.java b/src/main/java/com/anduril/types/AgentTaskRequest.java new file mode 100644 index 0000000..7621667 --- /dev/null +++ b/src/main/java/com/anduril/types/AgentTaskRequest.java @@ -0,0 +1,148 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentTaskRequest.Builder.class) +public final class AgentTaskRequest implements IAgentTaskRequest { + private final Optional executeRequest; + + private final Optional cancelRequest; + + private final Optional completeRequest; + + private final Map additionalProperties; + + private AgentTaskRequest( + Optional executeRequest, + Optional cancelRequest, + Optional completeRequest, + Map additionalProperties) { + this.executeRequest = executeRequest; + this.cancelRequest = cancelRequest; + this.completeRequest = completeRequest; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("executeRequest") + @java.lang.Override + public Optional getExecuteRequest() { + return executeRequest; + } + + @JsonProperty("cancelRequest") + @java.lang.Override + public Optional getCancelRequest() { + return cancelRequest; + } + + @JsonProperty("completeRequest") + @java.lang.Override + public Optional getCompleteRequest() { + return completeRequest; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentTaskRequest && equalTo((AgentTaskRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AgentTaskRequest other) { + return executeRequest.equals(other.executeRequest) + && cancelRequest.equals(other.cancelRequest) + && completeRequest.equals(other.completeRequest); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.executeRequest, this.cancelRequest, this.completeRequest); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional executeRequest = Optional.empty(); + + private Optional cancelRequest = Optional.empty(); + + private Optional completeRequest = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentTaskRequest other) { + executeRequest(other.getExecuteRequest()); + cancelRequest(other.getCancelRequest()); + completeRequest(other.getCompleteRequest()); + return this; + } + + @JsonSetter(value = "executeRequest", nulls = Nulls.SKIP) + public Builder executeRequest(Optional executeRequest) { + this.executeRequest = executeRequest; + return this; + } + + public Builder executeRequest(ExecuteRequest executeRequest) { + this.executeRequest = Optional.ofNullable(executeRequest); + return this; + } + + @JsonSetter(value = "cancelRequest", nulls = Nulls.SKIP) + public Builder cancelRequest(Optional cancelRequest) { + this.cancelRequest = cancelRequest; + return this; + } + + public Builder cancelRequest(CancelRequest cancelRequest) { + this.cancelRequest = Optional.ofNullable(cancelRequest); + return this; + } + + @JsonSetter(value = "completeRequest", nulls = Nulls.SKIP) + public Builder completeRequest(Optional completeRequest) { + this.completeRequest = completeRequest; + return this; + } + + public Builder completeRequest(CompleteRequest completeRequest) { + this.completeRequest = Optional.ofNullable(completeRequest); + return this; + } + + public AgentTaskRequest build() { + return new AgentTaskRequest(executeRequest, cancelRequest, completeRequest, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/EntityStreamHeartbeat.java b/src/main/java/com/anduril/types/EntityStreamHeartbeat.java index b8980a2..c8d6c5f 100644 --- a/src/main/java/com/anduril/types/EntityStreamHeartbeat.java +++ b/src/main/java/com/anduril/types/EntityStreamHeartbeat.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.time.OffsetDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -21,21 +20,21 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EntityStreamHeartbeat.Builder.class) public final class EntityStreamHeartbeat implements IHeartbeatObject { - private final Optional timestamp; + private final Optional timestamp; private final Map additionalProperties; - private EntityStreamHeartbeat(Optional timestamp, Map additionalProperties) { + private EntityStreamHeartbeat(Optional timestamp, Map additionalProperties) { this.timestamp = timestamp; this.additionalProperties = additionalProperties; } /** - * @return timestamp of the heartbeat + * @return The timestamp at which the heartbeat message was sent. */ @JsonProperty("timestamp") @java.lang.Override - public Optional getTimestamp() { + public Optional getTimestamp() { return timestamp; } @@ -70,7 +69,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional timestamp = Optional.empty(); + private Optional timestamp = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -83,15 +82,15 @@ public Builder from(EntityStreamHeartbeat other) { } /** - *

timestamp of the heartbeat

+ *

The timestamp at which the heartbeat message was sent.

*/ @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) - public Builder timestamp(Optional timestamp) { + public Builder timestamp(Optional timestamp) { this.timestamp = timestamp; return this; } - public Builder timestamp(OffsetDateTime timestamp) { + public Builder timestamp(String timestamp) { this.timestamp = Optional.ofNullable(timestamp); return this; } diff --git a/src/main/java/com/anduril/types/HeartbeatObject.java b/src/main/java/com/anduril/types/HeartbeatObject.java index 0581615..664fc72 100644 --- a/src/main/java/com/anduril/types/HeartbeatObject.java +++ b/src/main/java/com/anduril/types/HeartbeatObject.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.time.OffsetDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -21,21 +20,21 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = HeartbeatObject.Builder.class) public final class HeartbeatObject implements IHeartbeatObject { - private final Optional timestamp; + private final Optional timestamp; private final Map additionalProperties; - private HeartbeatObject(Optional timestamp, Map additionalProperties) { + private HeartbeatObject(Optional timestamp, Map additionalProperties) { this.timestamp = timestamp; this.additionalProperties = additionalProperties; } /** - * @return timestamp of the heartbeat + * @return The timestamp at which the heartbeat message was sent. */ @JsonProperty("timestamp") @java.lang.Override - public Optional getTimestamp() { + public Optional getTimestamp() { return timestamp; } @@ -70,7 +69,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional timestamp = Optional.empty(); + private Optional timestamp = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -83,15 +82,15 @@ public Builder from(HeartbeatObject other) { } /** - *

timestamp of the heartbeat

+ *

The timestamp at which the heartbeat message was sent.

*/ @JsonSetter(value = "timestamp", nulls = Nulls.SKIP) - public Builder timestamp(Optional timestamp) { + public Builder timestamp(Optional timestamp) { this.timestamp = timestamp; return this; } - public Builder timestamp(OffsetDateTime timestamp) { + public Builder timestamp(String timestamp) { this.timestamp = Optional.ofNullable(timestamp); return this; } diff --git a/src/main/java/com/anduril/types/IAgentTaskRequest.java b/src/main/java/com/anduril/types/IAgentTaskRequest.java new file mode 100644 index 0000000..2d00103 --- /dev/null +++ b/src/main/java/com/anduril/types/IAgentTaskRequest.java @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import java.util.Optional; + +public interface IAgentTaskRequest { + Optional getExecuteRequest(); + + Optional getCancelRequest(); + + Optional getCompleteRequest(); +} diff --git a/src/main/java/com/anduril/types/IHeartbeatObject.java b/src/main/java/com/anduril/types/IHeartbeatObject.java index 4cf8b3e..1bea59a 100644 --- a/src/main/java/com/anduril/types/IHeartbeatObject.java +++ b/src/main/java/com/anduril/types/IHeartbeatObject.java @@ -3,9 +3,8 @@ */ package com.anduril.types; -import java.time.OffsetDateTime; import java.util.Optional; public interface IHeartbeatObject { - Optional getTimestamp(); + Optional getTimestamp(); } diff --git a/src/main/java/com/anduril/types/ITaskEventData.java b/src/main/java/com/anduril/types/ITaskEventData.java new file mode 100644 index 0000000..e0d44b6 --- /dev/null +++ b/src/main/java/com/anduril/types/ITaskEventData.java @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import java.util.Optional; + +public interface ITaskEventData { + Optional getTaskEvent(); +} diff --git a/src/main/java/com/anduril/types/AgentStreamHeartbeatData.java b/src/main/java/com/anduril/types/StreamHeartbeat.java similarity index 81% rename from src/main/java/com/anduril/types/AgentStreamHeartbeatData.java rename to src/main/java/com/anduril/types/StreamHeartbeat.java index a1671d3..f361b15 100644 --- a/src/main/java/com/anduril/types/AgentStreamHeartbeatData.java +++ b/src/main/java/com/anduril/types/StreamHeartbeat.java @@ -18,13 +18,13 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentStreamHeartbeatData.Builder.class) -public final class AgentStreamHeartbeatData { +@JsonDeserialize(builder = StreamHeartbeat.Builder.class) +public final class StreamHeartbeat implements IHeartbeatObject { private final Optional timestamp; private final Map additionalProperties; - private AgentStreamHeartbeatData(Optional timestamp, Map additionalProperties) { + private StreamHeartbeat(Optional timestamp, Map additionalProperties) { this.timestamp = timestamp; this.additionalProperties = additionalProperties; } @@ -33,6 +33,7 @@ private AgentStreamHeartbeatData(Optional timestamp, Map * @return The timestamp at which the heartbeat message was sent. */ @JsonProperty("timestamp") + @java.lang.Override public Optional getTimestamp() { return timestamp; } @@ -40,7 +41,7 @@ public Optional getTimestamp() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AgentStreamHeartbeatData && equalTo((AgentStreamHeartbeatData) other); + return other instanceof StreamHeartbeat && equalTo((StreamHeartbeat) other); } @JsonAnyGetter @@ -48,7 +49,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(AgentStreamHeartbeatData other) { + private boolean equalTo(StreamHeartbeat other) { return timestamp.equals(other.timestamp); } @@ -75,7 +76,7 @@ public static final class Builder { private Builder() {} - public Builder from(AgentStreamHeartbeatData other) { + public Builder from(StreamHeartbeat other) { timestamp(other.getTimestamp()); return this; } @@ -94,8 +95,8 @@ public Builder timestamp(String timestamp) { return this; } - public AgentStreamHeartbeatData build() { - return new AgentStreamHeartbeatData(timestamp, additionalProperties); + public StreamHeartbeat build() { + return new StreamHeartbeat(timestamp, additionalProperties); } } } diff --git a/src/main/java/com/anduril/types/TaskEventData.java b/src/main/java/com/anduril/types/TaskEventData.java new file mode 100644 index 0000000..4c8166f --- /dev/null +++ b/src/main/java/com/anduril/types/TaskEventData.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskEventData.Builder.class) +public final class TaskEventData implements ITaskEventData { + private final Optional taskEvent; + + private final Map additionalProperties; + + private TaskEventData(Optional taskEvent, Map additionalProperties) { + this.taskEvent = taskEvent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The task event that occurred. + */ + @JsonProperty("taskEvent") + public Optional getTaskEvent() { + return taskEvent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskEventData && equalTo((TaskEventData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskEventData other) { + return taskEvent.equals(other.taskEvent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.taskEvent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional taskEvent = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TaskEventData other) { + taskEvent(other.getTaskEvent()); + return this; + } + + /** + *

The task event that occurred.

+ */ + @JsonSetter(value = "taskEvent", nulls = Nulls.SKIP) + public Builder taskEvent(Optional taskEvent) { + this.taskEvent = taskEvent; + return this; + } + + public Builder taskEvent(TaskEventDataTaskEvent taskEvent) { + this.taskEvent = Optional.ofNullable(taskEvent); + return this; + } + + public TaskEventData build() { + return new TaskEventData(taskEvent, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/TaskEventDataTaskEvent.java b/src/main/java/com/anduril/types/TaskEventDataTaskEvent.java new file mode 100644 index 0000000..86845ad --- /dev/null +++ b/src/main/java/com/anduril/types/TaskEventDataTaskEvent.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskEventDataTaskEvent.Builder.class) +public final class TaskEventDataTaskEvent { + private final Optional eventType; + + private final Optional task; + + private final Map additionalProperties; + + private TaskEventDataTaskEvent( + Optional eventType, + Optional task, + Map additionalProperties) { + this.eventType = eventType; + this.task = task; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of event that occurred for this task. + */ + @JsonProperty("eventType") + public Optional getEventType() { + return eventType; + } + + /** + * @return The task associated with this event. + */ + @JsonProperty("task") + public Optional getTask() { + return task; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskEventDataTaskEvent && equalTo((TaskEventDataTaskEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskEventDataTaskEvent other) { + return eventType.equals(other.eventType) && task.equals(other.task); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventType, this.task); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional eventType = Optional.empty(); + + private Optional task = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TaskEventDataTaskEvent other) { + eventType(other.getEventType()); + task(other.getTask()); + return this; + } + + /** + *

The type of event that occurred for this task.

+ */ + @JsonSetter(value = "eventType", nulls = Nulls.SKIP) + public Builder eventType(Optional eventType) { + this.eventType = eventType; + return this; + } + + public Builder eventType(TaskEventDataTaskEventEventType eventType) { + this.eventType = Optional.ofNullable(eventType); + return this; + } + + /** + *

The task associated with this event.

+ */ + @JsonSetter(value = "task", nulls = Nulls.SKIP) + public Builder task(Optional task) { + this.task = task; + return this; + } + + public Builder task(Task task) { + this.task = Optional.ofNullable(task); + return this; + } + + public TaskEventDataTaskEvent build() { + return new TaskEventDataTaskEvent(eventType, task, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/TaskEventDataTaskEventEventType.java b/src/main/java/com/anduril/types/TaskEventDataTaskEventEventType.java new file mode 100644 index 0000000..108970e --- /dev/null +++ b/src/main/java/com/anduril/types/TaskEventDataTaskEventEventType.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class TaskEventDataTaskEventEventType { + public static final TaskEventDataTaskEventEventType EVENT_TYPE_PREEXISTING = + new TaskEventDataTaskEventEventType(Value.EVENT_TYPE_PREEXISTING, "EVENT_TYPE_PREEXISTING"); + + public static final TaskEventDataTaskEventEventType EVENT_TYPE_INVALID = + new TaskEventDataTaskEventEventType(Value.EVENT_TYPE_INVALID, "EVENT_TYPE_INVALID"); + + public static final TaskEventDataTaskEventEventType EVENT_TYPE_UPDATE = + new TaskEventDataTaskEventEventType(Value.EVENT_TYPE_UPDATE, "EVENT_TYPE_UPDATE"); + + public static final TaskEventDataTaskEventEventType EVENT_TYPE_CREATED = + new TaskEventDataTaskEventEventType(Value.EVENT_TYPE_CREATED, "EVENT_TYPE_CREATED"); + + private final Value value; + + private final String string; + + TaskEventDataTaskEventEventType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof TaskEventDataTaskEventEventType + && this.string.equals(((TaskEventDataTaskEventEventType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EVENT_TYPE_PREEXISTING: + return visitor.visitEventTypePreexisting(); + case EVENT_TYPE_INVALID: + return visitor.visitEventTypeInvalid(); + case EVENT_TYPE_UPDATE: + return visitor.visitEventTypeUpdate(); + case EVENT_TYPE_CREATED: + return visitor.visitEventTypeCreated(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TaskEventDataTaskEventEventType valueOf(String value) { + switch (value) { + case "EVENT_TYPE_PREEXISTING": + return EVENT_TYPE_PREEXISTING; + case "EVENT_TYPE_INVALID": + return EVENT_TYPE_INVALID; + case "EVENT_TYPE_UPDATE": + return EVENT_TYPE_UPDATE; + case "EVENT_TYPE_CREATED": + return EVENT_TYPE_CREATED; + default: + return new TaskEventDataTaskEventEventType(Value.UNKNOWN, value); + } + } + + public enum Value { + EVENT_TYPE_INVALID, + + EVENT_TYPE_CREATED, + + EVENT_TYPE_UPDATE, + + EVENT_TYPE_PREEXISTING, + + UNKNOWN + } + + public interface Visitor { + T visitEventTypeInvalid(); + + T visitEventTypeCreated(); + + T visitEventTypeUpdate(); + + T visitEventTypePreexisting(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/anduril/types/TaskStreamEvent.java b/src/main/java/com/anduril/types/TaskStreamEvent.java new file mode 100644 index 0000000..60865ea --- /dev/null +++ b/src/main/java/com/anduril/types/TaskStreamEvent.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.anduril.types; + +import com.anduril.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TaskStreamEvent.Builder.class) +public final class TaskStreamEvent implements ITaskEventData { + private final Optional taskEvent; + + private final Map additionalProperties; + + private TaskStreamEvent(Optional taskEvent, Map additionalProperties) { + this.taskEvent = taskEvent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The task event that occurred. + */ + @JsonProperty("taskEvent") + public Optional getTaskEvent() { + return taskEvent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TaskStreamEvent && equalTo((TaskStreamEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TaskStreamEvent other) { + return taskEvent.equals(other.taskEvent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.taskEvent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional taskEvent = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TaskStreamEvent other) { + taskEvent(other.getTaskEvent()); + return this; + } + + /** + *

The task event that occurred.

+ */ + @JsonSetter(value = "taskEvent", nulls = Nulls.SKIP) + public Builder taskEvent(Optional taskEvent) { + this.taskEvent = taskEvent; + return this; + } + + public Builder taskEvent(TaskEventDataTaskEvent taskEvent) { + this.taskEvent = Optional.ofNullable(taskEvent); + return this; + } + + public TaskStreamEvent build() { + return new TaskStreamEvent(taskEvent, additionalProperties); + } + } +}