diff --git a/.fern/metadata.json b/.fern/metadata.json index 0f0f30e0..fc587531 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,10 +1,10 @@ { - "cliVersion": "3.51.2", + "cliVersion": "3.70.1", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "3.29.1", + "generatorVersion": "3.34.8", "generatorConfig": { "client-class-name": "Lattice", "package-prefix": "com.anduril" }, - "sdkVersion": "5.2.0" + "sdkVersion": "5.3.0" } \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 50dd7ca3..00000000 --- a/README.md +++ /dev/null @@ -1,290 +0,0 @@ -# Lattice SDK Java Library - -![](https://www.anduril.com/lattice-sdk/) - -[![Maven Central](https://img.shields.io/maven-central/v/com.anduril/lattice-sdk)](https://central.sonatype.com/artifact/com.anduril/lattice-sdk) - -The Lattice SDK Java library provides convenient access to the Lattice SDK APIs from Java. - -## Table of Contents - -- [Documentation](#documentation) -- [Requirements](#requirements) -- [Installation](#installation) -- [Support](#support) -- [Usage](#usage) -- [Authentication](#authentication) -- [Environments](#environments) -- [Base Url](#base-url) -- [Exception Handling](#exception-handling) -- [Advanced](#advanced) - - [Custom Client](#custom-client) - - [Retries](#retries) - - [Timeouts](#timeouts) - - [Custom Headers](#custom-headers) - - [Access Raw Response Data](#access-raw-response-data) -- [Reference](#reference) - -## Documentation - -API reference documentation is available [here](https://developer.anduril.com/). - -## Requirements - -This repository is tested against Java 1.8 or later. - -## Installation - -### Gradle - -Add the dependency in your `build.gradle` file: - -```groovy -dependencies { - implementation 'com.anduril:lattice-sdk' -} -``` - -### Maven - -Add the dependency in your `pom.xml` file: - -```xml - - com.anduril - lattice-sdk - 5.2.0 - -``` - -## Support - -For support with this library please reach out to your Anduril representative. - -## Usage - -Instantiate and use the client with the following: - -```java -package com.example.usage; - -import com.anduril.Lattice; -import com.anduril.resources.entities.requests.EntityEventRequest; - -public class Example { - public static void main(String[] args) { - Lattice client = Lattice.withCredentials("", "") - .build() - ; - - client.entities().longPollEntityEvents( - EntityEventRequest - .builder() - .sessionToken("sessionToken") - .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(); -``` - -## 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. - -```java -import com.anduril.Lattice; -import com.anduril.core.Environment; - -Lattice client = Lattice - .builder() - .environment(Environment.Default) - .build(); -``` - -## Base Url - -You can set a custom base URL when constructing the client. - -```java -import com.anduril.Lattice; - -Lattice client = Lattice - .builder() - .url("https://example.com") - .build(); -``` - -## Exception Handling - -When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown. - -```java -import com.anduril.core.AndurilApiApiException; - -try{ - client.entities().longPollEntityEvents(...); -} catch (AndurilApiApiException e){ - // Do something with the API exception... -} -``` - -## Advanced - -### Custom Client - -This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one. -However, you can pass your own client like so: - -```java -import com.anduril.Lattice; -import okhttp3.OkHttpClient; - -OkHttpClient customClient = ...; - -Lattice client = Lattice - .builder() - .httpClient(customClient) - .build(); -``` - -### Retries - -The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long -as the request is deemed retryable and the number of retry attempts has not grown larger than the configured -retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect -the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header -(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff. - -A request is deemed retryable when any of the following HTTP status codes is returned: - -- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) -- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) -- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) - -Use the `maxRetries` client option to configure this behavior. - -```java -import com.anduril.Lattice; - -Lattice client = Lattice - .builder() - .maxRetries(1) - .build(); -``` - -### Timeouts - -The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level. -```java -import com.anduril.Lattice; -import com.anduril.core.RequestOptions; - -// Client level -Lattice client = Lattice - .builder() - .timeout(60) - .build(); - -// Request level -client.entities().longPollEntityEvents( - ..., - RequestOptions - .builder() - .timeout(60) - .build() -); -``` - -### Custom Headers - -The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level. - -```java -import com.anduril.Lattice; -import com.anduril.core.RequestOptions; - -// Client level -Lattice client = Lattice - .builder() - .addHeader("X-Custom-Header", "custom-value") - .addHeader("X-Request-Id", "abc-123") - .build(); -; - -// Request level -client.entities().longPollEntityEvents( - ..., - RequestOptions - .builder() - .addHeader("X-Request-Header", "request-value") - .build() -); -``` - -### Access Raw Response Data - -The SDK provides access to raw response data, including headers, through the `withRawResponse()` method. -The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods. -(A normal client's `response` is identical to a raw client's `response.body()`.) - -```java -LongPollEntityEventsHttpResponse response = client.entities().withRawResponse().longPollEntityEvents(...); - -System.out.println(response.body()); -System.out.println(response.headers().get("X-My-Header")); -``` - -## Reference - -A full reference for this library is available [here](https://github.com/anduril/lattice-sdk-java/blob/HEAD/./reference.md). diff --git a/build.gradle b/build.gradle index 078fd98e..04322a25 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'com.anduril' -version = '5.2.0' +version = '5.3.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,21 +78,21 @@ publishing { maven(MavenPublication) { groupId = 'com.anduril' artifactId = 'lattice-sdk' - version = '5.2.0' + version = '5.3.0' from components.java pom { - name = 'Anduril Industries, Inc.' - description = 'Anduril Lattice SDK for Java' - url = 'https://developer.anduril.com' + name = 'anduril' + description = 'The official SDK of anduril' + url = 'https://buildwithfern.com' licenses { license { - name = 'Anduril Lattice Software Development Kit License Agreement' + name = 'Custom License (LICENSE)' } } developers { developer { - name = 'Anduril Industries, Inc.' - email = 'lattice-developers@anduril.com' + name = 'anduril' + email = 'developers@anduril.com' } } scm { diff --git a/reference.md b/reference.md index 8386af5b..6e6f2517 100644 --- a/reference.md +++ b/reference.md @@ -1159,6 +1159,14 @@ client.objects().listObjects( **allObjectsInMesh:** `Optional` — Lists objects across all environment nodes in a Lattice Mesh. + + + +
+
+ +**maxPageSize:** `Optional` — Sets the maximum number of items that should be returned on a single page. +
diff --git a/src/main/java/com/anduril/core/ClientOptions.java b/src/main/java/com/anduril/core/ClientOptions.java index b8861c9d..971031df 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.2.0"); + put("User-Agent", "com.anduril:lattice-sdk/5.3.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.anduril.fern:api-sdk"); - put("X-Fern-SDK-Version", "5.2.0"); + put("X-Fern-SDK-Version", "5.3.0"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/anduril/core/RequestOptions.java b/src/main/java/com/anduril/core/RequestOptions.java index f0fe01ef..e6a9bffe 100644 --- a/src/main/java/com/anduril/core/RequestOptions.java +++ b/src/main/java/com/anduril/core/RequestOptions.java @@ -18,15 +18,23 @@ public final class RequestOptions { private final Map> headerSuppliers; + private final Map queryParameters; + + private final Map> queryParameterSuppliers; + private RequestOptions( Optional timeout, TimeUnit timeoutTimeUnit, Map headers, - Map> headerSuppliers) { + Map> headerSuppliers, + Map queryParameters, + Map> queryParameterSuppliers) { this.timeout = timeout; this.timeoutTimeUnit = timeoutTimeUnit; this.headers = headers; this.headerSuppliers = headerSuppliers; + this.queryParameters = queryParameters; + this.queryParameterSuppliers = queryParameterSuppliers; } public Optional getTimeout() { @@ -46,6 +54,14 @@ public Map getHeaders() { return headers; } + public Map getQueryParameters() { + Map queryParameters = new HashMap<>(this.queryParameters); + this.queryParameterSuppliers.forEach((key, supplier) -> { + queryParameters.put(key, supplier.get()); + }); + return queryParameters; + } + public static Builder builder() { return new Builder(); } @@ -59,6 +75,10 @@ public static class Builder { private final Map> headerSuppliers = new HashMap<>(); + private final Map queryParameters = new HashMap<>(); + + private final Map> queryParameterSuppliers = new HashMap<>(); + public Builder timeout(Integer timeout) { this.timeout = Optional.of(timeout); return this; @@ -80,8 +100,19 @@ public Builder addHeader(String key, Supplier value) { return this; } + public Builder addQueryParameter(String key, String value) { + this.queryParameters.put(key, value); + return this; + } + + public Builder addQueryParameter(String key, Supplier value) { + this.queryParameterSuppliers.put(key, value); + return this; + } + public RequestOptions build() { - return new RequestOptions(timeout, timeoutTimeUnit, headers, headerSuppliers); + return new RequestOptions( + timeout, timeoutTimeUnit, headers, headerSuppliers, queryParameters, queryParameterSuppliers); } } } diff --git a/src/main/java/com/anduril/errors/ContentTooLargeError.java b/src/main/java/com/anduril/errors/ContentTooLargeError.java index 7968bc85..499cbc0a 100644 --- a/src/main/java/com/anduril/errors/ContentTooLargeError.java +++ b/src/main/java/com/anduril/errors/ContentTooLargeError.java @@ -4,20 +4,21 @@ package com.anduril.errors; import com.anduril.core.LatticeApiException; +import com.anduril.resources.object.types.Error; import okhttp3.Response; public final class ContentTooLargeError extends LatticeApiException { /** * The body of the response that triggered the exception. */ - private final Object body; + private final Error body; - public ContentTooLargeError(Object body) { + public ContentTooLargeError(Error body) { super("ContentTooLargeError", 413, body); this.body = body; } - public ContentTooLargeError(Object body, Response rawResponse) { + public ContentTooLargeError(Error body, Response rawResponse) { super("ContentTooLargeError", 413, body, rawResponse); this.body = body; } @@ -26,7 +27,7 @@ public ContentTooLargeError(Object body, Response rawResponse) { * @return the body */ @java.lang.Override - public Object body() { + public Error body() { return this.body; } } diff --git a/src/main/java/com/anduril/errors/InsufficientStorageError.java b/src/main/java/com/anduril/errors/InsufficientStorageError.java index feda2244..6f99a90c 100644 --- a/src/main/java/com/anduril/errors/InsufficientStorageError.java +++ b/src/main/java/com/anduril/errors/InsufficientStorageError.java @@ -4,20 +4,21 @@ package com.anduril.errors; import com.anduril.core.LatticeApiException; +import com.anduril.resources.object.types.Error; import okhttp3.Response; public final class InsufficientStorageError extends LatticeApiException { /** * The body of the response that triggered the exception. */ - private final Object body; + private final Error body; - public InsufficientStorageError(Object body) { + public InsufficientStorageError(Error body) { super("InsufficientStorageError", 507, body); this.body = body; } - public InsufficientStorageError(Object body, Response rawResponse) { + public InsufficientStorageError(Error body, Response rawResponse) { super("InsufficientStorageError", 507, body, rawResponse); this.body = body; } @@ -26,7 +27,7 @@ public InsufficientStorageError(Object body, Response rawResponse) { * @return the body */ @java.lang.Override - public Object body() { + public Error body() { return this.body; } } diff --git a/src/main/java/com/anduril/errors/RequestTimeoutError.java b/src/main/java/com/anduril/errors/RequestTimeoutError.java index 3b64d920..2cc98b5d 100644 --- a/src/main/java/com/anduril/errors/RequestTimeoutError.java +++ b/src/main/java/com/anduril/errors/RequestTimeoutError.java @@ -4,20 +4,21 @@ package com.anduril.errors; import com.anduril.core.LatticeApiException; +import com.anduril.resources.entity.types.Error; import okhttp3.Response; public final class RequestTimeoutError extends LatticeApiException { /** * The body of the response that triggered the exception. */ - private final Object body; + private final Error body; - public RequestTimeoutError(Object body) { + public RequestTimeoutError(Error body) { super("RequestTimeoutError", 408, body); this.body = body; } - public RequestTimeoutError(Object body, Response rawResponse) { + public RequestTimeoutError(Error body, Response rawResponse) { super("RequestTimeoutError", 408, body, rawResponse); this.body = body; } @@ -26,7 +27,7 @@ public RequestTimeoutError(Object body, Response rawResponse) { * @return the body */ @java.lang.Override - public Object body() { + public Error body() { return this.body; } } diff --git a/src/main/java/com/anduril/errors/TooManyRequestsError.java b/src/main/java/com/anduril/errors/TooManyRequestsError.java index 16d26e35..9ce489c8 100644 --- a/src/main/java/com/anduril/errors/TooManyRequestsError.java +++ b/src/main/java/com/anduril/errors/TooManyRequestsError.java @@ -4,20 +4,21 @@ package com.anduril.errors; import com.anduril.core.LatticeApiException; +import com.anduril.resources.entity.types.Error; import okhttp3.Response; public final class TooManyRequestsError extends LatticeApiException { /** * The body of the response that triggered the exception. */ - private final Object body; + private final Error body; - public TooManyRequestsError(Object body) { + public TooManyRequestsError(Error body) { super("TooManyRequestsError", 429, body); this.body = body; } - public TooManyRequestsError(Object body, Response rawResponse) { + public TooManyRequestsError(Error body, Response rawResponse) { super("TooManyRequestsError", 429, body, rawResponse); this.body = body; } @@ -26,7 +27,7 @@ public TooManyRequestsError(Object body, Response rawResponse) { * @return the body */ @java.lang.Override - public Object body() { + public Error body() { return this.body; } } diff --git a/src/main/java/com/anduril/resources/entities/AsyncRawEntitiesClient.java b/src/main/java/com/anduril/resources/entities/AsyncRawEntitiesClient.java index d3a814ad..c2aa9247 100644 --- a/src/main/java/com/anduril/resources/entities/AsyncRawEntitiesClient.java +++ b/src/main/java/com/anduril/resources/entities/AsyncRawEntitiesClient.java @@ -23,6 +23,7 @@ import com.anduril.resources.entities.requests.GetEntityRequest; import com.anduril.resources.entities.requests.RemoveEntityOverrideRequest; import com.anduril.resources.entities.types.StreamEntitiesResponse; +import com.anduril.resources.entity.types.Error; import com.anduril.types.Entity; import com.anduril.types.EntityEventResponse; import com.fasterxml.jackson.core.JsonProcessingException; @@ -91,10 +92,14 @@ public CompletableFuture> publishEntity(Entity reque * provenance.sourceUpdateTime is greater than the provenance.sourceUpdateTime of the existing entity.

*/ public CompletableFuture> publishEntity(Entity request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities") - .build(); + .addPathSegments("api/v1/entities"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -103,7 +108,7 @@ public CompletableFuture> publishEntity(Entity reque throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -171,13 +176,17 @@ public CompletableFuture> getEntity(String entityId, public CompletableFuture> getEntity( String entityId, GetEntityRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") - .addPathSegment(entityId) - .build(); + .addPathSegment(entityId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -283,13 +292,17 @@ public CompletableFuture> overrideEntity( */ public CompletableFuture> overrideEntity( String entityId, String fieldPath, EntityOverride request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") .addPathSegment(entityId) .addPathSegments("override") - .addPathSegment(fieldPath) - .build(); + .addPathSegment(fieldPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -298,7 +311,7 @@ public CompletableFuture> overrideEntity( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -387,15 +400,19 @@ public CompletableFuture> removeEntityOverride( */ public CompletableFuture> removeEntityOverride( String entityId, String fieldPath, RemoveEntityOverrideRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") .addPathSegment(entityId) .addPathSegments("override") - .addPathSegment(fieldPath) - .build(); + .addPathSegment(fieldPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("DELETE", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -482,10 +499,14 @@ public CompletableFuture> longPollEntit */ public CompletableFuture> longPollEntityEvents( EntityEventRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities/events") - .build(); + .addPathSegments("api/v1/entities/events"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -494,7 +515,7 @@ public CompletableFuture> longPollEntit throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -535,12 +556,12 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO return; case 408: future.completeExceptionally(new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); return; case 429: future.completeExceptionally(new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); return; } @@ -644,10 +665,14 @@ public CompletableFuture>> */ public CompletableFuture>> streamEntities( EntityStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities/stream") - .build(); + .addPathSegments("api/v1/entities/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -656,11 +681,10 @@ public CompletableFuture>> throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { diff --git a/src/main/java/com/anduril/resources/entities/RawEntitiesClient.java b/src/main/java/com/anduril/resources/entities/RawEntitiesClient.java index 4dae53fd..889da9c8 100644 --- a/src/main/java/com/anduril/resources/entities/RawEntitiesClient.java +++ b/src/main/java/com/anduril/resources/entities/RawEntitiesClient.java @@ -23,6 +23,7 @@ import com.anduril.resources.entities.requests.GetEntityRequest; import com.anduril.resources.entities.requests.RemoveEntityOverrideRequest; import com.anduril.resources.entities.types.StreamEntitiesResponse; +import com.anduril.resources.entity.types.Error; import com.anduril.types.Entity; import com.anduril.types.EntityEventResponse; import com.fasterxml.jackson.core.JsonProcessingException; @@ -87,10 +88,14 @@ public LatticeHttpResponse publishEntity(Entity request) { * provenance.sourceUpdateTime is greater than the provenance.sourceUpdateTime of the existing entity.

*/ public LatticeHttpResponse publishEntity(Entity request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities") - .build(); + .addPathSegments("api/v1/entities"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -99,7 +104,7 @@ public LatticeHttpResponse publishEntity(Entity request, RequestOptions throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -150,13 +155,17 @@ public LatticeHttpResponse getEntity(String entityId, GetEntityRequest r public LatticeHttpResponse getEntity( String entityId, GetEntityRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") - .addPathSegment(entityId) - .build(); + .addPathSegment(entityId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -242,13 +251,17 @@ public LatticeHttpResponse overrideEntity(String entityId, String fieldP */ public LatticeHttpResponse overrideEntity( String entityId, String fieldPath, EntityOverride request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") .addPathSegment(entityId) .addPathSegments("override") - .addPathSegment(fieldPath) - .build(); + .addPathSegment(fieldPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -257,7 +270,7 @@ public LatticeHttpResponse overrideEntity( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -327,15 +340,19 @@ public LatticeHttpResponse removeEntityOverride( */ public LatticeHttpResponse removeEntityOverride( String entityId, String fieldPath, RemoveEntityOverrideRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/entities") .addPathSegment(entityId) .addPathSegments("override") - .addPathSegment(fieldPath) - .build(); + .addPathSegment(fieldPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("DELETE", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -402,10 +419,14 @@ public LatticeHttpResponse longPollEntityEvents(EntityEvent */ public LatticeHttpResponse longPollEntityEvents( EntityEventRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities/events") - .build(); + .addPathSegments("api/v1/entities/events"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -414,7 +435,7 @@ public LatticeHttpResponse longPollEntityEvents( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -444,10 +465,10 @@ public LatticeHttpResponse longPollEntityEvents( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); case 408: throw new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); case 429: throw new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); } } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error @@ -538,10 +559,14 @@ public LatticeHttpResponse> streamEntities(Enti */ public LatticeHttpResponse> streamEntities( EntityStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/entities/stream") - .build(); + .addPathSegments("api/v1/entities/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -550,11 +575,10 @@ public LatticeHttpResponse> streamEntities( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { diff --git a/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java b/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java index e4405824..d7199427 100644 --- a/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java +++ b/src/main/java/com/anduril/resources/oauth/AsyncRawOauthClient.java @@ -46,10 +46,14 @@ public CompletableFuture> getToken(GetToke */ public CompletableFuture> getToken( GetTokenRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/oauth/token") - .build(); + .addPathSegments("api/v1/oauth/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } FormBody.Builder body = new FormBody.Builder(); try { body.add("grant_type", String.valueOf(request.getGrantType())); @@ -65,7 +69,7 @@ public CompletableFuture> getToken( throw new RuntimeException(e); } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body.build()) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/x-www-form-urlencoded") diff --git a/src/main/java/com/anduril/resources/oauth/RawOauthClient.java b/src/main/java/com/anduril/resources/oauth/RawOauthClient.java index abb5ea07..543660fa 100644 --- a/src/main/java/com/anduril/resources/oauth/RawOauthClient.java +++ b/src/main/java/com/anduril/resources/oauth/RawOauthClient.java @@ -41,10 +41,14 @@ public LatticeHttpResponse getToken(GetTokenRequest request) { * 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()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/oauth/token") - .build(); + .addPathSegments("api/v1/oauth/token"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } FormBody.Builder body = new FormBody.Builder(); try { body.add("grant_type", String.valueOf(request.getGrantType())); @@ -60,7 +64,7 @@ public LatticeHttpResponse getToken(GetTokenRequest request, R throw new RuntimeException(e); } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body.build()) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/x-www-form-urlencoded") diff --git a/src/main/java/com/anduril/resources/objects/AsyncRawObjectsClient.java b/src/main/java/com/anduril/resources/objects/AsyncRawObjectsClient.java index 73e1f001..8df5c612 100644 --- a/src/main/java/com/anduril/resources/objects/AsyncRawObjectsClient.java +++ b/src/main/java/com/anduril/resources/objects/AsyncRawObjectsClient.java @@ -19,6 +19,7 @@ import com.anduril.errors.InternalServerError; import com.anduril.errors.NotFoundError; import com.anduril.errors.UnauthorizedError; +import com.anduril.resources.object.types.Error; import com.anduril.resources.objects.requests.DeleteObjectRequest; import com.anduril.resources.objects.requests.GetObjectMetadataRequest; import com.anduril.resources.objects.requests.GetObjectRequest; @@ -99,6 +100,15 @@ public CompletableFuture>> QueryStringMapper.addQueryParameter( httpUrl, "allObjectsInMesh", request.getAllObjectsInMesh().get(), false); } + if (request.getMaxPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "maxPageSize", request.getMaxPageSize().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -203,13 +213,17 @@ public CompletableFuture> getObject(String obje */ public CompletableFuture> getObject( String objectPath, GetObjectRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -291,14 +305,18 @@ public CompletableFuture> uploadObject(String */ public CompletableFuture> uploadObject( String objectPath, InputStream request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body = new InputStreamRequestBody(MediaType.parse("application/octet-stream"), request); Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .build(); @@ -331,7 +349,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO return; case 413: future.completeExceptionally(new ContentTooLargeError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); return; case 500: @@ -341,7 +359,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO return; case 507: future.completeExceptionally(new InsufficientStorageError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); return; } @@ -406,13 +424,17 @@ public CompletableFuture> deleteObject(String objectPa */ public CompletableFuture> deleteObject( String objectPath, DeleteObjectRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("DELETE", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -502,13 +524,17 @@ public CompletableFuture> getObjectMetadata( */ public CompletableFuture> getObjectMetadata( String objectPath, GetObjectMetadataRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("HEAD", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); diff --git a/src/main/java/com/anduril/resources/objects/RawObjectsClient.java b/src/main/java/com/anduril/resources/objects/RawObjectsClient.java index 290e4680..25c05c4d 100644 --- a/src/main/java/com/anduril/resources/objects/RawObjectsClient.java +++ b/src/main/java/com/anduril/resources/objects/RawObjectsClient.java @@ -19,6 +19,7 @@ import com.anduril.errors.InternalServerError; import com.anduril.errors.NotFoundError; import com.anduril.errors.UnauthorizedError; +import com.anduril.resources.object.types.Error; import com.anduril.resources.objects.requests.DeleteObjectRequest; import com.anduril.resources.objects.requests.GetObjectMetadataRequest; import com.anduril.resources.objects.requests.GetObjectRequest; @@ -92,6 +93,15 @@ public LatticeHttpResponse> listObjects( QueryStringMapper.addQueryParameter( httpUrl, "allObjectsInMesh", request.getAllObjectsInMesh().get(), false); } + if (request.getMaxPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "maxPageSize", request.getMaxPageSize().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -170,13 +180,17 @@ public LatticeHttpResponse getObject(String objectPath, GetObjectRe */ public LatticeHttpResponse getObject( String objectPath, GetObjectRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -237,14 +251,18 @@ public LatticeHttpResponse uploadObject(String objectPath, InputSt */ public LatticeHttpResponse uploadObject( String objectPath, InputStream request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body = new InputStreamRequestBody(MediaType.parse("application/octet-stream"), request); Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .build(); @@ -269,13 +287,13 @@ public LatticeHttpResponse uploadObject( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); case 413: throw new ContentTooLargeError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); case 500: throw new InternalServerError( ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); case 507: throw new InsufficientStorageError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); } } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error @@ -329,13 +347,17 @@ public LatticeHttpResponse deleteObject(String objectPath, DeleteObjectReq */ public LatticeHttpResponse deleteObject( String objectPath, DeleteObjectRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("DELETE", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -402,13 +424,17 @@ public LatticeHttpResponse getObjectMetadata(String objectPath, GetObjectM */ public LatticeHttpResponse getObjectMetadata( String objectPath, GetObjectMetadataRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/objects") - .addPathSegment(objectPath) - .build(); + .addPathSegment(objectPath); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("HEAD", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); diff --git a/src/main/java/com/anduril/resources/objects/requests/ListObjectsRequest.java b/src/main/java/com/anduril/resources/objects/requests/ListObjectsRequest.java index 0057fd1e..71c9b39e 100644 --- a/src/main/java/com/anduril/resources/objects/requests/ListObjectsRequest.java +++ b/src/main/java/com/anduril/resources/objects/requests/ListObjectsRequest.java @@ -29,6 +29,8 @@ public final class ListObjectsRequest { private final Optional allObjectsInMesh; + private final Optional maxPageSize; + private final Map additionalProperties; private ListObjectsRequest( @@ -36,11 +38,13 @@ private ListObjectsRequest( Optional sinceTimestamp, Optional pageToken, Optional allObjectsInMesh, + Optional maxPageSize, Map additionalProperties) { this.prefix = prefix; this.sinceTimestamp = sinceTimestamp; this.pageToken = pageToken; this.allObjectsInMesh = allObjectsInMesh; + this.maxPageSize = maxPageSize; this.additionalProperties = additionalProperties; } @@ -76,6 +80,14 @@ public Optional getAllObjectsInMesh() { return allObjectsInMesh; } + /** + * @return Sets the maximum number of items that should be returned on a single page. + */ + @JsonProperty("maxPageSize") + public Optional getMaxPageSize() { + return maxPageSize; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -91,12 +103,13 @@ private boolean equalTo(ListObjectsRequest other) { return prefix.equals(other.prefix) && sinceTimestamp.equals(other.sinceTimestamp) && pageToken.equals(other.pageToken) - && allObjectsInMesh.equals(other.allObjectsInMesh); + && allObjectsInMesh.equals(other.allObjectsInMesh) + && maxPageSize.equals(other.maxPageSize); } @java.lang.Override public int hashCode() { - return Objects.hash(this.prefix, this.sinceTimestamp, this.pageToken, this.allObjectsInMesh); + return Objects.hash(this.prefix, this.sinceTimestamp, this.pageToken, this.allObjectsInMesh, this.maxPageSize); } @java.lang.Override @@ -118,6 +131,8 @@ public static final class Builder { private Optional allObjectsInMesh = Optional.empty(); + private Optional maxPageSize = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -128,6 +143,7 @@ public Builder from(ListObjectsRequest other) { sinceTimestamp(other.getSinceTimestamp()); pageToken(other.getPageToken()); allObjectsInMesh(other.getAllObjectsInMesh()); + maxPageSize(other.getMaxPageSize()); return this; } @@ -187,8 +203,23 @@ public Builder allObjectsInMesh(Boolean allObjectsInMesh) { return this; } + /** + *

Sets the maximum number of items that should be returned on a single page.

+ */ + @JsonSetter(value = "maxPageSize", nulls = Nulls.SKIP) + public Builder maxPageSize(Optional maxPageSize) { + this.maxPageSize = maxPageSize; + return this; + } + + public Builder maxPageSize(Integer maxPageSize) { + this.maxPageSize = Optional.ofNullable(maxPageSize); + return this; + } + public ListObjectsRequest build() { - return new ListObjectsRequest(prefix, sinceTimestamp, pageToken, allObjectsInMesh, additionalProperties); + return new ListObjectsRequest( + prefix, sinceTimestamp, pageToken, allObjectsInMesh, maxPageSize, additionalProperties); } } } diff --git a/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java b/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java index 86cece54..d0742da9 100644 --- a/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/AsyncRawTasksClient.java @@ -94,10 +94,14 @@ public CompletableFuture> createTask(TaskCreation requ */ public CompletableFuture> createTask( TaskCreation request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks") - .build(); + .addPathSegments("api/v1/tasks"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -106,7 +110,7 @@ public CompletableFuture> createTask( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -206,13 +210,17 @@ public CompletableFuture> getTask(String taskId, GetTa */ public CompletableFuture> getTask( String taskId, GetTaskRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/tasks") - .addPathSegment(taskId) - .build(); + .addPathSegment(taskId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -324,12 +332,16 @@ public CompletableFuture> updateTaskStatus(String task */ public CompletableFuture> updateTaskStatus( String taskId, TaskStatusUpdate request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/tasks") .addPathSegment(taskId) - .addPathSegments("status") - .build(); + .addPathSegments("status"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -338,7 +350,7 @@ public CompletableFuture> updateTaskStatus( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -475,10 +487,14 @@ public CompletableFuture> queryTasks(TaskQ */ public CompletableFuture> queryTasks( TaskQuery request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks/query") - .build(); + .addPathSegments("api/v1/tasks/query"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -487,7 +503,7 @@ public CompletableFuture> queryTasks( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -583,10 +599,14 @@ public CompletableFuture>> str */ public CompletableFuture>> streamTasks( TaskStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks/stream") - .build(); + .addPathSegments("api/v1/tasks/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -595,11 +615,10 @@ public CompletableFuture>> str throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { @@ -740,10 +759,14 @@ public CompletableFuture> listenAsAgent(AgentL */ public CompletableFuture> listenAsAgent( AgentListener request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/agent/listen") - .build(); + .addPathSegments("api/v1/agent/listen"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -752,7 +775,7 @@ public CompletableFuture> listenAsAgent( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -886,10 +909,14 @@ public CompletableFuture>> s */ public CompletableFuture>> streamAsAgent( AgentStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/agent/stream") - .build(); + .addPathSegments("api/v1/agent/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -898,11 +925,10 @@ public CompletableFuture>> s throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { diff --git a/src/main/java/com/anduril/resources/tasks/RawTasksClient.java b/src/main/java/com/anduril/resources/tasks/RawTasksClient.java index 5d7b75a4..3c5e4fe0 100644 --- a/src/main/java/com/anduril/resources/tasks/RawTasksClient.java +++ b/src/main/java/com/anduril/resources/tasks/RawTasksClient.java @@ -89,10 +89,14 @@ public LatticeHttpResponse createTask(TaskCreation request) { * through other Tasks API endpoints.

*/ public LatticeHttpResponse createTask(TaskCreation request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks") - .build(); + .addPathSegments("api/v1/tasks"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -101,7 +105,7 @@ public LatticeHttpResponse createTask(TaskCreation request, RequestOptions throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -183,13 +187,17 @@ public LatticeHttpResponse getTask(String taskId, GetTaskRequest request) * perspective.

*/ public LatticeHttpResponse getTask(String taskId, GetTaskRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/tasks") - .addPathSegment(taskId) - .build(); + .addPathSegment(taskId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json"); @@ -282,12 +290,16 @@ public LatticeHttpResponse updateTaskStatus(String taskId, TaskStatusUpdat */ public LatticeHttpResponse updateTaskStatus( String taskId, TaskStatusUpdate request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/v1/tasks") .addPathSegment(taskId) - .addPathSegments("status") - .build(); + .addPathSegments("status"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -296,7 +308,7 @@ public LatticeHttpResponse updateTaskStatus( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -413,10 +425,14 @@ public LatticeHttpResponse queryTasks(TaskQuery request) { *

By default, this returns the latest task version for each matching task from the manager's perspective.

*/ public LatticeHttpResponse queryTasks(TaskQuery request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks/query") - .build(); + .addPathSegments("api/v1/tasks/query"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -425,7 +441,7 @@ public LatticeHttpResponse queryTasks(TaskQuery request, Reque throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -499,10 +515,14 @@ public LatticeHttpResponse> streamTasks(TaskStream */ public LatticeHttpResponse> streamTasks( TaskStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/tasks/stream") - .build(); + .addPathSegments("api/v1/tasks/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -511,11 +531,10 @@ public LatticeHttpResponse> streamTasks( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { @@ -638,10 +657,14 @@ public LatticeHttpResponse listenAsAgent(AgentListener request) { * period you will be expected to reinitiate a new request.

*/ public LatticeHttpResponse listenAsAgent(AgentListener request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/agent/listen") - .build(); + .addPathSegments("api/v1/agent/listen"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -650,7 +673,7 @@ public LatticeHttpResponse listenAsAgent(AgentListener request, Re throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -765,10 +788,14 @@ public LatticeHttpResponse> streamAsAgent(AgentS */ public LatticeHttpResponse> streamAsAgent( AgentStreamRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/v1/agent/stream") - .build(); + .addPathSegments("api/v1/agent/stream"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -777,11 +804,10 @@ public LatticeHttpResponse> streamAsAgent( throw new LatticeException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .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()) { diff --git a/src/main/java/com/anduril/types/DeliveryConstraints.java b/src/main/java/com/anduril/types/DeliveryConstraints.java new file mode 100644 index 00000000..78df4dee --- /dev/null +++ b/src/main/java/com/anduril/types/DeliveryConstraints.java @@ -0,0 +1,139 @@ +/** + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeliveryConstraints.Builder.class) +public final class DeliveryConstraints { + private final Optional deliverAfter; + + private final Optional deliverBefore; + + private final Map additionalProperties; + + private DeliveryConstraints( + Optional deliverAfter, + Optional deliverBefore, + Map additionalProperties) { + this.deliverAfter = deliverAfter; + this.deliverBefore = deliverBefore; + this.additionalProperties = additionalProperties; + } + + /** + * @return Optional earliest time the task can attempt to be delivered. + */ + @JsonProperty("deliverAfter") + public Optional getDeliverAfter() { + return deliverAfter; + } + + /** + * @return The latest time by which the task should be delivered. + * If this deadline passes without successful delivery of the task, then the task will time + * out with DELIVERY_ERROR_CODE_TIMEOUT. + * This field is only required for tasks with retry strategies. + */ + @JsonProperty("deliverBefore") + public Optional getDeliverBefore() { + return deliverBefore; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeliveryConstraints && equalTo((DeliveryConstraints) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeliveryConstraints other) { + return deliverAfter.equals(other.deliverAfter) && deliverBefore.equals(other.deliverBefore); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.deliverAfter, this.deliverBefore); + } + + @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 deliverAfter = Optional.empty(); + + private Optional deliverBefore = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeliveryConstraints other) { + deliverAfter(other.getDeliverAfter()); + deliverBefore(other.getDeliverBefore()); + return this; + } + + /** + *

Optional earliest time the task can attempt to be delivered.

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

The latest time by which the task should be delivered. + * If this deadline passes without successful delivery of the task, then the task will time + * out with DELIVERY_ERROR_CODE_TIMEOUT. + * This field is only required for tasks with retry strategies.

+ */ + @JsonSetter(value = "deliverBefore", nulls = Nulls.SKIP) + public Builder deliverBefore(Optional deliverBefore) { + this.deliverBefore = deliverBefore; + return this; + } + + public Builder deliverBefore(OffsetDateTime deliverBefore) { + this.deliverBefore = Optional.ofNullable(deliverBefore); + return this; + } + + public DeliveryConstraints build() { + return new DeliveryConstraints(deliverAfter, deliverBefore, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/DeliveryError.java b/src/main/java/com/anduril/types/DeliveryError.java new file mode 100644 index 00000000..3fe3d2dd --- /dev/null +++ b/src/main/java/com/anduril/types/DeliveryError.java @@ -0,0 +1,130 @@ +/** + * 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 = DeliveryError.Builder.class) +public final class DeliveryError { + private final Optional code; + + private final Optional message; + + private final Map additionalProperties; + + private DeliveryError( + Optional code, Optional message, Map additionalProperties) { + this.code = code; + this.message = message; + this.additionalProperties = additionalProperties; + } + + /** + * @return Error code for Delivery error. + */ + @JsonProperty("code") + public Optional getCode() { + return code; + } + + /** + * @return Descriptive human-readable string regarding this delivery error. + */ + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeliveryError && equalTo((DeliveryError) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeliveryError other) { + return code.equals(other.code) && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.code, this.message); + } + + @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 code = Optional.empty(); + + private Optional message = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeliveryError other) { + code(other.getCode()); + message(other.getMessage()); + return this; + } + + /** + *

Error code for Delivery error.

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

Descriptive human-readable string regarding this delivery error.

+ */ + @JsonSetter(value = "message", nulls = Nulls.SKIP) + public Builder message(Optional message) { + this.message = message; + return this; + } + + public Builder message(String message) { + this.message = Optional.ofNullable(message); + return this; + } + + public DeliveryError build() { + return new DeliveryError(code, message, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/DeliveryErrorCode.java b/src/main/java/com/anduril/types/DeliveryErrorCode.java new file mode 100644 index 00000000..29d1a4c3 --- /dev/null +++ b/src/main/java/com/anduril/types/DeliveryErrorCode.java @@ -0,0 +1,107 @@ +/** + * 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 DeliveryErrorCode { + public static final DeliveryErrorCode DELIVERY_ERROR_CODE_REJECTED = + new DeliveryErrorCode(Value.DELIVERY_ERROR_CODE_REJECTED, "DELIVERY_ERROR_CODE_REJECTED"); + + public static final DeliveryErrorCode DELIVERY_ERROR_CODE_INVALID = + new DeliveryErrorCode(Value.DELIVERY_ERROR_CODE_INVALID, "DELIVERY_ERROR_CODE_INVALID"); + + public static final DeliveryErrorCode DELIVERY_ERROR_CODE_UNAVAILABLE = + new DeliveryErrorCode(Value.DELIVERY_ERROR_CODE_UNAVAILABLE, "DELIVERY_ERROR_CODE_UNAVAILABLE"); + + public static final DeliveryErrorCode DELIVERY_ERROR_CODE_TIMEOUT = + new DeliveryErrorCode(Value.DELIVERY_ERROR_CODE_TIMEOUT, "DELIVERY_ERROR_CODE_TIMEOUT"); + + private final Value value; + + private final String string; + + DeliveryErrorCode(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 DeliveryErrorCode && this.string.equals(((DeliveryErrorCode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DELIVERY_ERROR_CODE_REJECTED: + return visitor.visitDeliveryErrorCodeRejected(); + case DELIVERY_ERROR_CODE_INVALID: + return visitor.visitDeliveryErrorCodeInvalid(); + case DELIVERY_ERROR_CODE_UNAVAILABLE: + return visitor.visitDeliveryErrorCodeUnavailable(); + case DELIVERY_ERROR_CODE_TIMEOUT: + return visitor.visitDeliveryErrorCodeTimeout(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeliveryErrorCode valueOf(String value) { + switch (value) { + case "DELIVERY_ERROR_CODE_REJECTED": + return DELIVERY_ERROR_CODE_REJECTED; + case "DELIVERY_ERROR_CODE_INVALID": + return DELIVERY_ERROR_CODE_INVALID; + case "DELIVERY_ERROR_CODE_UNAVAILABLE": + return DELIVERY_ERROR_CODE_UNAVAILABLE; + case "DELIVERY_ERROR_CODE_TIMEOUT": + return DELIVERY_ERROR_CODE_TIMEOUT; + default: + return new DeliveryErrorCode(Value.UNKNOWN, value); + } + } + + public enum Value { + DELIVERY_ERROR_CODE_INVALID, + + DELIVERY_ERROR_CODE_UNAVAILABLE, + + DELIVERY_ERROR_CODE_TIMEOUT, + + DELIVERY_ERROR_CODE_REJECTED, + + UNKNOWN + } + + public interface Visitor { + T visitDeliveryErrorCodeInvalid(); + + T visitDeliveryErrorCodeUnavailable(); + + T visitDeliveryErrorCodeTimeout(); + + T visitDeliveryErrorCodeRejected(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/anduril/types/DeliveryState.java b/src/main/java/com/anduril/types/DeliveryState.java new file mode 100644 index 00000000..65883742 --- /dev/null +++ b/src/main/java/com/anduril/types/DeliveryState.java @@ -0,0 +1,163 @@ +/** + * 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 = DeliveryState.Builder.class) +public final class DeliveryState { + private final Optional status; + + private final Optional error; + + private final Optional deliveryConstraints; + + private final Map additionalProperties; + + private DeliveryState( + Optional status, + Optional error, + Optional deliveryConstraints, + Map additionalProperties) { + this.status = status; + this.error = error; + this.deliveryConstraints = deliveryConstraints; + this.additionalProperties = additionalProperties; + } + + /** + * @return The current status of the delivery. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return Errors associated with the delivery, if any. + */ + @JsonProperty("error") + public Optional getError() { + return error; + } + + /** + * @return Optional scheduling constraints for Lattice delivery of the task. + */ + @JsonProperty("deliveryConstraints") + public Optional getDeliveryConstraints() { + return deliveryConstraints; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeliveryState && equalTo((DeliveryState) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeliveryState other) { + return status.equals(other.status) + && error.equals(other.error) + && deliveryConstraints.equals(other.deliveryConstraints); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.error, this.deliveryConstraints); + } + + @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 status = Optional.empty(); + + private Optional error = Optional.empty(); + + private Optional deliveryConstraints = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeliveryState other) { + status(other.getStatus()); + error(other.getError()); + deliveryConstraints(other.getDeliveryConstraints()); + return this; + } + + /** + *

The current status of the delivery.

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

Errors associated with the delivery, if any.

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

Optional scheduling constraints for Lattice delivery of the task.

+ */ + @JsonSetter(value = "deliveryConstraints", nulls = Nulls.SKIP) + public Builder deliveryConstraints(Optional deliveryConstraints) { + this.deliveryConstraints = deliveryConstraints; + return this; + } + + public Builder deliveryConstraints(DeliveryConstraints deliveryConstraints) { + this.deliveryConstraints = Optional.ofNullable(deliveryConstraints); + return this; + } + + public DeliveryState build() { + return new DeliveryState(status, error, deliveryConstraints, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/DeliveryStateStatus.java b/src/main/java/com/anduril/types/DeliveryStateStatus.java new file mode 100644 index 00000000..b69cc5e6 --- /dev/null +++ b/src/main/java/com/anduril/types/DeliveryStateStatus.java @@ -0,0 +1,118 @@ +/** + * 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 DeliveryStateStatus { + public static final DeliveryStateStatus DELIVERY_STATUS_PENDING_CANCEL = + new DeliveryStateStatus(Value.DELIVERY_STATUS_PENDING_CANCEL, "DELIVERY_STATUS_PENDING_CANCEL"); + + public static final DeliveryStateStatus DELIVERY_STATUS_DELIVERED = + new DeliveryStateStatus(Value.DELIVERY_STATUS_DELIVERED, "DELIVERY_STATUS_DELIVERED"); + + public static final DeliveryStateStatus DELIVERY_STATUS_INVALID = + new DeliveryStateStatus(Value.DELIVERY_STATUS_INVALID, "DELIVERY_STATUS_INVALID"); + + public static final DeliveryStateStatus DELIVERY_STATUS_PENDING_EXECUTE = + new DeliveryStateStatus(Value.DELIVERY_STATUS_PENDING_EXECUTE, "DELIVERY_STATUS_PENDING_EXECUTE"); + + public static final DeliveryStateStatus DELIVERY_STATUS_PENDING_COMPLETE = + new DeliveryStateStatus(Value.DELIVERY_STATUS_PENDING_COMPLETE, "DELIVERY_STATUS_PENDING_COMPLETE"); + + private final Value value; + + private final String string; + + DeliveryStateStatus(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 DeliveryStateStatus && this.string.equals(((DeliveryStateStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DELIVERY_STATUS_PENDING_CANCEL: + return visitor.visitDeliveryStatusPendingCancel(); + case DELIVERY_STATUS_DELIVERED: + return visitor.visitDeliveryStatusDelivered(); + case DELIVERY_STATUS_INVALID: + return visitor.visitDeliveryStatusInvalid(); + case DELIVERY_STATUS_PENDING_EXECUTE: + return visitor.visitDeliveryStatusPendingExecute(); + case DELIVERY_STATUS_PENDING_COMPLETE: + return visitor.visitDeliveryStatusPendingComplete(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeliveryStateStatus valueOf(String value) { + switch (value) { + case "DELIVERY_STATUS_PENDING_CANCEL": + return DELIVERY_STATUS_PENDING_CANCEL; + case "DELIVERY_STATUS_DELIVERED": + return DELIVERY_STATUS_DELIVERED; + case "DELIVERY_STATUS_INVALID": + return DELIVERY_STATUS_INVALID; + case "DELIVERY_STATUS_PENDING_EXECUTE": + return DELIVERY_STATUS_PENDING_EXECUTE; + case "DELIVERY_STATUS_PENDING_COMPLETE": + return DELIVERY_STATUS_PENDING_COMPLETE; + default: + return new DeliveryStateStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + DELIVERY_STATUS_INVALID, + + DELIVERY_STATUS_DELIVERED, + + DELIVERY_STATUS_PENDING_EXECUTE, + + DELIVERY_STATUS_PENDING_CANCEL, + + DELIVERY_STATUS_PENDING_COMPLETE, + + UNKNOWN + } + + public interface Visitor { + T visitDeliveryStatusInvalid(); + + T visitDeliveryStatusDelivered(); + + T visitDeliveryStatusPendingExecute(); + + T visitDeliveryStatusPendingCancel(); + + T visitDeliveryStatusPendingComplete(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/anduril/types/FixedRetry.java b/src/main/java/com/anduril/types/FixedRetry.java new file mode 100644 index 00000000..fcb5eab3 --- /dev/null +++ b/src/main/java/com/anduril/types/FixedRetry.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 = FixedRetry.Builder.class) +public final class FixedRetry { + private final Optional retryInterval; + + private final Map additionalProperties; + + private FixedRetry(Optional retryInterval, Map additionalProperties) { + this.retryInterval = retryInterval; + this.additionalProperties = additionalProperties; + } + + /** + * @return Specifies the interval between retries. A default interval of 5 seconds is used if this field is not set. + */ + @JsonProperty("retryInterval") + public Optional getRetryInterval() { + return retryInterval; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FixedRetry && equalTo((FixedRetry) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FixedRetry other) { + return retryInterval.equals(other.retryInterval); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.retryInterval); + } + + @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 retryInterval = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FixedRetry other) { + retryInterval(other.getRetryInterval()); + return this; + } + + /** + *

Specifies the interval between retries. A default interval of 5 seconds is used if this field is not set.

+ */ + @JsonSetter(value = "retryInterval", nulls = Nulls.SKIP) + public Builder retryInterval(Optional retryInterval) { + this.retryInterval = retryInterval; + return this; + } + + public Builder retryInterval(String retryInterval) { + this.retryInterval = Optional.ofNullable(retryInterval); + return this; + } + + public FixedRetry build() { + return new FixedRetry(retryInterval, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/RetryStrategy.java b/src/main/java/com/anduril/types/RetryStrategy.java new file mode 100644 index 00000000..3a825fff --- /dev/null +++ b/src/main/java/com/anduril/types/RetryStrategy.java @@ -0,0 +1,95 @@ +/** + * 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 = RetryStrategy.Builder.class) +public final class RetryStrategy { + private final Optional fixedRetryStrategy; + + private final Map additionalProperties; + + private RetryStrategy(Optional fixedRetryStrategy, Map additionalProperties) { + this.fixedRetryStrategy = fixedRetryStrategy; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("fixedRetryStrategy") + public Optional getFixedRetryStrategy() { + return fixedRetryStrategy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetryStrategy && equalTo((RetryStrategy) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetryStrategy other) { + return fixedRetryStrategy.equals(other.fixedRetryStrategy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.fixedRetryStrategy); + } + + @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 fixedRetryStrategy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RetryStrategy other) { + fixedRetryStrategy(other.getFixedRetryStrategy()); + return this; + } + + @JsonSetter(value = "fixedRetryStrategy", nulls = Nulls.SKIP) + public Builder fixedRetryStrategy(Optional fixedRetryStrategy) { + this.fixedRetryStrategy = fixedRetryStrategy; + return this; + } + + public Builder fixedRetryStrategy(FixedRetry fixedRetryStrategy) { + this.fixedRetryStrategy = Optional.ofNullable(fixedRetryStrategy); + return this; + } + + public RetryStrategy build() { + return new RetryStrategy(fixedRetryStrategy, additionalProperties); + } + } +} diff --git a/src/main/java/com/anduril/types/Task.java b/src/main/java/com/anduril/types/Task.java index 22adadfe..aec3fe13 100644 --- a/src/main/java/com/anduril/types/Task.java +++ b/src/main/java/com/anduril/types/Task.java @@ -52,6 +52,10 @@ public final class Task { private final Optional owner; + private final Optional retryStrategy; + + private final Optional deliveryState; + private final Map additionalProperties; private Task( @@ -70,6 +74,8 @@ private Task( Optional replication, Optional> initialEntities, Optional owner, + Optional retryStrategy, + Optional deliveryState, Map additionalProperties) { this.version = version; this.displayName = displayName; @@ -86,6 +92,8 @@ private Task( this.replication = replication; this.initialEntities = initialEntities; this.owner = owner; + this.retryStrategy = retryStrategy; + this.deliveryState = deliveryState; this.additionalProperties = additionalProperties; } @@ -214,6 +222,22 @@ public Optional getOwner() { return owner; } + /** + * @return Sets an optional try strategy for tasks. Use this option to control how Lattice attempts to retry delivery of tasks to assets with intermittent access or network connectivity to your environment. + */ + @JsonProperty("retryStrategy") + public Optional getRetryStrategy() { + return retryStrategy; + } + + /** + * @return The current delivery state of a task. + */ + @JsonProperty("deliveryState") + public Optional getDeliveryState() { + return deliveryState; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -240,7 +264,9 @@ private boolean equalTo(Task other) { && createTime.equals(other.createTime) && replication.equals(other.replication) && initialEntities.equals(other.initialEntities) - && owner.equals(other.owner); + && owner.equals(other.owner) + && retryStrategy.equals(other.retryStrategy) + && deliveryState.equals(other.deliveryState); } @java.lang.Override @@ -260,7 +286,9 @@ public int hashCode() { this.createTime, this.replication, this.initialEntities, - this.owner); + this.owner, + this.retryStrategy, + this.deliveryState); } @java.lang.Override @@ -304,6 +332,10 @@ public static final class Builder { private Optional owner = Optional.empty(); + private Optional retryStrategy = Optional.empty(); + + private Optional deliveryState = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -325,6 +357,8 @@ public Builder from(Task other) { replication(other.getReplication()); initialEntities(other.getInitialEntities()); owner(other.getOwner()); + retryStrategy(other.getRetryStrategy()); + deliveryState(other.getDeliveryState()); return this; } @@ -543,6 +577,34 @@ public Builder owner(Owner owner) { return this; } + /** + *

Sets an optional try strategy for tasks. Use this option to control how Lattice attempts to retry delivery of tasks to assets with intermittent access or network connectivity to your environment.

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

The current delivery state of a task.

+ */ + @JsonSetter(value = "deliveryState", nulls = Nulls.SKIP) + public Builder deliveryState(Optional deliveryState) { + this.deliveryState = deliveryState; + return this; + } + + public Builder deliveryState(DeliveryState deliveryState) { + this.deliveryState = Optional.ofNullable(deliveryState); + return this; + } + public Task build() { return new Task( version, @@ -560,6 +622,8 @@ public Task build() { replication, initialEntities, owner, + retryStrategy, + deliveryState, additionalProperties); } }